forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CSP] Fix WPT eval-blocked-in-about-blank-iframe
The test was failing for all vendors since it expected to get a securitypolicyviolation event in the parent frame instead of the frame where the eval was blocked. I rewrote the test in a modern way and deleted the old http blink test this one had been converted from. Bug: 651742 Change-Id: Ie8b7ae4842c0934b3c18086a2aee93c8a8ca292a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3059564 Commit-Queue: Antonio Sartori <antoniosartori@chromium.org> Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org> Cr-Commit-Position: refs/heads/master@{#906671}
- Loading branch information
Showing
5 changed files
with
61 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
.../external/wpt/content-security-policy/unsafe-eval/eval-blocked-in-about-blank-iframe.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta http-equiv="Content-Security-Policy" | ||
content="script-src 'self' 'unsafe-inline';"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
|
||
<body> | ||
|
||
<p> | ||
Eval should be blocked in the iframe, but inline script should be allowed. | ||
</p> | ||
|
||
<script> | ||
promise_test(async t => { | ||
const document_loaded = new Promise(resolve => window.onload = resolve); | ||
await document_loaded; | ||
|
||
const eval_error = new Promise(resolve => { | ||
window.addEventListener('message', function(e) { | ||
assert_not_equals(e.data, 'FAIL', 'eval was executed in the frame'); | ||
if (e.data === 'PASS') | ||
resolve(); | ||
}); | ||
}); | ||
const csp_violation_report = new Promise(resolve => { | ||
window.addEventListener('message', function(e) { | ||
if (e.data["violated-directive"]) { | ||
assert_equals(e.data["violated-directive"], "script-src"); | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
|
||
frames[0].document.write(` | ||
<script> | ||
window.addEventListener('securitypolicyviolation', function(e) { | ||
parent.postMessage({ 'violated-directive': e.violatedDirective }); | ||
}); | ||
try { | ||
eval('parent.postMessage(\"FAIL\", \"*\");'); | ||
} catch (e) { | ||
if (e instanceof EvalError) | ||
parent.postMessage(\"PASS\", \"*\"); | ||
} | ||
</sc` + `ript>` | ||
); | ||
frames[0].document.close(); | ||
|
||
await eval_error; | ||
await csp_violation_report; | ||
}); | ||
</script> | ||
<iframe src="about:blank"></iframe> | ||
|
||
</body> | ||
|
||
</html> |
34 changes: 0 additions & 34 deletions
34
...ernal/wpt/content-security-policy/unsafe-eval/eval-blocked-in-about-blank-iframe.sub.html
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...http/tests/security/contentSecurityPolicy/eval-blocked-in-about-blank-iframe-expected.txt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...b_tests/http/tests/security/contentSecurityPolicy/eval-blocked-in-about-blank-iframe.html
This file was deleted.
Oops, something went wrong.