|
1 <html xmlns="http://www.w3.org/1999/xhtml"> |
|
2 <head> |
|
3 <title>sessionStorage clone equal origins</title> |
|
4 |
|
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <script type="text/javascript" src="interOriginTest.js"></script> |
|
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
8 |
|
9 <script type="text/javascript"> |
|
10 |
|
11 var currentTest = 1; |
|
12 var currentStep = 1; |
|
13 |
|
14 /* |
|
15 window.addEventListener("storage", onStorageEvent, false); |
|
16 |
|
17 function onStorageEvent(event) |
|
18 { |
|
19 } |
|
20 */ |
|
21 |
|
22 function doNextTest() |
|
23 { |
|
24 // We must perform the first step of the test |
|
25 // to prepare the land. |
|
26 currentStep = 1; |
|
27 doStep(); |
|
28 |
|
29 switch (currentTest) |
|
30 { |
|
31 case 1: |
|
32 // Open a window from the same origin and check data |
|
33 // are copied but not further modified on our side |
|
34 slaveOrigin = "http://mochi.test:8888"; |
|
35 slave = window.open(slaveOrigin + slavePath + "frameEqual.html"); |
|
36 break; |
|
37 |
|
38 case 2: |
|
39 slave.close(); |
|
40 // Open a window from a different origin and check data |
|
41 // are NOT copied and not modified on our side |
|
42 slaveOrigin = "http://example.com"; |
|
43 slave = window.open(slaveOrigin + slavePath + "frameNotEqual.html"); |
|
44 break; |
|
45 |
|
46 case 3: |
|
47 slave.close(); |
|
48 sessionStorage.clear(); |
|
49 SimpleTest.finish(); |
|
50 break; |
|
51 } |
|
52 |
|
53 ++currentTest; |
|
54 } |
|
55 |
|
56 function doStep() |
|
57 { |
|
58 switch (currentStep) |
|
59 { |
|
60 case 1: |
|
61 sessionStorage.setItem("A", "1"); |
|
62 sessionStorage.setItem("B", "2"); |
|
63 is(sessionStorage.getItem("A"), "1", "A is 1 in the master"); |
|
64 is(sessionStorage.getItem("B"), "2", "B is 2 in the master"); |
|
65 is(sessionStorage.length, 2, "Num of items is 2"); |
|
66 break; |
|
67 |
|
68 case 3: |
|
69 is(sessionStorage.getItem("A"), "1", "A is 1 in the master"); |
|
70 is(sessionStorage.getItem("B"), "2", "B is 2 in the master"); |
|
71 is(sessionStorage.getItem("C"), null, "C is null in the master"); |
|
72 is(sessionStorage.length, 2, "Num of items is 2"); |
|
73 |
|
74 sessionStorage.setItem("C", "4"); |
|
75 is(sessionStorage.getItem("C"), "4", "C is 4 in the master"); |
|
76 is(sessionStorage.length, 3, "Num of items is 3"); |
|
77 break; |
|
78 } |
|
79 |
|
80 ++currentStep; |
|
81 ++currentStep; |
|
82 |
|
83 return true; |
|
84 } |
|
85 |
|
86 SimpleTest.waitForExplicitFinish(); |
|
87 |
|
88 </script> |
|
89 |
|
90 </head> |
|
91 |
|
92 <body onload="doNextTest();"> |
|
93 </body> |
|
94 </html> |