Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <head>
3 <title>localStorage replace test</title>
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 -->
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 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;
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;
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;
48 case "window":
49 shell.close();
50 window.setTimeout(function() {SimpleTest.finish();}, 0);
51 break;
52 }
53 break;
55 default:
56 SimpleTest.ok(!event.data.match(failureRegExp), event.data);
57 break;
58 }
59 }
61 function startTest() {
62 SpecialPowers.pushPrefEnv({"set": [["security.mixed_content.block_display_content", false], ["security.mixed_content.block_active_content", false]]}, test1);
63 }
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 }
71 SimpleTest.waitForExplicitFinish();
73 </script>
75 </head>
77 <body onload="startTest();">
78 <iframe src="" name="frame"></iframe>
79 </body>
80 </html>