test: add test on Page.evaluateOnNewDocument with CSP (#2319)
This patch adds a test that Page.evaluateOnNewDocument works with CSP: there's been some concerns on the bugtracker before. References #1229
This commit is contained in:
parent
1fdd33886f
commit
4663b43a62
1
test/assets/csp.html
Normal file
1
test/assets/csp.html
Normal file
@ -0,0 +1 @@
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'">
|
@ -1508,6 +1508,18 @@ module.exports.addTests = function({testRunner, expect, defaultBrowserOptions, p
|
||||
await page.goto(server.PREFIX + '/tamperable.html');
|
||||
expect(await page.evaluate(() => window.result)).toBe(123);
|
||||
});
|
||||
it('should work with CSP', async({page, server}) => {
|
||||
server.setCSP('/empty.html', 'script-src ' + server.PREFIX);
|
||||
await page.evaluateOnNewDocument(function(){
|
||||
window.injected = 123;
|
||||
});
|
||||
await page.goto(server.PREFIX + '/empty.html');
|
||||
expect(await page.evaluate(() => window.injected)).toBe(123);
|
||||
|
||||
// Make sure CSP works.
|
||||
await page.addScriptTag({content: 'window.e = 10;'}).catch(e => void e);
|
||||
expect(await page.evaluate(() => window.e)).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.setCacheEnabled', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user