Layout test demonstrating IDBCursor inconsistency bug.
authordgrogan@chromium.org <dgrogan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2011 16:42:48 +0000 (16:42 +0000)
committerdgrogan@chromium.org <dgrogan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Sep 2011 16:42:48 +0000 (16:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69012

Reviewed by Nate Chapin.

* storage/indexeddb/cursor-inconsistency-expected.txt: Added.
* storage/indexeddb/cursor-inconsistency.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96335 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/cursor-inconsistency-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/cursor-inconsistency.html [new file with mode: 0644]

index 2d44ab1..39b85c2 100644 (file)
@@ -1,3 +1,13 @@
+2011-09-29  David Grogan  <dgrogan@chromium.org>
+
+        Layout test demonstrating IDBCursor inconsistency bug.
+        https://bugs.webkit.org/show_bug.cgi?id=69012
+
+        Reviewed by Nate Chapin.
+
+        * storage/indexeddb/cursor-inconsistency-expected.txt: Added.
+        * storage/indexeddb/cursor-inconsistency.html: Added.
+
 2011-09-29  Adam Barth  <abarth@webkit.org>
 
         Generalize expected result to all of MAC.
diff --git a/LayoutTests/storage/indexeddb/cursor-inconsistency-expected.txt b/LayoutTests/storage/indexeddb/cursor-inconsistency-expected.txt
new file mode 100644 (file)
index 0000000..48675dd
--- /dev/null
@@ -0,0 +1,62 @@
+Test consistency of IndexedDB's cursor objects.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+webkitIndexedDB.open('cursor-inconsistency')
+db = event.target.result
+db.setVersion('new version')
+setVersionSuccess():
+trans = event.target.result
+PASS trans !== null is true
+Deleted all object stores.
+objectStore = db.createObjectStore('basicStore')
+objectStore.add('someValue1', 'someKey1').onerror = unexpectedErrorCallback
+objectStore.add('someValue2', 'someKey2').onerror = unexpectedErrorCallback
+objectStore.add('someValue3', 'someKey3').onerror = unexpectedErrorCallback
+objectStore.add('someValue4', 'someKey4').onerror = unexpectedErrorCallback
+openBasicCursor()
+trans = db.transaction([], webkitIDBTransaction.READ_WRITE)
+trans.objectStore('basicStore')
+objectStore.openCursor(keyRange)
+
+checkCursor()
+storedCursor = event.target.result
+PASS storedCursor === event.target.result is true
+PASS storedCursor.key is "someKey1"
+PASS event.target.result.key is "someKey1"
+PASS storedCursor.value is "someValue1"
+PASS event.target.result.value is "someValue1"
+event.target.result.continue()
+
+checkCursor()
+FAIL storedCursor === event.target.result should be true. Was false.
+PASS storedCursor.key is "someKey2"
+PASS event.target.result.key is "someKey2"
+FAIL storedCursor.value should be someValue2. Was someValue1.
+PASS event.target.result.value is "someValue2"
+event.target.result.continue()
+
+checkCursor()
+FAIL storedCursor === event.target.result should be true. Was false.
+PASS storedCursor.key is "someKey3"
+PASS event.target.result.key is "someKey3"
+FAIL storedCursor.value should be someValue3. Was someValue1.
+PASS event.target.result.value is "someValue3"
+event.target.result.continue()
+
+checkCursor()
+FAIL storedCursor === event.target.result should be true. Was false.
+PASS storedCursor.key is "someKey4"
+PASS event.target.result.key is "someKey4"
+FAIL storedCursor.value should be someValue4. Was someValue1.
+PASS event.target.result.value is "someValue4"
+event.target.result.continue()
+
+checkCursor()
+PASS counter is 5
+transactionComplete()
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/indexeddb/cursor-inconsistency.html b/LayoutTests/storage/indexeddb/cursor-inconsistency.html
new file mode 100644 (file)
index 0000000..b9ccb58
--- /dev/null
@@ -0,0 +1,99 @@
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+<script src="resources/shared.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Test consistency of IndexedDB's cursor objects.");
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+test();
+
+function test()
+{
+    request = evalAndLog("webkitIndexedDB.open('cursor-inconsistency')");
+    request.onsuccess = openSuccess;
+    request.onerror = unexpectedErrorCallback;
+}
+
+function openSuccess()
+{
+    var db = evalAndLog("db = event.target.result");
+
+    request = evalAndLog("db.setVersion('new version')");
+    request.onsuccess = setVersionSuccess;
+    request.onerror = unexpectedErrorCallback;
+}
+
+function setVersionSuccess()
+{
+    debug("setVersionSuccess():");
+    window.trans = evalAndLog("trans = event.target.result");
+    shouldBeTrue("trans !== null");
+    trans.onabort = unexpectedAbortCallback;
+    trans.oncomplete = openBasicCursor;
+
+    deleteAllObjectStores(db);
+
+    var objectStore = evalAndLog("objectStore = db.createObjectStore('basicStore')");
+    evalAndLog("objectStore.add('someValue1', 'someKey1').onerror = unexpectedErrorCallback");
+    evalAndLog("objectStore.add('someValue2', 'someKey2').onerror = unexpectedErrorCallback");
+    evalAndLog("objectStore.add('someValue3', 'someKey3').onerror = unexpectedErrorCallback");
+    evalAndLog("objectStore.add('someValue4', 'someKey4').onerror = unexpectedErrorCallback");
+
+}
+
+function openBasicCursor()
+{
+    debug("openBasicCursor()");
+    evalAndLog("trans = db.transaction([], webkitIDBTransaction.READ_WRITE)");
+    trans.onabort = unexpectedAbortCallback;
+    trans.oncomplete = transactionComplete;
+
+    keyRange = webkitIDBKeyRange.lowerBound("someKey1");
+    window.objectStore = evalAndLog("trans.objectStore('basicStore')");
+    request = evalAndLog("objectStore.openCursor(keyRange)");
+    request.onsuccess = checkCursor;
+    request.onerror = unexpectedErrorCallback;
+    counter = 1;
+}
+
+storedCursor = null;
+function checkCursor()
+{
+    debug("")
+    debug("checkCursor()");
+    if (event.target.result == null) {
+        shouldBe("counter", "5");
+        return;
+    }
+    if (storedCursor == null)
+      storedCursor = evalAndLog("storedCursor = event.target.result");
+
+    shouldBeTrue("storedCursor === event.target.result");
+    shouldBeEqualToString("storedCursor.key", "someKey" + counter);
+    shouldBeEqualToString("event.target.result.key", "someKey" + counter);
+    shouldBeEqualToString("storedCursor.value", "someValue" + counter);
+    shouldBeEqualToString("event.target.result.value", "someValue" + counter);
+    counter++;
+    evalAndLog("event.target.result.continue()");
+}
+
+function transactionComplete()
+{
+    debug("transactionComplete()");
+    done();
+}
+
+var successfullyParsed = true;
+
+</script>
+</body>
+</html>