tor-browser

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

test_localStorageReplace.html (2317B)


      1 <html xmlns="http://www.w3.org/1999/xhtml">
      2 <head>
      3 <title>localStorage replace test</title>
      4 
      5 <!--
      6  This test checks that localStorage object doesn't leak
      7  in a window that changes its location. We do this by switching
      8  frame location inside of this window and then by changing location
      9  of a top level window.
     10 -->
     11 
     12 <script src="/tests/SimpleTest/SimpleTest.js"></script>
     13 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     14 
     15 <script type="text/javascript">
     16 
     17 var shell;
     18 var shellType;
     19 var failureRegExp = new RegExp("^FAILURE");
     20 
     21 window.addEventListener("message", onMessageReceived);
     22 
     23 function onMessageReceived(event)
     24 {
     25  switch (event.data)
     26  {
     27    case "init_done":
     28      // This is frame with different origin in the same browsing context
     29      // as the first frame adding data to localStorage of the first origin.
     30      shell.location = "http://example.com:80/tests/dom/tests/mochitest/localstorage/frameReplace.html?check&" + shellType;
     31      break;
     32 
     33    case "check_done":
     34      // Clean the localStorage of the first origin.
     35      shell.location = "http://example.org:80/tests/dom/tests/mochitest/localstorage/frameReplace.html?clean&" + shellType;
     36      break;
     37 
     38    case "clean_done":
     39      switch (shellType)
     40      {
     41        case "frame":
     42          // We finished testing in a frame
     43          // proceed with test in a separate window
     44          shellType = "window";
     45          shell = window.open("http://example.org:80/tests/dom/tests/mochitest/localstorage/frameReplace.html?init&" + shellType);
     46          break;
     47 
     48        case "window":
     49          shell.close();
     50          window.setTimeout(function() {SimpleTest.finish();}, 0);
     51          break;
     52      }
     53      break;
     54 
     55    default:
     56      SimpleTest.ok(!event.data.match(failureRegExp), event.data);
     57      break;
     58  }
     59 }
     60 
     61 function startTest() {
     62  SpecialPowers.pushPrefEnv({"set": [["security.mixed_content.block_display_content", false], ["security.mixed_content.block_active_content", false]]}, test1);
     63 }
     64 
     65 function test1() {
     66  shellType = "frame";
     67  shell = frame;
     68  shell.location = "http://example.org:80/tests/dom/tests/mochitest/localstorage/frameReplace.html?init&" + shellType;
     69 }
     70 
     71 SimpleTest.waitForExplicitFinish();
     72 
     73 </script>
     74 
     75 </head>
     76 
     77 <body onload="startTest();">
     78  <iframe src="" name="frame"></iframe>
     79 </body>
     80 </html>