dom/tests/mochitest/sessionstorage/test_sessionStorageReplace.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 <html xmlns="http://www.w3.org/1999/xhtml">
     2 <head>
     3 <title>sessionStorage replace test</title>
     5 <!--
     6   This test checks that sessionStorage 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 -->
    12 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    13 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    15 <script type="text/javascript">
    17 var shell;
    18 var shellType;
    19 var failureRegExp = new RegExp("^FAILURE");
    21 window.addEventListener("message", onMessageReceived, false);
    23 function onMessageReceived(event)
    24 {
    25   //alert("onMessageReceived "+event.data);
    26   switch (event.data)
    27   {
    28     case "init_done":
    29       // This is frame with different origin in the same browsing context
    30       // as the first frame adding data to sessionStorage of the first origin.
    31       shell.location = "http://example.com/tests/dom/tests/mochitest/sessionstorage/frameReplace.html?check&" + shellType;
    32       break;
    34     case "check_done":
    35       // Recheck and clean the sessionStorage of the first origin.
    36       shell.location = "http://example.org:80/tests/dom/tests/mochitest/sessionstorage/frameReplace.html?clean&" + shellType;
    37       break;
    39     case "clean_done":
    40       switch (shellType)
    41       {
    42         case "frame":
    43           // We finished testing in a frame
    44           // proceed with test in a separate window
    45           shellType = "window";
    46           shell = window.open("http://example.org/tests/dom/tests/mochitest/sessionstorage/frameReplace.html?init&" + shellType);
    47           break;
    49         case "window":
    50           shell.close();
    51           window.setTimeout(function() {SimpleTest.finish();}, 0);
    52           break;
    53       }
    54       break;
    56     default:
    57       SimpleTest.ok(!event.data.match(failureRegExp), event.data);
    58       break;
    59   }
    60 }
    62 function startTest()
    63 {
    64   shellType = "frame";
    65   shell = frame;
    66   shell.location = "http://example.org/tests/dom/tests/mochitest/sessionstorage/frameReplace.html?init&" + shellType;
    67 }
    69 SimpleTest.waitForExplicitFinish();
    71 </script>
    73 </head>
    75 <body onload="startTest();">
    76   <iframe src="" name="frame"></iframe>
    77 </body>
    78 </html>

mercurial