IndexedDB deleteIndex should throw NOT_ALLOWED_ERR if called outside a VERSION_CHANGE...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2011 21:18:30 +0000 (21:18 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2011 21:18:30 +0000 (21:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=62370

Already behaves correctly, just adding tests.

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

* storage/indexeddb/deleteIndex-expected.txt: Added.
* storage/indexeddb/deleteIndex.html: Added.

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

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

index 1b49696..f0039c6 100755 (executable)
@@ -1,3 +1,15 @@
+2011-12-07  Joshua Bell  <jsbell@chromium.org>
+
+        IndexedDB deleteIndex should throw NOT_ALLOWED_ERR if called outside a VERSION_CHANGE transaction callback
+        https://bugs.webkit.org/show_bug.cgi?id=62370
+
+        Already behaves correctly, just adding tests.
+
+        Reviewed by Tony Chang.
+
+        * storage/indexeddb/deleteIndex-expected.txt: Added.
+        * storage/indexeddb/deleteIndex.html: Added.
+
 2011-12-07  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r102244.
diff --git a/LayoutTests/storage/indexeddb/deleteIndex-expected.txt b/LayoutTests/storage/indexeddb/deleteIndex-expected.txt
new file mode 100644 (file)
index 0000000..c3d1e55
--- /dev/null
@@ -0,0 +1,36 @@
+Test IndexedDB deleteIndex method
+
+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
+IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException;
+PASS IDBDatabaseException == null is false
+indexedDB.open('deleteIndex')
+db = event.target.result
+request = db.setVersion('1')
+transaction = event.target.result;
+Deleted all object stores.
+objectStore = db.createObjectStore('foo');
+Expecting exception from objectStore.deleteIndex('first')
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.NOT_FOUND_ERR
+PASS objectStore.deleteIndex() threw exception TypeError: Not enough arguments.
+index = objectStore.createIndex('first', 'first');
+Expecting exception from objectStore.deleteIndex('FIRST')
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.NOT_FOUND_ERR
+index = objectStore.createIndex('second', 'second');
+returnValue = objectStore.deleteIndex('first');
+PASS returnValue is undefined
+Expecting exception from db.createObjectStore('bar');
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.NOT_ALLOWED_ERR
+Expecting exception from objectStore.deleteIndex('second')
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.NOT_ALLOWED_ERR
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/indexeddb/deleteIndex.html b/LayoutTests/storage/indexeddb/deleteIndex.html
new file mode 100644 (file)
index 0000000..c67e8e1
--- /dev/null
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+<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 deleteIndex method");
+if (window.layoutTestController)
+    layoutTestController.waitUntilDone();
+
+function test()
+{
+    indexedDB = evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;");
+    shouldBeFalse("indexedDB == null");
+    IDBDatabaseException = evalAndLog("IDBDatabaseException = window.IDBDatabaseException || window.webkitIDBDatabaseException;");
+    shouldBeFalse("IDBDatabaseException == null");
+
+    request = evalAndLog("indexedDB.open('deleteIndex')");
+    request.onsuccess = openSuccess;
+    request.onerror = unexpectedErrorCallback;
+}
+
+function openSuccess()
+{
+    db = evalAndLog("db = event.target.result");
+
+    request = evalAndLog("request = db.setVersion('1')");
+    request.onsuccess = twiddleIndexes;
+    request.onerror = unexpectedErrorCallback;
+}
+
+function twiddleIndexes()
+{
+    transaction = evalAndLog("transaction = event.target.result;");
+    transaction.onerror = unexpectedErrorCallback;
+    transaction.onabort = unexpectedAbortCallback;
+    transaction.oncomplete = postTwiddling;
+    deleteAllObjectStores(db);
+
+    objectStore = evalAndLog("objectStore = db.createObjectStore('foo');");
+    evalAndExpectException("objectStore.deleteIndex('first')", "IDBDatabaseException.NOT_FOUND_ERR");
+    shouldThrow("objectStore.deleteIndex()"); // TypeError: not enough arguments.
+    index = evalAndLog("index = objectStore.createIndex('first', 'first');");
+    evalAndExpectException("objectStore.deleteIndex('FIRST')", "IDBDatabaseException.NOT_FOUND_ERR");
+    index = evalAndLog("index = objectStore.createIndex('second', 'second');");
+    returnValue = evalAndLog("returnValue = objectStore.deleteIndex('first');");
+    shouldBe("returnValue", "undefined");
+}
+
+function postTwiddling()
+{
+    evalAndExpectException("db.createObjectStore('bar');", "IDBDatabaseException.NOT_ALLOWED_ERR");
+    evalAndExpectException("objectStore.deleteIndex('second')", "IDBDatabaseException.NOT_ALLOWED_ERR");
+    done();
+}
+
+test();
+
+</script>
+</body>
+</html>