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