Commit 724950a7 authored by jsbell@chromium.org's avatar jsbell@chromium.org

IndexedDB: storage/indexeddb/cursor-prev-no-duplicate.html is flaky

https://bugs.webkit.org/show_bug.cgi?id=101990

Reviewed by Tony Chang.

Race condition in test leads to flaky behavior. Refactor test to remove flake
and clean up output.

* storage/indexeddb/cursor-prev-no-duplicate-expected.txt:
* storage/indexeddb/resources/cursor-prev-no-duplicate.js:
(testFarRangeCursor_closed):
(.trans.oncomplete):
(.storeReq.onsuccess):
(runTest):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@134343 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f9ad3f4f
2012-11-12 Joshua Bell <jsbell@chromium.org>
IndexedDB: storage/indexeddb/cursor-prev-no-duplicate.html is flaky
https://bugs.webkit.org/show_bug.cgi?id=101990
Reviewed by Tony Chang.
Race condition in test leads to flaky behavior. Refactor test to remove flake
and clean up output.
* storage/indexeddb/cursor-prev-no-duplicate-expected.txt:
* storage/indexeddb/resources/cursor-prev-no-duplicate.js:
(testFarRangeCursor_closed):
(.trans.oncomplete):
(.storeReq.onsuccess):
(runTest):
2012-11-12 Hayato Ito <hayato@chromium.org>
Unreviewed, gardening.
......@@ -20,103 +20,90 @@ store.put({sorted: 1, value: 333}, 3)
store.put({sorted: 10, value: 444}, 17)
store.put({sorted: 10, value: 555}, 16)
store.put({sorted: 10, value: 666}, 15)
testFarRangeCursor: upper bound is well out of range, results always the same, whether open or closed
storeReq = store.openCursor(IDBKeyRange.upperBound(7, false), 'prev')
Testing: store.openCursor(IDBKeyRange.upperBound(7, false), 'prev')
PASS cursor.key is 3
PASS cursor.value.value is 333
storeReq = store.openCursor(IDBKeyRange.upperBound(7, true), 'prev')
DONE
Testing: store.openCursor(IDBKeyRange.upperBound(7, true), 'prev')
storeReq = store.openCursor(IDBKeyRange.upperBound(7, true), 'prev')
PASS cursor.key is 3
PASS cursor.value.value is 333
storeReq = index.openCursor(IDBKeyRange.upperBound(7, false), 'prev')
DONE
Testing: index.openCursor(IDBKeyRange.upperBound(7, false), 'prev')
storeReq = index.openCursor(IDBKeyRange.upperBound(7, false), 'prev')
PASS cursor.key is 3
PASS cursor.value.value is 111
PASS cursor.primaryKey is 1
storeReq = index.openCursor(IDBKeyRange.upperBound(7, true), 'prev')
DONE
Testing: index.openCursor(IDBKeyRange.upperBound(7, true), 'prev')
storeReq = index.openCursor(IDBKeyRange.upperBound(7, true), 'prev')
PASS cursor.key is 3
PASS cursor.value.value is 111
PASS cursor.primaryKey is 1
storeReq = index.openKeyCursor(IDBKeyRange.upperBound(7, false), 'prev')
DONE
Testing: index.openKeyCursor(IDBKeyRange.upperBound(7, false), 'prev')
storeReq = index.openKeyCursor(IDBKeyRange.upperBound(7, false), 'prev')
PASS cursor.key is 3
PASS cursor.primaryKey is 1
storeReq = index.openKeyCursor(IDBKeyRange.upperBound(7, true), 'prev')
DONE
Testing: index.openKeyCursor(IDBKeyRange.upperBound(7, true), 'prev')
storeReq = index.openKeyCursor(IDBKeyRange.upperBound(7, true), 'prev')
PASS cursor.key is 3
PASS cursor.primaryKey is 1
storeReq = store.openCursor(IDBKeyRange.upperBound(3, false), 'prev')
DONE
Testing: store.openCursor(IDBKeyRange.upperBound(3, false), 'prev')
storeReq = store.openCursor(IDBKeyRange.upperBound(3, false), 'prev')
PASS cursor.key is 3
PASS cursor.value.value is 333
storeReq = store.openCursor(IDBKeyRange.upperBound(3, true), 'prev')
DONE
Testing: store.openCursor(IDBKeyRange.upperBound(3, true), 'prev')
storeReq = store.openCursor(IDBKeyRange.upperBound(3, true), 'prev')
PASS cursor.key is 2
PASS cursor.value.value is 222
storeReq = index.openCursor(IDBKeyRange.upperBound(3, false), 'prev')
DONE
Testing: index.openCursor(IDBKeyRange.upperBound(3, false), 'prev')
storeReq = index.openCursor(IDBKeyRange.upperBound(3, false), 'prev')
PASS cursor.key is 3
PASS cursor.value.value is 111
PASS cursor.primaryKey is 1
storeReq = index.openCursor(IDBKeyRange.upperBound(3, true), 'prev')
DONE
Testing: index.openCursor(IDBKeyRange.upperBound(3, true), 'prev')
storeReq = index.openCursor(IDBKeyRange.upperBound(3, true), 'prev')
PASS cursor.key is 2
PASS cursor.value.value is 222
PASS cursor.primaryKey is 2
storeReq = index.openKeyCursor(IDBKeyRange.upperBound(3, false), 'prev')
DONE
Testing: index.openKeyCursor(IDBKeyRange.upperBound(3, false), 'prev')
storeReq = index.openKeyCursor(IDBKeyRange.upperBound(3, false), 'prev')
PASS cursor.key is 3
PASS cursor.primaryKey is 1
storeReq = index.openKeyCursor(IDBKeyRange.upperBound(3, true), 'prev')
DONE
Testing: index.openKeyCursor(IDBKeyRange.upperBound(3, true), 'prev')
storeReq = index.openKeyCursor(IDBKeyRange.upperBound(3, true), 'prev')
PASS cursor.key is 2
PASS cursor.primaryKey is 2
testNoDuplicate: there are 3 values, but we should return always the first one
storeReq = store.openCursor(IDBKeyRange.upperBound(15, false), 'prevunique')
DONE
Testing: store.openCursor(IDBKeyRange.upperBound(15, false), 'prevunique')
testNoDuplicate: there are 3 values, but we should return always the first one
storeReq = store.openCursor(IDBKeyRange.upperBound(15, false), 'prevunique')
PASS cursor.key is 15
PASS cursor.value.value is 666
PASS cursor.primaryKey is 15
storeReq = index.openCursor(IDBKeyRange.upperBound(15, false), 'prevunique')
DONE
Testing: index.openCursor(IDBKeyRange.upperBound(15, false), 'prevunique')
storeReq = index.openCursor(IDBKeyRange.upperBound(15, false), 'prevunique')
PASS cursor.key is 10
PASS cursor.value.value is 666
PASS cursor.primaryKey is 15
storeReq = index.openKeyCursor(IDBKeyRange.upperBound(15, false), 'prevunique')
DONE
Testing: index.openKeyCursor(IDBKeyRange.upperBound(15, false), 'prevunique')
storeReq = index.openKeyCursor(IDBKeyRange.upperBound(15, false), 'prevunique')
PASS cursor.key is 10
PASS cursor.primaryKey is 15
DONE
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -34,76 +34,77 @@ function populateStore()
function testFarRangeCursor_closed()
{
debug("");
debug("testFarRangeCursor: upper bound is well out of range, results always the same, whether open or closed");
runTest(makeOpenCursor("store", 7, false, "'prev'"),
{ expectedValue: 333, expectedKey: 3}).onsuccess =
testFarRangeCursor_open;
{ expectedValue: 333, expectedKey: 3},
testFarRangeCursor_open);
}
function testFarRangeCursor_open()
{
runTest(makeOpenCursor("store", 7, true, "'prev'"),
{ expectedValue: 333, expectedKey: 3}).onsuccess =
testFarRangeCursor_indexClosed;
{ expectedValue: 333, expectedKey: 3},
testFarRangeCursor_indexClosed);
}
function testFarRangeCursor_indexClosed()
{
// here '7' refers to the 'sorted' value
runTest(makeOpenCursor("index", 7, false, "'prev'"),
{ expectedValue: 111, expectedKey: 3, expectedPrimaryKey: 1}).onsuccess =
testFarRangeCursor_indexOpen;
// here '7' refers to the 'sorted' value
runTest(makeOpenCursor("index", 7, false, "'prev'"),
{ expectedValue: 111, expectedKey: 3, expectedPrimaryKey: 1},
testFarRangeCursor_indexOpen);
}
function testFarRangeCursor_indexOpen()
{
runTest(makeOpenCursor("index", 7, true, "'prev'"),
{ expectedValue: 111, expectedKey: 3, expectedPrimaryKey: 1}).onsuccess =
testFarRangeCursor_indexKeyOpen;
{ expectedValue: 111, expectedKey: 3, expectedPrimaryKey: 1},
testFarRangeCursor_indexKeyOpen);
}
function testFarRangeCursor_indexKeyOpen()
{
// here '7' refers to the sorted value
runTest(makeOpenKeyCursor("index", 7, false, "'prev'"),
{ expectedKey: 3, expectedPrimaryKey: 1}).onsuccess =
testFarRangeCursor_indexKeyClosed;
{ expectedKey: 3, expectedPrimaryKey: 1},
testFarRangeCursor_indexKeyClosed);
}
function testFarRangeCursor_indexKeyClosed()
{
runTest(makeOpenKeyCursor("index", 7, true, "'prev'"),
{ expectedKey: 3, expectedPrimaryKey: 1}).onsuccess =
testBoundaryCursor_closed;
{ expectedKey: 3, expectedPrimaryKey: 1},
testBoundaryCursor_closed);
}
function testBoundaryCursor_closed()
{
runTest(makeOpenCursor("store", 3, false, "'prev'"),
{ expectedValue: 333, expectedKey: 3}).onsuccess =
testBoundaryCursor_open;
{ expectedValue: 333, expectedKey: 3},
testBoundaryCursor_open);
};
function testBoundaryCursor_open()
{
runTest(makeOpenCursor("store", 3, true, "'prev'"),
{ expectedValue: 222, expectedKey: 2}).onsuccess =
testBoundaryCursor_indexClosed;
{ expectedValue: 222, expectedKey: 2},
testBoundaryCursor_indexClosed);
}
function testBoundaryCursor_indexClosed()
{
// by index sort order, we should return them in a different order
runTest(makeOpenCursor("index", 3, false, "'prev'"),
{ expectedValue: 111, expectedKey: 3, expectedPrimaryKey: 1}).onsuccess =
testBoundaryCursor_indexOpen;
{ expectedValue: 111, expectedKey: 3, expectedPrimaryKey: 1},
testBoundaryCursor_indexOpen);
}
function testBoundaryCursor_indexOpen()
{
runTest(makeOpenCursor("index", 3, true, "'prev'"),
{ expectedValue: 222, expectedKey: 2, expectedPrimaryKey: 2}).onsuccess =
testBoundaryCursor_indexKeyClosed;
{ expectedValue: 222, expectedKey: 2, expectedPrimaryKey: 2},
testBoundaryCursor_indexKeyClosed);
}
function testBoundaryCursor_indexKeyClosed()
......@@ -111,15 +112,15 @@ function testBoundaryCursor_indexKeyClosed()
// now the value doesn't matter, just the primary key
runTest(makeOpenKeyCursor("index", 3, false, "'prev'"),
{ expectedKey: 3, expectedPrimaryKey: 1}).onsuccess =
testBoundaryCursor_indexKeyOpen;
{ expectedKey: 3, expectedPrimaryKey: 1},
testBoundaryCursor_indexKeyOpen);
}
function testBoundaryCursor_indexKeyOpen()
{
runTest(makeOpenKeyCursor("index", 3, true, "'prev'"),
{ expectedKey: 2, expectedPrimaryKey: 2}).onsuccess =
testNoDuplicate_closed;
{ expectedKey: 2, expectedPrimaryKey: 2},
testNoDuplicate_closed);
}
function testNoDuplicate_closed()
......@@ -130,8 +131,8 @@ function testNoDuplicate_closed()
// cursors, but we should make sure we get the right one
// anyway
runTest(makeOpenCursor("store", 15, false, "'prevunique'"),
{ expectedValue: 666, expectedKey: 15, expectedPrimaryKey: 15 })
.onsuccess = testNoDuplicate_open;
{ expectedValue: 666, expectedKey: 15, expectedPrimaryKey: 15 },
testNoDuplicate_open);
}
function testNoDuplicate_open()
......@@ -139,7 +140,8 @@ function testNoDuplicate_open()
// still three values, but now the index says we should return the
// second one
runTest(makeOpenCursor("index", 15, false, "'prevunique'"),
{ expectedValue: 666, expectedKey: 10, expectedPrimaryKey: 15}).onsuccess = testNoDuplicate_indexKeyClosed;
{ expectedValue: 666, expectedKey: 10, expectedPrimaryKey: 15},
testNoDuplicate_indexKeyClosed);
}
......@@ -147,8 +149,8 @@ function testNoDuplicate_indexKeyClosed()
{
// same behavior as above, without a value
runTest(makeOpenKeyCursor("index", 15, false, "'prevunique'"),
{ expectedKey: 10, expectedPrimaryKey: 15}).onsuccess =
finishJSTest;
{ expectedKey: 10, expectedPrimaryKey: 15},
finishJSTest);
}
......@@ -166,7 +168,7 @@ function makeOpenKeyCursor(obj, upperBound, open, direction)
direction + ")";
}
function runTest(openCursor, exp)
function runTest(openCursor, expectation, callback)
{
trans = db.transaction('store', 'readonly');
......@@ -175,19 +177,14 @@ function runTest(openCursor, exp)
index = store.index('index');
trans.onerror = unexpectedErrorCallback;
trans.onabort = unexpectedAbortCallback;
trans.oncomplete = function()
{
trans.oncomplete = function() {
debug("DONE");
debug("");
callback();
};
var result = {};
var testFunction = function()
{
// expose for evalAndLog
expectation = exp;
debug("\nTesting: " + openCursor);
storeReq = evalAndLog("storeReq = " + openCursor);
storeReq.onsuccess = function() {
cursor = event.target.result;
if (cursor === null) {
testFailed("null cursor");
......@@ -197,19 +194,11 @@ function runTest(openCursor, exp)
shouldBe("cursor.key", JSON.stringify(expectation.expectedKey));
if ("value" in cursor) {
shouldBe("cursor.value.value", JSON.stringify(expectation.expectedValue));
}
else if ("expectedValue" in expectation)
} else if ("expectedValue" in expectation)
testFailed("Test broken: shouldn't have expectedValue");
if ("expectedPrimaryKey" in expectation) {
shouldBe("cursor.primaryKey", JSON.stringify(expectation.expectedPrimaryKey));
}
result.onsuccess();
};
storeReq = evalAndLog("storeReq = " + openCursor);
storeReq.onsuccess = testFunction;
return result;
}
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