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