mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 14:20:14 +02:00
Automatic update from web-platform-tests[SessionStorageS13N] Fix key decoding/encoding and site isolation. Allows namespaces to be bound multiple times for site isolation work, fixes key encoding & decoding in the renderer, and fixes some tests. Change-Id: Iac667af7f6edcb4774f9ef49cfc8fd0801060b31 Reviewed-on: https://chromium-review.googlesource.com/1065207 Reviewed-by: John Abd-El-Malek <jam@chromium.org> Reviewed-by: Marijn Kruisselbrink <mek@chromium.org> Commit-Queue: Daniel Murphy <dmurph@chromium.org> Cr-Commit-Position: refs/heads/master@{#560391} -- wpt-commits: cf00fe1051b58f10f542fe396cc1872d31e37b60 wpt-pr: 11096
64 lines
1.9 KiB
JavaScript
64 lines
1.9 KiB
JavaScript
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) {
|
|
if (iframe.contentWindow.sessionStorage === e.storageArea)
|
|
e.storageAreaString = "sessionStorage";
|
|
else if (iframe.contentWindow.localStorage === e.storageArea)
|
|
e.storageAreaString = "localStorage";
|
|
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");
|
|
}
|
|
});
|
|
}
|