| OLD | NEW |
| 1 description("This is a test to make sure DOM Storage mutations fire StorageEvent
s that are caught by the event listener set via window.onstorage."); | 1 description("This is a test to make sure DOM Storage mutations fire StorageEvent
s that are caught by the event listener set via window.onstorage."); |
| 2 | 2 |
| 3 function test(storageString, callback) | 3 function test(storageString, callback) |
| 4 { | 4 { |
| 5 window.completionCallback = callback; | 5 window.completionCallback = callback; |
| 6 window.storage = eval(storageString); | 6 window.storage = eval(storageString); |
| 7 if (!storage) { | 7 if (!storage) { |
| 8 testFailed(storageString + " DOES NOT exist"); | 8 testFailed(storageString + " DOES NOT exist"); |
| 9 return; | 9 return; |
| 10 } | 10 } |
| 11 | 11 |
| 12 debug("Testing " + storageString); | 12 debug("Testing " + storageString); |
| 13 | 13 |
| 14 storageEventList = new Array(); | 14 storageEventList = new Array(); |
| 15 evalAndLog("storage.clear()"); | 15 evalAndLog("storage.clear()"); |
| 16 shouldBe("storage.length", "0"); | 16 shouldBe("storage.length", "0"); |
| 17 | 17 |
| 18 runAfterNStorageEvents(step1, 0); | 18 iframe.onload = onload; |
| 19 iframe.src = "about:blank"; |
| 20 } |
| 21 |
| 22 function onload() |
| 23 { |
| 24 iframe.contentWindow.onstorage = function (e) { |
| 25 window.parent.storageEventList.push(e); |
| 26 }; |
| 27 |
| 28 step1(); |
| 19 } | 29 } |
| 20 | 30 |
| 21 function step1() | 31 function step1() |
| 22 { | 32 { |
| 23 debug("Reset storage event list"); | 33 debug("Reset storage event list"); |
| 24 evalAndLog("storageEventList = new Array()"); | 34 evalAndLog("storageEventList = new Array()"); |
| 25 evalAndLog("storage.setItem('FOO', 'BAR')"); | 35 evalAndLog("storage.setItem('FOO', 'BAR')"); |
| 26 | 36 |
| 27 runAfterNStorageEvents(step2, 1); | 37 runAfterNStorageEvents(step2, 1); |
| 28 } | 38 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 runAfterNStorageEvents(step5, 7); | 82 runAfterNStorageEvents(step5, 7); |
| 73 } | 83 } |
| 74 | 84 |
| 75 function step5() | 85 function step5() |
| 76 { | 86 { |
| 77 shouldBe("storageEventList.length", "7"); | 87 shouldBe("storageEventList.length", "7"); |
| 78 shouldBeEqualToString("storageEventList[6].key", "FU"); | 88 shouldBeEqualToString("storageEventList[6].key", "FU"); |
| 79 shouldBeEqualToString("storageEventList[6].oldValue", "BAR"); | 89 shouldBeEqualToString("storageEventList[6].oldValue", "BAR"); |
| 80 shouldBeNull("storageEventList[6].newValue"); | 90 shouldBeNull("storageEventList[6].newValue"); |
| 81 evalAndLog("storage.clear()"); | 91 evalAndLog("storage.clear()"); |
| 82 | 92 |
| 83 runAfterNStorageEvents(step6, 8); | 93 runAfterNStorageEvents(step6, 8); |
| 84 } | 94 } |
| 85 | 95 |
| 86 function step6() | 96 function step6() |
| 87 { | 97 { |
| 88 shouldBe("storageEventList.length", "8"); | 98 shouldBe("storageEventList.length", "8"); |
| 89 shouldBeNull("storageEventList[7].key"); | 99 shouldBeNull("storageEventList[7].key"); |
| 90 shouldBeNull("storageEventList[7].oldValue"); | 100 shouldBeNull("storageEventList[7].oldValue"); |
| 91 shouldBeNull("storageEventList[7].newValue"); | 101 shouldBeNull("storageEventList[7].newValue"); |
| 92 | 102 |
| 93 completionCallback(); | 103 completionCallback(); |
| 94 } | 104 } |
| 95 | 105 |
| 96 testStorages(test); | 106 testStorages(test); |
| 97 | 107 |
| 98 var successfullyParsed = true; | 108 var successfullyParsed = true; |
| OLD | NEW |