Skip to content

Commit 5277fb9

Browse files
authored
test: fix the CSP capability test (#2394)
1 parent 47ded05 commit 5277fb9

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

test/capabilities.spec.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,17 @@ describe('Capabilities', function() {
3434
expect(value).toBe('incoming');
3535
});
3636

37-
it.fail(FFOX)('should respect CSP', async({page, server}) => {
38-
server.setCSP('/empty.html', 'script-src ' + server.PREFIX);
37+
it('should respect CSP', async({page, server}) => {
38+
server.setRoute('/empty.html', async (req, res) => {
39+
res.setHeader('Content-Security-Policy', `script-src 'unsafe-inline';`);
40+
res.end(`
41+
<script>
42+
window.testStatus = 'SUCCESS';
43+
window.testStatus = eval("'FAILED'");
44+
</script>`);
45+
});
46+
3947
await page.goto(server.EMPTY_PAGE);
40-
expect(await page.evaluate(() => new Promise(f => setTimeout(() => {
41-
try {
42-
f(eval("'failed'"));
43-
} catch (e) {
44-
f('success');
45-
}
46-
}, 0)))).toBe('success');
48+
expect(await page.evaluate(() => window.testStatus)).toBe('SUCCESS');
4749
});
4850
});

0 commit comments

Comments
 (0)