docshell/test/navigation/test_reserved.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 <head>
michael@0 4 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 5 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 7 <script type="text/javascript" src="NavigationUtils.js"></script>
michael@0 8 <style type="text/css">
michael@0 9 iframe { width: 90%; height: 200px; }
michael@0 10 </style>
michael@0 11 <script>
michael@0 12 if (navigator.platform.startsWith("Mac")) {
michael@0 13 SimpleTest.expectAssertions(0, 2);
michael@0 14 }
michael@0 15
michael@0 16 function testTop() {
michael@0 17 window0 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#top,location", "_blank", "width=10,height=10");
michael@0 18
michael@0 19 xpcWaitForFinishedFrames(function() {
michael@0 20 isInaccessible(window0, "Should be able to navigate off-domain top by setting location.");
michael@0 21 window0.close();
michael@0 22 xpcCleanupWindows();
michael@0 23
michael@0 24 window1 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,open", "_blank", "width=10,height=10");
michael@0 25
michael@0 26 xpcWaitForFinishedFrames(function() {
michael@0 27 isInaccessible(window1, "Should be able to navigate off-domain top by calling window.open.");
michael@0 28 window1.close();
michael@0 29 xpcCleanupWindows();
michael@0 30
michael@0 31 window2 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,form", "_blank", "width=10,height=10");
michael@0 32
michael@0 33 xpcWaitForFinishedFrames(function() {
michael@0 34 isInaccessible(window2, "Should be able to navigate off-domain top by submitting form.");
michael@0 35 window2.close();
michael@0 36 xpcCleanupWindows();
michael@0 37
michael@0 38 window3 = window.open("iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_top,hyperlink", "_blank", "width=10,height=10");
michael@0 39
michael@0 40 xpcWaitForFinishedFrames(function() {
michael@0 41 isInaccessible(window3, "Should be able to navigate off-domain top by targeted hyperlink.");
michael@0 42 window3.close();
michael@0 43 xpcCleanupWindows();
michael@0 44
michael@0 45 testParent();
michael@0 46 }, 1);
michael@0 47 }, 1);
michael@0 48 }, 1);
michael@0 49 }, 1);
michael@0 50 }
michael@0 51
michael@0 52 function testParent() {
michael@0 53 document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#parent,location"></iframe>';
michael@0 54
michael@0 55 xpcWaitForFinishedFrames(function() {
michael@0 56 isAccessible(frames[0], "Should not be able to navigate off-domain parent by setting location.");
michael@0 57 xpcCleanupWindows();
michael@0 58
michael@0 59 document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_parent,open"></iframe>';
michael@0 60
michael@0 61 xpcWaitForFinishedFrames(function() {
michael@0 62 isAccessible(frames[0], "Should not be able to navigate off-domain parent by calling window.open.");
michael@0 63 xpcCleanupWindows();
michael@0 64
michael@0 65 document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_parent,form"></iframe>';
michael@0 66
michael@0 67 xpcWaitForFinishedFrames(function() {
michael@0 68 isAccessible(frames[0], "Should not be able to navigate off-domain parent by submitting form.");
michael@0 69 xpcCleanupWindows();
michael@0 70
michael@0 71 document.getElementById("frames").innerHTML = '<iframe src="iframe.html#http://test1.example.org:80/tests/docshell/test/navigation/navigate.html#_parent,hyperlink"></iframe>';
michael@0 72
michael@0 73 xpcWaitForFinishedFrames(function() {
michael@0 74 isAccessible(frames[0], "Should not be able to navigate off-domain parent by targeted hyperlink.");
michael@0 75 xpcCleanupWindows();
michael@0 76
michael@0 77 document.getElementById("frames").innerHTML = "";
michael@0 78 SimpleTest.finish();
michael@0 79 }, 1);
michael@0 80 }, 1);
michael@0 81 }, 1);
michael@0 82 }, 1);
michael@0 83 }
michael@0 84
michael@0 85 window.onload = function() {
michael@0 86 testTop();
michael@0 87 }
michael@0 88 </script>
michael@0 89 </head>
michael@0 90 <body>
michael@0 91 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=408052">Mozilla Bug 408052</a>
michael@0 92 <div id="frames">
michael@0 93 </div>
michael@0 94 <pre id="test">
michael@0 95 <script type="text/javascript">
michael@0 96 SimpleTest.waitForExplicitFinish();
michael@0 97 </script>
michael@0 98 </pre>
michael@0 99 </body>
michael@0 100 </html>

mercurial