mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test: ensure Page.setBypassCSP works with iFrames (#4155)
This commit is contained in:
parent
e3a4f3411c
commit
6474b3ffe0
@ -781,6 +781,25 @@ module.exports.addTests = function({testRunner, expect, headless, Errors, Device
|
||||
await page.addScriptTag({content: 'window.__injected = 42;'});
|
||||
expect(await page.evaluate(() => window.__injected)).toBe(42);
|
||||
});
|
||||
it('should bypass CSP in iframes as well', async({page, server}) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
{
|
||||
// Make sure CSP prohibits addScriptTag in an iframe.
|
||||
const frame = await utils.attachFrame(page, 'frame1', server.PREFIX + '/csp.html');
|
||||
await frame.addScriptTag({content: 'window.__injected = 42;'}).catch(e => void e);
|
||||
expect(await frame.evaluate(() => window.__injected)).toBe(undefined);
|
||||
}
|
||||
|
||||
// By-pass CSP and try one more time.
|
||||
await page.setBypassCSP(true);
|
||||
await page.reload();
|
||||
|
||||
{
|
||||
const frame = await utils.attachFrame(page, 'frame1', server.PREFIX + '/csp.html');
|
||||
await frame.addScriptTag({content: 'window.__injected = 42;'}).catch(e => void e);
|
||||
expect(await frame.evaluate(() => window.__injected)).toBe(42);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page.addScriptTag', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user