Title: [134343] trunk/LayoutTests
Revision
134343
Author
[email protected]
Date
2012-11-12 19:38:47 -0800 (Mon, 12 Nov 2012)

Log Message

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):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (134342 => 134343)


--- trunk/LayoutTests/ChangeLog	2012-11-13 03:09:31 UTC (rev 134342)
+++ trunk/LayoutTests/ChangeLog	2012-11-13 03:38:47 UTC (rev 134343)
@@ -1,3 +1,20 @@
+2012-11-12  Joshua Bell  <[email protected]>
+
+        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  <[email protected]>
 
         Unreviewed, gardening.

Modified: trunk/LayoutTests/storage/indexeddb/cursor-prev-no-duplicate-expected.txt (134342 => 134343)


--- trunk/LayoutTests/storage/indexeddb/cursor-prev-no-duplicate-expected.txt	2012-11-13 03:09:31 UTC (rev 134342)
+++ trunk/LayoutTests/storage/indexeddb/cursor-prev-no-duplicate-expected.txt	2012-11-13 03:38:47 UTC (rev 134343)
@@ -20,103 +20,90 @@
 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

Modified: trunk/LayoutTests/storage/indexeddb/resources/cursor-prev-no-duplicate.js (134342 => 134343)


--- trunk/LayoutTests/storage/indexeddb/resources/cursor-prev-no-duplicate.js	2012-11-13 03:09:31 UTC (rev 134342)
+++ trunk/LayoutTests/storage/indexeddb/resources/cursor-prev-no-duplicate.js	2012-11-13 03:38:47 UTC (rev 134343)
@@ -34,76 +34,77 @@
 
 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 @@
 
     // 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 @@
     // 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 @@
     // 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 @@
 {
     // 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 @@
             direction + ")";
 }
 
-function runTest(openCursor, exp)
+function runTest(openCursor, expectation, callback)
 {
     trans = db.transaction('store', 'readonly');
 
@@ -175,19 +177,14 @@
     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 @@
         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;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to