Skip to content

Commit

Permalink
test: fix the CSP capability test (#2394)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed May 29, 2020
1 parent 47ded05 commit 5277fb9
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions test/capabilities.spec.js
Expand Up @@ -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');
});
});

0 comments on commit 5277fb9

Please sign in to comment.