Skip to content
  • jsbell@chromium.org's avatar
    IndexedDB: Correct database version after aborted upgrade · ef0ca77a
    jsbell@chromium.org authored
    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: http://svn.webkit.org/repository/webkit/trunk@136475 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    ef0ca77a