tor-browser

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

test_bug458091.html (2760B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=458091
      5 -->
      6 <head>
      7  <title>Test for Bug 458091</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     11 </head>
     12 <body>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=458091">Mozilla Bug 458091</a>
     14 
     15 <div id="content" style="display: none">
     16 
     17 </div>
     18 <pre id="test">
     19 <a id="testlink1" target="_blank" rel="opener" href="javascript:window.opener.finish(sessionStorage['testItem']);window.close();">Javascript Link</a>
     20 <a id="testlink2" target="_blank" rel="opener" href="bug458091_child.html">HTTP Link</a>
     21 <a id="testlink3" target="alreadyOpened" href="bug458091_child.html">Target Link</a>
     22 <script type="application/javascript">
     23 
     24 /** Test for Bug 458091 */
     25 
     26 var gTestWin;
     27 var gRunningTests = 0;
     28 
     29 function runNextTest()
     30 {
     31  if (gTests.length) {
     32    var test = gTests.shift();
     33    test();
     34  } else {
     35    SimpleTest.finish();
     36  }
     37 }
     38 
     39 function finish(val)
     40 {
     41  is(val, "correct value",
     42     "New window should access the correct session storage");
     43  if (--gRunningTests == 0) {
     44    runNextTest();
     45  }
     46 }
     47 
     48 SimpleTest.waitForExplicitFinish();
     49 
     50 function test1() {
     51  sessionStorage.testItem = "correct value";
     52 
     53  gRunningTests++;
     54  window.open('javascript:window.opener.finish(sessionStorage["testItem"]);window.close();');
     55 
     56  gRunningTests++;
     57  window.open("bug458091_child.html");
     58 
     59  gRunningTests++;
     60  sendMouseEvent({type: "click"}, "testlink1");
     61 
     62  gRunningTests++;
     63  sendMouseEvent({type: "click"}, "testlink2");
     64 
     65  // targetted load into an existing window
     66  var testWin = window.open("about:blank", "alreadyOpened");
     67  gRunningTests++;
     68  sendMouseEvent({type: "click"}, "testlink3");
     69 
     70  // window.location into an existing window.  Leave the window open
     71  // for further tests...
     72  gRunningTests++;
     73  gTestWin = window.open("about:blank", "testWindow");
     74  gTestWin.location = 'javascript:window.opener.finish(sessionStorage["testItem"]);';
     75 }
     76 
     77 function test2() {
     78  // Now change session storage and load a new item in gTestWin, to
     79  // verify that they properly diverged after window.open().
     80  gRunningTests++;
     81  sessionStorage.testItem = "incorrect value";
     82  gTestWin.location = 'javascript:window.opener.finish(sessionStorage["testItem"]);';
     83 }
     84 
     85 function test3()
     86 {
     87  // Now, with session storage still changed, try the window.open()
     88  // path, make sure it doesn't overwrite the session storage.
     89  gRunningTests++;
     90  window.open('javascript:window.opener.finish(sessionStorage["testItem"]);window.close();',
     91              "testWindow");
     92 }
     93 
     94 var gTests = [test1, test2, test3];
     95 
     96 runNextTest();
     97 
     98 </script>
     99 </pre>
    100 </body>
    101 </html>