|
1 <html xmlns="http://www.w3.org/1999/xhtml"> |
|
2 <head> |
|
3 <title>sessionStorage replace test</title> |
|
4 |
|
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 --> |
|
11 |
|
12 <script type="text/javascript" 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, false); |
|
22 |
|
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; |
|
33 |
|
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; |
|
38 |
|
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; |
|
48 |
|
49 case "window": |
|
50 shell.close(); |
|
51 window.setTimeout(function() {SimpleTest.finish();}, 0); |
|
52 break; |
|
53 } |
|
54 break; |
|
55 |
|
56 default: |
|
57 SimpleTest.ok(!event.data.match(failureRegExp), event.data); |
|
58 break; |
|
59 } |
|
60 } |
|
61 |
|
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 } |
|
68 |
|
69 SimpleTest.waitForExplicitFinish(); |
|
70 |
|
71 </script> |
|
72 |
|
73 </head> |
|
74 |
|
75 <body onload="startTest();"> |
|
76 <iframe src="" name="frame"></iframe> |
|
77 </body> |
|
78 </html> |