tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_reserved.html (3659B)


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