test: fix the CSP capability test (#2394)

This commit is contained in:
Pavel Feldman 2020-05-28 18:29:15 -07:00 committed by GitHub
parent 47ded05c39
commit 5277fb9479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,15 +34,17 @@ describe('Capabilities', function() {
expect(value).toBe('incoming');
});
it.fail(FFOX)('should respect CSP', async({page, server}) => {
server.setCSP('/empty.html', 'script-src ' + server.PREFIX);
it('should respect CSP', async({page, server}) => {
server.setRoute('/empty.html', async (req, res) => {
res.setHeader('Content-Security-Policy', `script-src 'unsafe-inline';`);
res.end(`
<script>
window.testStatus = 'SUCCESS';
window.testStatus = eval("'FAILED'");
</script>`);
});
await page.goto(server.EMPTY_PAGE);
expect(await page.evaluate(() => new Promise(f => setTimeout(() => {
try {
f(eval("'failed'"));
} catch (e) {
f('success');
}
}, 0)))).toBe('success');
expect(await page.evaluate(() => window.testStatus)).toBe('SUCCESS');
});
});