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 parent 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 != "parentIframe") { |
michael@0 | 19 | ok(false, "event.data: got '" + event.data + "', expected 'parentIframe'"); |
michael@0 | 20 | } |
michael@0 | 21 | ok(false, testCase.desc, "parent navigation was NOT blocked"); |
michael@0 | 22 | runNextTest(); |
michael@0 | 23 | }; |
michael@0 | 24 | try { |
michael@0 | 25 | window["parentIframe"]["childIframe"].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: parent.location.replace should be blocked even when sandboxed with allow-same-origin allow-top-navigation", |
michael@0 | 36 | script: "parent.location.replace('file_parent_navigation_by_location.html')" |
michael@0 | 37 | }, |
michael@0 | 38 | { |
michael@0 | 39 | desc: "Test 2: parent.location.assign should be blocked even when sandboxed with allow-same-origin allow-top-navigation", |
michael@0 | 40 | script: "parent.location.assign('file_parent_navigation_by_location.html')" |
michael@0 | 41 | }, |
michael@0 | 42 | { |
michael@0 | 43 | desc: "Test 3: parent.location.href should be blocked even when sandboxed with allow-same-origin allow-top-navigation", |
michael@0 | 44 | script: "parent.location.href = 'file_parent_navigation_by_location.html'" |
michael@0 | 45 | }, |
michael@0 | 46 | { |
michael@0 | 47 | desc: "Test 4: parent.location.hash should be blocked even when sandboxed with allow-same-origin allow-top-navigation", |
michael@0 | 48 | script: "parent.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 | SimpleTest.finish(); |
michael@0 | 56 | return; |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | runScriptNavigationTest(testCases[testCaseIndex]); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | window.onmessage = runNextTest; |
michael@0 | 63 | </script> |
michael@0 | 64 | </head> |
michael@0 | 65 | <body> |
michael@0 | 66 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=785310">Mozilla Bug 785310</a> |
michael@0 | 67 | <p id="display"></p> |
michael@0 | 68 | <div id="content"> |
michael@0 | 69 | Tests for Bug 785310 |
michael@0 | 70 | </div> |
michael@0 | 71 | |
michael@0 | 72 | <iframe name="parentIframe" src="file_parent_navigation_by_location.html"></iframe> |
michael@0 | 73 | |
michael@0 | 74 | </body> |
michael@0 | 75 | </html> |