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.

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

mercurial