Title: [193878] trunk
Revision
193878
Author
beid...@apple.com
Date
2015-12-09 16:53:11 -0800 (Wed, 09 Dec 2015)

Log Message

Modern IDB: storage/indexeddb/metadata.html fails
https://bugs.webkit.org/show_bug.cgi?id=152099

Reviewed by Alex Christensen.

Source/WebCore:

Test: storage/indexeddb/modern/abort-objectstore-info.html
      And at least one existing failure now passes.

We did not properly reset object store info when version change transactions aborted.

* Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
(WebCore::IDBClient::IDBObjectStore::IDBObjectStore):
(WebCore::IDBClient::IDBObjectStore::rollbackInfoForVersionChangeAbort):
* Modules/indexeddb/client/IDBObjectStoreImpl.h:

* Modules/indexeddb/client/IDBTransactionImpl.cpp:
(WebCore::IDBClient::IDBTransaction::abort):

LayoutTests:

* platform/mac-wk1/TestExpectations:
* storage/indexeddb/modern/abort-objectstore-info-expected.txt: Added.
* storage/indexeddb/modern/abort-objectstore-info.html: Added.
* storage/indexeddb/modern/resources/abort-objectstore-info.js: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (193877 => 193878)


--- trunk/LayoutTests/ChangeLog	2015-12-09 23:57:59 UTC (rev 193877)
+++ trunk/LayoutTests/ChangeLog	2015-12-10 00:53:11 UTC (rev 193878)
@@ -1,5 +1,17 @@
 2015-12-09  Brady Eidson  <beid...@apple.com>
 
+        Modern IDB: storage/indexeddb/metadata.html fails
+        https://bugs.webkit.org/show_bug.cgi?id=152099
+
+        Reviewed by Alex Christensen.
+
+        * platform/mac-wk1/TestExpectations:
+        * storage/indexeddb/modern/abort-objectstore-info-expected.txt: Added.
+        * storage/indexeddb/modern/abort-objectstore-info.html: Added.
+        * storage/indexeddb/modern/resources/abort-objectstore-info.js: Added.
+
+2015-12-09  Brady Eidson  <beid...@apple.com>
+
         Modern IDB: storage/indexeddb/intversion-close-between-events.html fails.
         https://bugs.webkit.org/show_bug.cgi?id=152096
 

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (193877 => 193878)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-12-09 23:57:59 UTC (rev 193877)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-12-10 00:53:11 UTC (rev 193878)
@@ -110,7 +110,6 @@
 storage/indexeddb/intversion-upgrades.html [ Failure ]
 storage/indexeddb/key-type-array.html [ Failure ]
 storage/indexeddb/lazy-index-types.html [ Failure ]
-storage/indexeddb/metadata.html [ Failure ]
 storage/indexeddb/objectstore-autoincrement.html [ Failure ]
 storage/indexeddb/objectstore-basics.html [ Failure ]
 storage/indexeddb/objectstore-count.html [ Failure ]

Added: trunk/LayoutTests/storage/indexeddb/modern/abort-objectstore-info-expected.txt (0 => 193878)


--- trunk/LayoutTests/storage/indexeddb/modern/abort-objectstore-info-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/abort-objectstore-info-expected.txt	2015-12-10 00:53:11 UTC (rev 193878)
@@ -0,0 +1,62 @@
+Explores the edge cases of what IDBObjectStore objects look like after a version change transaction that changed them aborts.
+
+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;
+
+dbname = "abort-objectstore-info.html"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
+connection1 = event.target.result;
+objectStore1_1 = connection1.createObjectStore('objectStore1');
+objectStore1_2 = connection1.createObjectStore('objectStore2');
+objectStore1_2.createIndex('index', 'foo');
+
+PASS connection1.version is 1
+PASS connection1.objectStoreNames.length is 2
+PASS objectStore1_1.indexNames.length is 0
+PASS objectStore1_2.indexNames.length is 1
+
+connection1.close();
+secondRequest = indexedDB.open(dbname, 2);
+secondRequest._onupgradeneeded_ = secondUpgradeNeeded;
+connection2 = event.target.result;
+objectStore2_1 = secondRequest.transaction.objectStore('objectStore1');
+objectStore2_2 = secondRequest.transaction.objectStore('objectStore2');
+objectStore2_3 = connection2.createObjectStore('objectStore3');
+
+PASS connection2.version is 2
+PASS connection2.objectStoreNames.length is 3
+PASS objectStore2_1.indexNames.length is 0
+PASS objectStore2_2.indexNames.length is 1
+PASS objectStore2_3.indexNames.length is 0
+
+objectStore2_1.createIndex('index', 'foo');
+objectStore2_2.deleteIndex('index');
+objectStore2_3.createIndex('index', 'foo');
+
+PASS connection2.version is 2
+PASS connection2.objectStoreNames.length is 3
+PASS objectStore2_1.indexNames.length is 1
+PASS objectStore2_2.indexNames.length is 0
+PASS objectStore2_3.indexNames.length is 1
+
+secondRequest.transaction.abort();
+connection2.close()
+
+checkState():
+PASS connection1.version is 1
+PASS connection1.objectStoreNames.length is 2
+PASS objectStore1_1.indexNames.length is 0
+PASS objectStore1_2.indexNames.length is 1
+
+PASS connection2.version is 1
+PASS connection2.objectStoreNames.length is 2
+PASS objectStore2_1.indexNames.length is 0
+PASS objectStore2_2.indexNames.length is 1
+PASS objectStore2_3.indexNames.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/storage/indexeddb/modern/abort-objectstore-info.html (0 => 193878)


--- trunk/LayoutTests/storage/indexeddb/modern/abort-objectstore-info.html	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/abort-objectstore-info.html	2015-12-10 00:53:11 UTC (rev 193878)
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/storage/indexeddb/modern/resources/abort-objectstore-info.js (0 => 193878)


--- trunk/LayoutTests/storage/indexeddb/modern/resources/abort-objectstore-info.js	                        (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/resources/abort-objectstore-info.js	2015-12-10 00:53:11 UTC (rev 193878)
@@ -0,0 +1,80 @@
+description("Explores the edge cases of what IDBObjectStore objects look like after a version change transaction that changed them aborts.");
+
+indexedDBTest(prepareDatabase, versionChangeSuccessCallback);
+
+function prepareDatabase()
+{
+    evalAndLog("connection1 = event.target.result;");
+    evalAndLog("objectStore1_1 = connection1.createObjectStore('objectStore1');");
+    evalAndLog("objectStore1_2 = connection1.createObjectStore('objectStore2');");
+    evalAndLog("objectStore1_2.createIndex('index', 'foo');");
+
+    debug("");
+    shouldBe("connection1.version", "1");
+    shouldBe("connection1.objectStoreNames.length", "2");
+    shouldBe("objectStore1_1.indexNames.length", "0");
+    shouldBe("objectStore1_2.indexNames.length", "1");
+    debug("");
+}
+
+function versionChangeSuccessCallback()
+{
+    evalAndLog("connection1.close();");
+    evalAndLog("secondRequest = indexedDB.open(dbname, 2);");
+    evalAndLog("secondRequest._onupgradeneeded_ = secondUpgradeNeeded;");
+    secondRequest._onsuccess_ = unexpectedSuccessCallback;
+    secondRequest._onerror_ = function() {
+        evalAndLog("connection2.close()");
+        checkState();
+    };
+}
+
+function secondUpgradeNeeded()
+{
+    evalAndLog("connection2 = event.target.result;");
+    evalAndLog("objectStore2_1 = secondRequest.transaction.objectStore('objectStore1');");
+    evalAndLog("objectStore2_2 = secondRequest.transaction.objectStore('objectStore2');");
+    evalAndLog("objectStore2_3 = connection2.createObjectStore('objectStore3');");
+
+    debug("");
+    shouldBe("connection2.version", "2");
+    shouldBe("connection2.objectStoreNames.length", "3");
+    shouldBe("objectStore2_1.indexNames.length", "0");
+    shouldBe("objectStore2_2.indexNames.length", "1");
+    shouldBe("objectStore2_3.indexNames.length", "0");
+    
+    debug("");
+    evalAndLog("objectStore2_1.createIndex('index', 'foo');");
+    evalAndLog("objectStore2_2.deleteIndex('index');");
+    evalAndLog("objectStore2_3.createIndex('index', 'foo');");
+    debug("");
+
+    shouldBe("connection2.version", "2");
+    shouldBe("connection2.objectStoreNames.length", "3");
+    shouldBe("objectStore2_1.indexNames.length", "1");
+    shouldBe("objectStore2_2.indexNames.length", "0");
+    shouldBe("objectStore2_3.indexNames.length", "1");
+
+    debug("");
+    evalAndLog("secondRequest.transaction.abort();");
+}
+
+function checkState()
+{
+    debug("");
+    debug("checkState():");
+
+    shouldBe("connection1.version", "1");
+    shouldBe("connection1.objectStoreNames.length", "2");
+    shouldBe("objectStore1_1.indexNames.length", "0");
+    shouldBe("objectStore1_2.indexNames.length", "1");
+    debug("");
+
+    shouldBe("connection2.version", "1");
+    shouldBe("connection2.objectStoreNames.length", "2");
+    shouldBe("objectStore2_1.indexNames.length", "0");
+    shouldBe("objectStore2_2.indexNames.length", "1");
+    shouldBe("objectStore2_3.indexNames.length", "0");
+
+    finishJSTest();
+}

Modified: trunk/Source/WebCore/ChangeLog (193877 => 193878)


--- trunk/Source/WebCore/ChangeLog	2015-12-09 23:57:59 UTC (rev 193877)
+++ trunk/Source/WebCore/ChangeLog	2015-12-10 00:53:11 UTC (rev 193878)
@@ -1,3 +1,23 @@
+2015-12-09  Brady Eidson  <beid...@apple.com>
+
+        Modern IDB: storage/indexeddb/metadata.html fails
+        https://bugs.webkit.org/show_bug.cgi?id=152099
+
+        Reviewed by Alex Christensen.
+
+        Test: storage/indexeddb/modern/abort-objectstore-info.html
+              And at least one existing failure now passes.
+
+        We did not properly reset object store info when version change transactions aborted.
+
+        * Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
+        (WebCore::IDBClient::IDBObjectStore::IDBObjectStore):
+        (WebCore::IDBClient::IDBObjectStore::rollbackInfoForVersionChangeAbort):
+        * Modules/indexeddb/client/IDBObjectStoreImpl.h:
+        
+        * Modules/indexeddb/client/IDBTransactionImpl.cpp:
+        (WebCore::IDBClient::IDBTransaction::abort):
+
 2015-12-09  Simon Fraser  <simon.fra...@apple.com>
 
         Adjust layer backing store format

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp (193877 => 193878)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp	2015-12-09 23:57:59 UTC (rev 193877)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp	2015-12-10 00:53:11 UTC (rev 193878)
@@ -52,6 +52,7 @@
 
 IDBObjectStore::IDBObjectStore(const IDBObjectStoreInfo& info, IDBTransaction& transaction)
     : m_info(info)
+    , m_originalInfo(info)
     , m_transaction(transaction)
 {
 }
@@ -596,6 +597,11 @@
     m_deleted = true;
 }
 
+void IDBObjectStore::rollbackInfoForVersionChangeAbort()
+{
+    m_info = m_originalInfo;
+}
+
 } // namespace IDBClient
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h (193877 => 193878)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h	2015-12-09 23:57:59 UTC (rev 193877)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.h	2015-12-10 00:53:11 UTC (rev 193878)
@@ -92,6 +92,8 @@
     // this will no longer be necessary.
     IDBTransaction& modernTransaction() { return m_transaction.get(); }
 
+    void rollbackInfoForVersionChangeAbort();
+
 private:
     IDBObjectStore(const IDBObjectStoreInfo&, IDBTransaction&);
 
@@ -104,6 +106,7 @@
     RefPtr<WebCore::IDBRequest> doCount(ScriptExecutionContext&, const IDBKeyRangeData&, ExceptionCodeWithMessage&);
 
     IDBObjectStoreInfo m_info;
+    IDBObjectStoreInfo m_originalInfo;
     Ref<IDBTransaction> m_transaction;
 
     bool m_deleted { false };

Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp (193877 => 193878)


--- trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp	2015-12-09 23:57:59 UTC (rev 193877)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp	2015-12-10 00:53:11 UTC (rev 193878)
@@ -188,6 +188,9 @@
     m_database->willAbortTransaction(*this);
 
     if (isVersionChange()) {
+        for (auto& objectStore : m_referencedObjectStores.values())
+            objectStore->rollbackInfoForVersionChangeAbort();
+
         ASSERT(m_openDBRequest);
         m_openDBRequest->versionChangeTransactionWillFinish();
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to