Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=785310
5 html5 sandboxed iframe should not be able to perform top navigation with scripts allowed
6 -->
7 <head>
8 <meta charset="utf-8">
9 <title>Test for Bug 785310 - iframe sandbox other auxiliary navigation by location tests</title>
10 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
13 <script>
14 SimpleTest.waitForExplicitFinish();
16 function runScriptNavigationTest(testCase) {
17 window.onmessage = function(event) {
18 if (event.data != "otherWindow") {
19 ok(false, "event.data: got '" + event.data + "', expected 'otherWindow'");
20 }
21 ok(false, testCase.desc, "auxiliary navigation was NOT blocked");
22 runNextTest();
23 };
24 try {
25 window["testIframe"].eval(testCase.script);
26 } catch(e) {
27 ok(true, testCase.desc, e.message);
28 runNextTest();
29 }
30 }
32 var testCaseIndex = -1;
33 testCases = [
34 {
35 desc: "Test 1: location.replace on auxiliary NOT opened by us should be blocked",
36 script: "parent.openedWindow.location.replace('file_other_auxiliary_navigation_by_location.html')"
37 },
38 {
39 desc: "Test 2: location.assign on auxiliary NOT opened by us should be blocked",
40 script: "parent.openedWindow.location.assign('file_other_auxiliary_navigation_by_location.html')"
41 },
42 {
43 desc: "Test 3: location.href on auxiliary NOT opened by us should be blocked",
44 script: "parent.openedWindow.location.href = 'file_other_auxiliary_navigation_by_location.html'"
45 },
46 {
47 desc: "Test 4: location.hash on auxiliary NOT opened by us should be blocked",
48 script: "parent.openedWindow.location.hash = 'wibble'"
49 }
50 ];
52 function runNextTest() {
53 ++testCaseIndex;
54 if (testCaseIndex == testCases.length) {
55 openedWindow.close();
56 SimpleTest.finish();
57 return;
58 }
60 runScriptNavigationTest(testCases[testCaseIndex]);
61 }
63 window.onmessage = runNextTest;
65 window.onload = function() {
66 window.openedWindow = window.open("file_other_auxiliary_navigation_by_location.html", "otherWindow");
67 }
68 </script>
70 </head>
71 <body>
72 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=785310">Mozilla Bug 785310</a>
73 <p id="display"></p>
74 <div id="content">
75 Tests for Bug 785310
76 </div>
78 <iframe name="testIframe" sandbox="allow-scripts allow-same-origin allow-top-navigation allow-popups"></iframe>
79 </body>
80 </html>