IndexedDB 2.0: Support new IDBTransaction interfaces.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2016 16:25:27 +0000 (16:25 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2016 16:25:27 +0000 (16:25 +0000)
<rdar://problem/28806928> and https://bugs.webkit.org/show_bug.cgi?id=163927

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

* web-platform-tests/IndexedDB/idbobjectstore-rename-abort-expected.txt:
* web-platform-tests/IndexedDB/idbobjectstore-rename-store-expected.txt:
* web-platform-tests/IndexedDB/idbtransaction_objectStoreNames-expected.txt:
* web-platform-tests/IndexedDB/transaction-abort-multiple-metadata-revert-expected.txt:
* web-platform-tests/IndexedDB/transaction-abort-object-store-metadata-revert-expected.txt:

Source/WebCore:

Tests: storage/indexeddb/modern/idbtransaction-objectstores-1-private.html
       storage/indexeddb/modern/idbtransaction-objectstores-1.html
       At least partially passing results on 5 previously failed W3C tests.

The "new IDBTransaction interfaces" really just means adding the property IDBTransaction.objectStoreNames.

* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::objectStoreNames):
* Modules/indexeddb/IDBTransaction.h:
* Modules/indexeddb/IDBTransaction.idl:

LayoutTests:

* storage/indexeddb/modern/idbtransaction-objectstores-1-expected.txt: Added.
* storage/indexeddb/modern/idbtransaction-objectstores-1-private-expected.txt: Added.
* storage/indexeddb/modern/idbtransaction-objectstores-1-private.html: Added.
* storage/indexeddb/modern/idbtransaction-objectstores-1.html: Added.
* storage/indexeddb/modern/resources/idbtransaction-objectstores-1.js: Added.

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

16 files changed:
LayoutTests/ChangeLog
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-rename-abort-expected.txt
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbobjectstore-rename-store-expected.txt
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbtransaction_objectStoreNames-expected.txt
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/transaction-abort-multiple-metadata-revert-expected.txt
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/transaction-abort-object-store-metadata-revert-expected.txt
LayoutTests/storage/indexeddb/modern/idbtransaction-objectstores-1-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/idbtransaction-objectstores-1-private-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/idbtransaction-objectstores-1-private.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/idbtransaction-objectstores-1.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/resources/idbtransaction-objectstores-1.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.h
Source/WebCore/Modules/indexeddb/IDBTransaction.idl

index 9272e9a..da81f61 100644 (file)
@@ -1,3 +1,16 @@
+2016-10-25  Brady Eidson  <beidson@apple.com>
+
+        IndexedDB 2.0: Support new IDBTransaction interfaces.
+        <rdar://problem/28806928> and https://bugs.webkit.org/show_bug.cgi?id=163927
+
+        Reviewed by Sam Weinig.
+
+        * storage/indexeddb/modern/idbtransaction-objectstores-1-expected.txt: Added.
+        * storage/indexeddb/modern/idbtransaction-objectstores-1-private-expected.txt: Added.
+        * storage/indexeddb/modern/idbtransaction-objectstores-1-private.html: Added.
+        * storage/indexeddb/modern/idbtransaction-objectstores-1.html: Added.
+        * storage/indexeddb/modern/resources/idbtransaction-objectstores-1.js: Added.
+
 2016-10-25  Alex Christensen  <achristensen@webkit.org>
 
         Rebase test after r207805
index 47b25e8..916315d 100644 (file)
@@ -1,3 +1,16 @@
+2016-10-25  Brady Eidson  <beidson@apple.com>
+
+        IndexedDB 2.0: Support new IDBTransaction interfaces.
+        <rdar://problem/28806928> and https://bugs.webkit.org/show_bug.cgi?id=163927
+
+        Reviewed by Sam Weinig.
+
+        * web-platform-tests/IndexedDB/idbobjectstore-rename-abort-expected.txt:
+        * web-platform-tests/IndexedDB/idbobjectstore-rename-store-expected.txt:
+        * web-platform-tests/IndexedDB/idbtransaction_objectStoreNames-expected.txt:
+        * web-platform-tests/IndexedDB/transaction-abort-multiple-metadata-revert-expected.txt:
+        * web-platform-tests/IndexedDB/transaction-abort-object-store-metadata-revert-expected.txt:
+
 2016-10-24  Jiewen Tan  <jiewen_tan@apple.com>
 
         Update SubtleCrypto::generateKey to match the latest spec
index ea1a201..4795218 100644 (file)
@@ -1,6 +1,4 @@
 
-Harness Error (TIMEOUT), message = null
-
-FAIL IndexedDB object store rename in aborted transaction undefined is not an object (evaluating 'actual.length')
-TIMEOUT IndexedDB object store creation and rename in an aborted transaction Test timed out
+PASS IndexedDB object store rename in aborted transaction 
+FAIL IndexedDB object store creation and rename in an aborted transaction assert_equals: IDBObjectStore.name should reflect the last rename immediately after transaction.abort() returns expected "not_books_renamed_again" but got "not_books"
 
index 8ac90c6..56c98d8 100644 (file)
@@ -1,6 +1,6 @@
 
-FAIL IndexedDB object store rename in new transaction undefined is not an object (evaluating 'actual.length')
-FAIL IndexedDB object store rename in the transaction where it is created undefined is not an object (evaluating 'actual.length')
+PASS IndexedDB object store rename in new transaction 
+PASS IndexedDB object store rename in the transaction where it is created 
 PASS IndexedDB object store rename covers index 
 FAIL IndexedDB object store rename covers key generator assert_equals: Renaming an object store should not change the state of its key generator expected 345680 but got 345679
 PASS IndexedDB object store rename to the same name succeeds 
index 1c2c188..4023c0d 100644 (file)
@@ -1,10 +1,10 @@
 
-FAIL IDBTransaction.objectStoreNames - during upgrade transaction undefined is not an object (evaluating 'actual.length')
-FAIL IDBTransaction.objectStoreNames - value after close undefined is not an object (evaluating 'actual.length')
-FAIL IDBTransaction.objectStoreNames - transaction scope undefined is not an object (evaluating 'actual.length')
-FAIL IDBTransaction.objectStoreNames - value after commit undefined is not an object (evaluating 'actual.length')
-FAIL IDBTransaction.objectStoreNames - value after abort undefined is not an object (evaluating 'actual.length')
-FAIL IDBTransaction.objectStoreNames - sorting undefined is not an object (evaluating 'actual.length')
-FAIL IDBTransaction.objectStoreNames - no duplicates undefined is not an object (evaluating 'actual.length')
-FAIL IDBTransaction.objectStoreNames - unusual names undefined is not an object (evaluating 'actual.length')
+PASS IDBTransaction.objectStoreNames - during upgrade transaction 
+PASS IDBTransaction.objectStoreNames - value after close 
+PASS IDBTransaction.objectStoreNames - transaction scope 
+PASS IDBTransaction.objectStoreNames - value after commit 
+PASS IDBTransaction.objectStoreNames - value after abort 
+PASS IDBTransaction.objectStoreNames - sorting 
+FAIL IDBTransaction.objectStoreNames - no duplicates assert_array_equals: transaction objectStoreNames should not have duplicates lengths differ, expected 2 got 3
+FAIL IDBTransaction.objectStoreNames - unusual names assert_array_equals: transaction should have names sorted with no duplicates lengths differ, expected 14 got 28
 
index 4d253bb..716fa38 100644 (file)
@@ -1,5 +1,5 @@
 
-FAIL Deleted indexes in newly created stores are still marked as deleted after the transaction aborts undefined is not an object (evaluating 'actual.length')
-FAIL Deleted indexes in deleted stores are still marked as not-deleted after the transaction aborts undefined is not an object (evaluating 'actual.length')
-FAIL Deleted indexes in created+deleted stores are still marked as deleted after their transaction aborts undefined is not an object (evaluating 'actual.length')
+FAIL Deleted indexes in newly created stores are still marked as deleted after the transaction aborts assert_throws: IDBObjectStore.get should throw InvalidStateError, indicating that the store is marked for deletion, immediately after IDBTransaction.abort() returns function "() => store.get('query')" threw object "TransactionInactiveError (DOM IDBDatabase Exception): Fai..." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
+FAIL Deleted indexes in deleted stores are still marked as not-deleted after the transaction aborts assert_array_equals: IDBObjectStore.indexNames for the deleted store should be empty immediately after IDBDatabase.deleteObjectStore() returns lengths differ, expected 0 got 1
+FAIL Deleted indexes in created+deleted stores are still marked as deleted after their transaction aborts assert_array_equals: IDBObjectStore.indexNames should be empty immediately after IDBDatabase.deleteObjectStore() returns lengths differ, expected 0 got 1
 
index ce7e4db..c34f919 100644 (file)
@@ -1,6 +1,6 @@
 
-FAIL Created stores get marked as deleted after their transaction aborts undefined is not an object (evaluating 'actual.length')
-FAIL Deleted stores get marked as not-deleted after the transaction aborts undefined is not an object (evaluating 'actual.length')
-FAIL Created+deleted stores are still marked as deleted after their transaction aborts undefined is not an object (evaluating 'actual.length')
-FAIL Un-instantiated deleted stores get marked as not-deleted after the transaction aborts undefined is not an object (evaluating 'actual.length')
+FAIL Created stores get marked as deleted after their transaction aborts assert_throws: IDBObjectStore.get should throw InvalidStateError, indicating that the store is marked for deletion, immediately after IDBTransaction.abort() returns function "() => store.get('query')" threw object "TransactionInactiveError (DOM IDBDatabase Exception): Fai..." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
+PASS Deleted stores get marked as not-deleted after the transaction aborts 
+FAIL Created+deleted stores are still marked as deleted after their transaction aborts assert_throws: IDBObjectStore.get should throw InvalidStateError, indicating that the store is still marked for deletion, immediately after IDBTransaction.abort() returns function "() => store.get('query')" threw object "TransactionInactiveError (DOM IDBDatabase Exception): Fai..." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11
+PASS Un-instantiated deleted stores get marked as not-deleted after the transaction aborts 
 
diff --git a/LayoutTests/storage/indexeddb/modern/idbtransaction-objectstores-1-expected.txt b/LayoutTests/storage/indexeddb/modern/idbtransaction-objectstores-1-expected.txt
new file mode 100644 (file)
index 0000000..af09342
--- /dev/null
@@ -0,0 +1,33 @@
+This tests the IDBTransaction.objectStoreNames API
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
+Upgrade needed: Old version - 0 New version - 1
+List has 1 entries
+Entry 0: ObjectStore1
+List has 2 entries
+Entry 0: ObjectStore1
+Entry 1: ObjectStore2
+List has 1 entries
+Entry 0: ObjectStore2
+List has 3 entries
+Entry 0: ObjectStore2
+Entry 1: ObjectStore3
+Entry 2: ObjectStore4
+Version change transaction complete
+List has 3 entries
+Entry 0: ObjectStore2
+Entry 1: ObjectStore3
+Entry 2: ObjectStore4
+List has 2 entries
+Entry 0: ObjectStore2
+Entry 1: ObjectStore4
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/indexeddb/modern/idbtransaction-objectstores-1-private-expected.txt b/LayoutTests/storage/indexeddb/modern/idbtransaction-objectstores-1-private-expected.txt
new file mode 100644 (file)
index 0000000..af09342
--- /dev/null
@@ -0,0 +1,33 @@
+This tests the IDBTransaction.objectStoreNames API
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
+Upgrade needed: Old version - 0 New version - 1
+List has 1 entries
+Entry 0: ObjectStore1
+List has 2 entries
+Entry 0: ObjectStore1
+Entry 1: ObjectStore2
+List has 1 entries
+Entry 0: ObjectStore2
+List has 3 entries
+Entry 0: ObjectStore2
+Entry 1: ObjectStore3
+Entry 2: ObjectStore4
+Version change transaction complete
+List has 3 entries
+Entry 0: ObjectStore2
+Entry 1: ObjectStore3
+Entry 2: ObjectStore4
+List has 2 entries
+Entry 0: ObjectStore2
+Entry 1: ObjectStore4
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/indexeddb/modern/idbtransaction-objectstores-1-private.html b/LayoutTests/storage/indexeddb/modern/idbtransaction-objectstores-1-private.html
new file mode 100644 (file)
index 0000000..2fa88af
--- /dev/null
@@ -0,0 +1,12 @@
+<html>
+<head>
+<script>
+enablePrivateBrowsing = true;
+</script>
+<script src="../../../resources/js-test.js"></script>
+<script src="../resources/shared.js"></script>
+</head>
+<body>
+<script src="resources/idbtransaction-objectstores-1.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/storage/indexeddb/modern/idbtransaction-objectstores-1.html b/LayoutTests/storage/indexeddb/modern/idbtransaction-objectstores-1.html
new file mode 100644 (file)
index 0000000..f36c730
--- /dev/null
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src="../../../resources/js-test.js"></script>
+<script src="../resources/shared.js"></script>
+</head>
+<body>
+<script src="resources/idbtransaction-objectstores-1.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/storage/indexeddb/modern/resources/idbtransaction-objectstores-1.js b/LayoutTests/storage/indexeddb/modern/resources/idbtransaction-objectstores-1.js
new file mode 100644 (file)
index 0000000..ba4fe33
--- /dev/null
@@ -0,0 +1,63 @@
+description("This tests the IDBTransaction.objectStoreNames API");
+
+indexedDBTest(prepareDatabase);
+
+function done()
+{
+    finishJSTest();
+}
+
+function dumpList(list)
+{
+       debug("List has " + list.length + " entries");
+       
+       for (i = 0; i < list.length; ++i)
+               debug("Entry " + i + ": " + list.item(i));
+}
+
+function prepareDatabase(event)
+{
+    debug("Upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
+    
+    var tx = event.target.transaction;
+    db = event.target.result;
+
+       db.createObjectStore("ObjectStore1");
+       dumpList(tx.objectStoreNames);
+
+       db.createObjectStore("ObjectStore2");
+       dumpList(tx.objectStoreNames);
+
+       db.deleteObjectStore("ObjectStore1");
+       dumpList(tx.objectStoreNames);
+
+       db.createObjectStore("ObjectStore3");
+       db.createObjectStore("ObjectStore4");
+       dumpList(tx.objectStoreNames);
+       
+    tx.onabort = function(event) {
+        debug("Version change transaction unexpected abort");
+        done();
+    }
+
+    tx.oncomplete = function(event) {
+        debug("Version change transaction complete");
+        continueTest();
+    }
+
+    tx.onerror = function(event) {
+        debug("Version change transaction unexpected error");
+        done();
+    }
+}
+
+function continueTest()
+{
+       tx = db.transaction(["ObjectStore2", "ObjectStore3", "ObjectStore4"]);
+       dumpList(tx.objectStoreNames);
+
+       tx = db.transaction(["ObjectStore2", "ObjectStore4"]);
+       dumpList(tx.objectStoreNames);
+       
+       done();
+}
index 1e34083..66b054c 100644 (file)
@@ -1,3 +1,21 @@
+2016-10-25  Brady Eidson  <beidson@apple.com>
+
+        IndexedDB 2.0: Support new IDBTransaction interfaces.
+        <rdar://problem/28806928> and https://bugs.webkit.org/show_bug.cgi?id=163927
+
+        Reviewed by Sam Weinig.
+
+        Tests: storage/indexeddb/modern/idbtransaction-objectstores-1-private.html
+               storage/indexeddb/modern/idbtransaction-objectstores-1.html
+               At least partially passing results on 5 previously failed W3C tests.
+
+        The "new IDBTransaction interfaces" really just means adding the property IDBTransaction.objectStoreNames.
+
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::objectStoreNames):
+        * Modules/indexeddb/IDBTransaction.h:
+        * Modules/indexeddb/IDBTransaction.idl:
+
 2016-10-25  Youenn Fablet  <youenn@apple.com>
 
         MediaEndpointConfiguration does not need to be refcounted
index a4c8662..413a684 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(INDEXED_DATABASE)
 
 #include "DOMError.h"
+#include "DOMStringList.h"
 #include "DOMWindow.h"
 #include "Event.h"
 #include "EventNames.h"
@@ -168,6 +169,20 @@ IDBClient::IDBConnectionProxy& IDBTransaction::connectionProxy()
     return m_database->connectionProxy();
 }
 
+Ref<DOMStringList> IDBTransaction::objectStoreNames() const
+{
+    ASSERT(currentThread() == m_database->originThreadID());
+
+    const Vector<String> names = isVersionChange() ? m_database->info().objectStoreNames() : m_info.objectStores();
+
+    Ref<DOMStringList> objectStoreNames = DOMStringList::create();
+    for (auto& name : names)
+        objectStoreNames->append(name);
+
+    objectStoreNames->sort();
+    return objectStoreNames;
+}
+
 const String& IDBTransaction::mode() const
 {
     ASSERT(currentThread() == m_database->originThreadID());
index ea4ef14..9bcf8ba 100644 (file)
@@ -42,6 +42,7 @@
 namespace WebCore {
 
 class DOMError;
+class DOMStringList;
 class IDBCursor;
 class IDBCursorInfo;
 class IDBDatabase;
@@ -78,6 +79,7 @@ public:
     ~IDBTransaction() final;
 
     // IDBTransaction IDL
+    Ref<DOMStringList> objectStoreNames() const;
     const String& mode() const;
     IDBDatabase* db();
     DOMError* error() const;
index 8ebae82..e48f0ab 100644 (file)
@@ -30,6 +30,7 @@
     EnabledAtRuntime=IndexedDB,
     SkipVTableValidation,
 ] interface IDBTransaction : EventTarget {
+    readonly attribute DOMStringList objectStoreNames;
     readonly attribute DOMString mode;
     readonly attribute IDBDatabase db;
     readonly attribute DOMError error;