diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/webstorage/eventTestHarness.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/webstorage/eventTestHarness.js')
-rw-r--r-- | testing/web-platform/tests/webstorage/eventTestHarness.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webstorage/eventTestHarness.js b/testing/web-platform/tests/webstorage/eventTestHarness.js new file mode 100644 index 000000000..7d9ed0187 --- /dev/null +++ b/testing/web-platform/tests/webstorage/eventTestHarness.js @@ -0,0 +1,60 @@ +iframe = document.createElement("IFRAME"); +iframe.src = "about:blank"; +document.body.appendChild(iframe); +iframe.contentWindow.document.body.textContent = "Nothing to see here."; + +storageEventList = new Array(); +iframe.contentWindow.onstorage = function(e) { + window.parent.storageEventList.push(e); +}; + +function runAfterNStorageEvents(callback, expectedNumEvents) +{ + countStorageEvents(callback, expectedNumEvents, 0) +} + +function countStorageEvents(callback, expectedNumEvents, times) +{ + function onTimeout() + { + var currentCount = storageEventList.length; + if (currentCount == expectedNumEvents) { + callback(); + } else if (currentCount > expectedNumEvents) { + msg = "got at least " + currentCount + ", expected only " + expectedNumEvents + " events"; + callback(msg); + } else if (times > 50) { + msg = "Timeout: only got " + currentCount + ", expected " + expectedNumEvents + " events"; + callback(msg); + } else { + countStorageEvents(callback, expectedNumEvents, times+1); + } + } + setTimeout(onTimeout, 20); +} + +function clearStorage(storageName, callback) +{ + if (window[storageName].length === 0) { + storageEventList = []; + setTimeout(callback, 0); + } else { + window[storageName].clear(); + runAfterNStorageEvents(function() { + storageEventList = []; + callback(); + }, 1); + } +} + +function testStorages(testCallback) +{ + testCallback("sessionStorage"); + var hit = false; + add_result_callback(function() { + if (!hit) { + hit = true; + testCallback("localStorage"); + } + }); +} |