2011-05-12 David Grogan <dgrogan@chromium.org>

        Reviewed by Darin Adler.

        make layout tests in storage/domstorage/events more deterministic
        https://bugs.webkit.org/show_bug.cgi?id=60299

        Instead of counting the number of storage events fired between two
        setTimeout(0) events, specify the number of events to wait for and wait up to
        1 second for them.

        * storage/domstorage/events/resources/eventTestHarness.js:
        (runAfterNStorageEvents):
        (countStorageEvents.onTimeout):
        (countStorageEvents):
        (testStorages.allDone):
        * storage/domstorage/events/script-tests/basic-body-attribute.js:
        (step1):
        (step2):
        (step3):
        (step4):
        (step5):
        * storage/domstorage/events/script-tests/basic-setattribute.js:
        (step1):
        (step2):
        (step3):
        (step4):
        (step5):
        * storage/domstorage/events/script-tests/basic.js:
        (test):
        (step1):
        (step2):
        (step3):
        (step4):
        (step5):
        * storage/domstorage/events/script-tests/case-sensitive.js:
        (test):
        (step1):
        (step2):
        * storage/domstorage/events/script-tests/documentURI.js:
        (test):
        (step1):
        (step2):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@86408 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ff72a0db
2011-05-12 David Grogan <dgrogan@chromium.org>
Reviewed by Darin Adler.
make layout tests in storage/domstorage/events more deterministic
https://bugs.webkit.org/show_bug.cgi?id=60299
Instead of counting the number of storage events fired between two
setTimeout(0) events, specify the number of events to wait for and wait up to
1 second for them.
* storage/domstorage/events/resources/eventTestHarness.js:
(runAfterNStorageEvents):
(countStorageEvents.onTimeout):
(countStorageEvents):
(testStorages.allDone):
* storage/domstorage/events/script-tests/basic-body-attribute.js:
(step1):
(step2):
(step3):
(step4):
(step5):
* storage/domstorage/events/script-tests/basic-setattribute.js:
(step1):
(step2):
(step3):
(step4):
(step5):
* storage/domstorage/events/script-tests/basic.js:
(test):
(step1):
(step2):
(step3):
(step4):
(step5):
* storage/domstorage/events/script-tests/case-sensitive.js:
(test):
(step1):
(step2):
* storage/domstorage/events/script-tests/documentURI.js:
(test):
(step1):
(step2):
2011-05-12 Andrew Wilson <atwilson@chromium.org>
Unreviewed expectations tweaks for chromium.
......@@ -13,15 +13,28 @@ iframe.contentWindow.onstorage = function (e) {
window.parent.storageEventList.push(e);
}
function runAfterStorageEvents(callback) {
var currentCount = storageEventList.length;
function onTimeout() {
if (currentCount != storageEventList.length)
runAfterStorageEvents(callback);
else
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, 0);
setTimeout(onTimeout, 20);
}
function testStorages(testCallback)
......@@ -34,6 +47,8 @@ function testStorages(testCallback)
window.successfullyParsed = true;
isSuccessfullyParsed();
debug("");
localStorage.clear();
sessionStorage.clear();
if (window.layoutTestController)
layoutTestController.notifyDone()
}
......
......@@ -24,7 +24,7 @@ function step1()
evalAndLog("storageEventList = new Array()");
evalAndLog("storage.setItem('FOO', 'BAR')");
runAfterStorageEvents(step2);
runAfterNStorageEvents(step2, 1);
}
function step2()
......@@ -38,7 +38,7 @@ function step2()
evalAndLog("storage.setItem('b', '2')");
evalAndLog("storage.setItem('b', '3')");
runAfterStorageEvents(step3);
runAfterNStorageEvents(step3, 5);
}
function step3()
......@@ -58,7 +58,7 @@ function step3()
shouldBeEqualToString("storageEventList[4].newValue", "3");
evalAndLog("storage.removeItem('FOO')");
runAfterStorageEvents(step4);
runAfterNStorageEvents(step4, 6);
}
function step4()
......@@ -69,7 +69,7 @@ function step4()
shouldBeNull("storageEventList[5].newValue");
evalAndLog("storage.removeItem('FU')");
runAfterStorageEvents(step5);
runAfterNStorageEvents(step5, 7);
}
function step5()
......@@ -80,7 +80,7 @@ function step5()
shouldBeNull("storageEventList[6].newValue");
evalAndLog("storage.clear()");
runAfterStorageEvents(step6);
runAfterNStorageEvents(step6, 8);
}
function step6()
......
......@@ -24,7 +24,7 @@ function step1()
evalAndLog("storageEventList = new Array()");
evalAndLog("storage.setItem('FOO', 'BAR')");
runAfterStorageEvents(step2);
runAfterNStorageEvents(step2, 1);
}
function step2()
......@@ -38,7 +38,7 @@ function step2()
evalAndLog("storage.setItem('b', '2')");
evalAndLog("storage.setItem('b', '3')");
runAfterStorageEvents(step3);
runAfterNStorageEvents(step3, 5);
}
function step3()
......@@ -58,7 +58,7 @@ function step3()
shouldBeEqualToString("storageEventList[4].newValue", "3");
evalAndLog("storage.removeItem('FOO')");
runAfterStorageEvents(step4);
runAfterNStorageEvents(step4, 6);
}
function step4()
......@@ -69,7 +69,7 @@ function step4()
shouldBeNull("storageEventList[5].newValue");
evalAndLog("storage.removeItem('FU')");
runAfterStorageEvents(step5);
runAfterNStorageEvents(step5, 7);
}
function step5()
......@@ -80,7 +80,7 @@ function step5()
shouldBeNull("storageEventList[6].newValue");
evalAndLog("storage.clear()");
runAfterStorageEvents(step6);
runAfterNStorageEvents(step6, 8);
}
function step6()
......
......@@ -11,10 +11,11 @@ function test(storageString, callback)
debug("Testing " + storageString);
storageEventList = new Array();
evalAndLog("storage.clear()");
shouldBe("storage.length", "0");
runAfterStorageEvents(step1);
runAfterNStorageEvents(step1, 0);
}
function step1()
......@@ -23,7 +24,7 @@ function step1()
evalAndLog("storageEventList = new Array()");
evalAndLog("storage.setItem('FOO', 'BAR')");
runAfterStorageEvents(step2);
runAfterNStorageEvents(step2, 1);
}
function step2()
......@@ -37,7 +38,7 @@ function step2()
evalAndLog("storage.setItem('b', '2')");
evalAndLog("storage.setItem('b', '3')");
runAfterStorageEvents(step3);
runAfterNStorageEvents(step3, 5);
}
function step3()
......@@ -57,7 +58,7 @@ function step3()
shouldBeEqualToString("storageEventList[4].newValue", "3");
evalAndLog("storage.removeItem('FOO')");
runAfterStorageEvents(step4);
runAfterNStorageEvents(step4, 6);
}
function step4()
......@@ -68,7 +69,7 @@ function step4()
shouldBeNull("storageEventList[5].newValue");
evalAndLog("storage.removeItem('FU')");
runAfterStorageEvents(step5);
runAfterNStorageEvents(step5, 7);
}
function step5()
......@@ -79,7 +80,7 @@ function step5()
shouldBeNull("storageEventList[6].newValue");
evalAndLog("storage.clear()");
runAfterStorageEvents(step6);
runAfterNStorageEvents(step6, 8);
}
function step6()
......
......@@ -11,6 +11,7 @@ function test(storageString, callback)
debug("Testing " + storageString);
storageEventList = new Array();
evalAndLog("storage.clear()");
shouldBe("storage.length", "0");
......@@ -18,7 +19,7 @@ function test(storageString, callback)
debug("Verify storage events are case sensitive");
evalAndLog("storage.foo = 'test'");
runAfterStorageEvents(step1);
runAfterNStorageEvents(step1, 1);
}
function step1()
......@@ -27,7 +28,7 @@ function step1()
evalAndLog("storageEventList = new Array()");
evalAndLog("storage.foo = 'test'");
runAfterStorageEvents(step2);
runAfterNStorageEvents(step2, 0);
}
function step2()
......@@ -35,7 +36,7 @@ function step2()
shouldBe("storageEventList.length", "0");
evalAndLog("storage.foo = 'TEST'");
runAfterStorageEvents(step3);
runAfterNStorageEvents(step3, 1);
}
function step3()
......
......@@ -11,10 +11,11 @@ function test(storageString, callback)
debug("Testing " + storageString);
storageEventList = new Array();
evalAndLog("storage.clear()");
shouldBe("storage.length", "0");
runAfterStorageEvents(step1);
runAfterNStorageEvents(step1, 0);
}
function step1()
......@@ -23,7 +24,7 @@ function step1()
evalAndLog("storageEventList = new Array()");
evalAndLog("storage.foo = '123'");
runAfterStorageEvents(step2);
runAfterNStorageEvents(step2, 1);
}
function step2()
......@@ -36,7 +37,7 @@ function step2()
shouldBeEqualToString("document.documentURI", "abc");
evalAndLog("storage.foo = 'xyz'");
runAfterStorageEvents(step3);
runAfterNStorageEvents(step3, 2);
}
function step3()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment