IndexedDB objectStoreNames not updated after aborted transaction
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2011 19:45:58 +0000 (19:45 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2011 19:45:58 +0000 (19:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=58655

Already functional but there wasn't a test with these specifics.

Patch by Joshua Bell <jsbell@chromium.org> on 2011-12-07
Reviewed by Tony Chang.

* storage/indexeddb/mozilla/versionchange-abort-expected.txt: Added.
* storage/indexeddb/mozilla/versionchange-abort.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/mozilla/versionchange-abort-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/mozilla/versionchange-abort.html [new file with mode: 0644]

index 181a996..f1bc274 100644 (file)
@@ -1,3 +1,15 @@
+2011-12-07  Joshua Bell  <jsbell@chromium.org>
+
+        IndexedDB objectStoreNames not updated after aborted transaction
+        https://bugs.webkit.org/show_bug.cgi?id=58655
+
+        Already functional but there wasn't a test with these specifics.
+
+        Reviewed by Tony Chang.
+
+        * storage/indexeddb/mozilla/versionchange-abort-expected.txt: Added.
+        * storage/indexeddb/mozilla/versionchange-abort.html: Added.
+
 2011-12-07  Xiaomei Ji  <xji@chromium.org>
 
         Turn on move caret by word visually for windows platform.
diff --git a/LayoutTests/storage/indexeddb/mozilla/versionchange-abort-expected.txt b/LayoutTests/storage/indexeddb/mozilla/versionchange-abort-expected.txt
new file mode 100644 (file)
index 0000000..e9a5d3a
--- /dev/null
@@ -0,0 +1,23 @@
+Test IndexedDB's aborting setVersion
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;
+PASS indexedDB == null is false
+indexedDB.open(name, description)
+db = event.target.result
+initialVersion = db.version;
+request = db.setVersion('2')
+Deleted all object stores.
+objectStore = db.createObjectStore('foo');
+PASS db.objectStoreNames.length is 1
+index = objectStore.createIndex('bar', 'baz');
+PASS objectStore.indexNames.length is 1
+event.target.transaction.abort();
+PASS db.version is initialVersion
+PASS db.objectStoreNames.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/indexeddb/mozilla/versionchange-abort.html b/LayoutTests/storage/indexeddb/mozilla/versionchange-abort.html
new file mode 100644 (file)
index 0000000..a59eceb
--- /dev/null
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<!--
+  original test: http://mxr.mozilla.org/mozilla2.0/source/dom/indexedDB/test/test_setVersion_abort.html
+  license of original test:
+    " Any copyright is dedicated to the Public Domain.
+      http://creativecommons.org/publicdomain/zero/1.0/ "
+-->
+<html>
+<head>
+<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 IndexedDB's aborting setVersion");
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+function test()
+{
+    indexedDB = evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;");
+    shouldBeFalse("indexedDB == null");
+
+    name = window.location.pathname;
+    description = "My Test Database";
+    request = evalAndLog("indexedDB.open(name, description)");
+    request.onsuccess = openSuccess;
+    request.onerror = unexpectedErrorCallback;
+}
+
+function openSuccess()
+{
+    db = evalAndLog("db = event.target.result");
+    initialVersion = evalAndLog("initialVersion = db.version;");
+    request = evalAndLog("request = db.setVersion('2')");
+    request.onsuccess = cleanDatabase;
+    request.onerror = unexpectedErrorCallback;
+}
+
+function cleanDatabase()
+{
+    deleteAllObjectStores(db);
+
+    objectStore = evalAndLog("objectStore = db.createObjectStore('foo');");
+    shouldBe("db.objectStoreNames.length", "1");
+
+    index = evalAndLog("index = objectStore.createIndex('bar', 'baz');");
+    shouldBe("objectStore.indexNames.length", "1");
+
+    event.target.transaction.oncomplete = unexpectedSuccessCallback;
+    event.target.transaction.onabort = postAbort;
+    evalAndLog("event.target.transaction.abort();");
+}
+
+function postAbort()
+{
+    shouldBe("db.version", "initialVersion");
+    shouldBe("db.objectStoreNames.length", "0");
+
+    done();
+}
+
+test();
+
+</script>
+</body>
+</html>
+