Skip to content

Commit

Permalink
Check the source browsing context's CSP in Location::SetLocation prio…
Browse files Browse the repository at this point in the history
…r to dispatching a navigation to a `javascript:` URL.

Makes `javascript:` navigations via window.location.href compliant with
https://html.spec.whatwg.org/#navigate, which states that the source
browsing context must be checked (rather than the current browsing
context).

Bug: 909865
Change-Id: Id6aef6eef56865e164816c67eb9fe07ea1cb1b4e
Reviewed-on: https://chromium-review.googlesource.com/c/1359823
Reviewed-by: Andy Paicu <[email protected]>
Reviewed-by: Mike West <[email protected]>
Commit-Queue: Andrew Comminos <[email protected]>
Cr-Commit-Position: refs/heads/master@{#614451}
  • Loading branch information
acomminos authored and chromium-wpt-export-bot committed Dec 6, 2018
1 parent 047734d commit ffcb833
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<head>
<meta http-equiv="content-security-policy" content="script-src 'self' 'nonce-abc'">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<iframe src="support/frame-with-csp.sub.html?csp=script-src%20'self'%20'unsafe-inline'"></iframe>
<script nonce='abc'>
var t = async_test("Should not have executed the javascript url");
const iframe = document.querySelector("iframe");
iframe.addEventListener('load', () => {
window.onmessage = t.step_func(function(e) {
if (e.data == "executed")
assert_true(false, "Javascript url executed");
});
window.addEventListener('securitypolicyviolation', t.step_func_done(function(e) {
assert_equals(e.blockedURI, 'inline');
}));
iframe.contentWindow.location.href = 'javascript:parent.postMessage(\'executed\', \'*\')'
});
</script>
</body>

0 comments on commit ffcb833

Please sign in to comment.