Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/sandbox-iframe-blocks-top-navigation-to-javascript.html

Issue 2371993003: Throw when blocking top-level navigation. (Closed)
Patch Set: Test. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="/resources/testharness.js"></script>
3 <script src="/resources/testharnessreport.js"></script>
4 <body>
5 <script>
6 async_test(t => {
7 var i = document.createElement('iframe');
8 i.sandbox = "allow-scripts allow-same-origin allow-modals";
9 i.srcdoc = "<script>" +
10 " window.onerror = (m,f,l,c,e) => { top.postMessage(e.name, '*'); }" +
11 "</scr" + "ipt>" +
12 "<a href='javascript:top.location=\"/security/frameNavigation /resources/fail.html\";'>click</a>";
13
14 window.onmessage = t.step_func_done(e => {
15 assert_equals(e.data, "SecurityError", "The 'javascript:' navigation threw.");
16 assert_equals(i.contentDocument.body.innerText, "click", "The page c ontents did not change.");
17 });
18
19 var clicked = false;
20 i.onload = t.step_func(e => {
21 i.contentDocument.querySelector('a').click();
22 clicked = true;
23 });
24
25 document.body.appendChild(i);
26 }, "Sandboxed frames should throw when navigating the top-level window.");
27 </script>
28 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698