IndexedDB: Correct database version after aborted upgrade
authorjsbell@chromium.org <jsbell@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Dec 2012 07:17:04 +0000 (07:17 +0000)
committerjsbell@chromium.org <jsbell@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Dec 2012 07:17:04 +0000 (07:17 +0000)
commit1d999e59d12bd10e8f2ee87066b5f01fb2f9edf0
tree5f46d3b1ec2d5856df5429d2a3e8c355b2c3af2d
parent1d1a1eb463214cfc19a9d1d84b5033bd1ec784d0
IndexedDB: Correct database version after aborted upgrade
https://bugs.webkit.org/show_bug.cgi?id=103763

Reviewed by Tony Chang.

Source/WebCore:

After an aborted "versionchange" transaction, the IDBDatabase would fetch a fresh snapshot
of the metadata from the back end. If the back end had already started a new "versionchange"
transaction the snapshot would be bogus. Instead, save a copy of the IDBDatabase's metadata
and roll back to that, as is done for IDBObjectStore.

Tests: storage/indexeddb/intversion-abort-in-initial-upgradeneeded.html
       storage/indexeddb/mozilla/versionchange-abort.html
       storage/indexeddb/unblocked-version-changes.html

* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::IDBDatabase):
(WebCore::IDBDatabase::transactionCreated):
* Modules/indexeddb/IDBDatabase.h:
(WebCore::IDBDatabase::setMetadata): Let IDBOpenDBRequest and IDBTransaction tinker.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::onUpgradeNeeded): Fetch new and compute old metadata.
(WebCore::IDBOpenDBRequest::onSuccess): Fetch new metadata, in case upgrade changed it.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::create): Stash the old metadata, in case of rollback.
(WebCore::IDBTransaction::IDBTransaction):
(WebCore::IDBTransaction::onAbort): Revert the database as well as the stores.
* Modules/indexeddb/IDBTransaction.h:
(IDBTransaction):

Source/WebKit/chromium:

Pass previously created proxy along in an open onSuccess, rather than a useless wrapper.

* src/WebIDBCallbacksImpl.cpp:
(WebKit::WebIDBCallbacksImpl::WebIDBCallbacksImpl):
(WebKit::WebIDBCallbacksImpl::onSuccess):
(WebKit::WebIDBCallbacksImpl::onUpgradeNeeded):
* src/WebIDBCallbacksImpl.h:
(WebCore):
(WebIDBCallbacksImpl):

LayoutTests:

Update test expectations and tweak a test so it's testing what it claimed.

* storage/indexeddb/intversion-abort-in-initial-upgradeneeded-expected.txt:
* storage/indexeddb/mozilla/resources/versionchange-abort.js:
(postAbort):
* storage/indexeddb/mozilla/versionchange-abort-expected.txt:
* storage/indexeddb/resources/unblocked-version-changes.js:
(onUpgradeNeeded):
* storage/indexeddb/unblocked-version-changes-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@136475 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/intversion-abort-in-initial-upgradeneeded-expected.txt
LayoutTests/storage/indexeddb/mozilla/resources/versionchange-abort.js
LayoutTests/storage/indexeddb/mozilla/versionchange-abort-expected.txt
LayoutTests/storage/indexeddb/resources/unblocked-version-changes.js
LayoutTests/storage/indexeddb/unblocked-version-changes-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBDatabase.cpp
Source/WebCore/Modules/indexeddb/IDBDatabase.h
Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/IDBTransaction.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebIDBCallbacksImpl.cpp
Source/WebKit/chromium/src/WebIDBCallbacksImpl.h