blob: f42a749ff84d3da94f8fb2d879b335b56711c970 [file] [log] [blame]
var jsTestIsAsync = true;
iframe = document.createElement("IFRAME");
iframe.src = 'about:blank';
document.body.appendChild(iframe);
storageEventList = new Array();
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) {
testFailed("got at least " + currentCount + ", expected only " + expectedNumEvents + " events");
callback();
} else if (times > 50) {
testFailed("Timeout: only got " + currentCount + ", expected " + expectedNumEvents + " events");
callback();
} else {
countStorageEvents(callback, expectedNumEvents, times+1);
}
}
setTimeout(onTimeout, 20);
}
function testStorages(testCallback)
{
// When we're done testing with SessionStorage, this is run.
function runLocalStorage()
{
debug("");
debug("");
testCallback("localStorage", finishJSTest);
}
// First run the test with SessionStorage.
testCallback("sessionStorage", runLocalStorage);
}