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.

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

mercurial