Tue, 06 Jan 2015 21:39:09 +0100
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 <!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 type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="application/javascript" 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>
15 <div id="content" style="display: none">
17 </div>
18 <pre id="test">
19 <a id="testlink1" target="_blank" href="javascript:window.opener.finish(sessionStorage['testItem']);window.close();">Javascript Link</a>
20 <a id="testlink2" target="_blank" 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">
24 /** Test for Bug 458091 **/
26 var gTestWin;
27 var gRunningTests = 0;
29 function runNextTest()
30 {
31 if (gTests.length > 0) {
32 var test = gTests.shift();
33 test();
34 } else {
35 SimpleTest.finish();
36 }
37 }
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 }
48 SimpleTest.waitForExplicitFinish();
50 function test1() {
51 sessionStorage["testItem"] = "correct value";
53 gRunningTests++;
54 window.open('javascript:window.opener.finish(sessionStorage["testItem"]);window.close();');
56 gRunningTests++;
57 window.open("bug458091_child.html");
59 gRunningTests++;
60 sendMouseEvent({type: "click"}, "testlink1");
62 gRunningTests++;
63 sendMouseEvent({type: "click"}, "testlink2");
65 // targetted load into an existing window
66 var testWin = window.open("about:blank", "alreadyOpened");
67 gRunningTests++;
68 sendMouseEvent({type: "click"}, "testlink3");
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 }
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 }
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 }
94 var gTests = [test1, test2, test3];
95 runNextTest();
97 </script>
98 </pre>
99 </body>
100 </html>