Skip to content
  • dgrogan@chromium.org's avatar
    IndexedDB: fire upgradeneeded even without an explicit integer version · 5f450791
    dgrogan@chromium.org authored
    https://bugs.webkit.org/show_bug.cgi?id=96444
    
    Reviewed by Tony Chang.
    
    Source/WebCore:
    
    Also of note:
    - New databases now get a default version of 1 instead of
    the empty string when they are opened.
    - We now allow databases with an integer version to revert to a string
    version by calling setVersion.
    
    Implementation detail: we store both an integer version and string
    version for a particular database. If both are set we give preference
    to the integer version and assume the db is on the integer track.
    
    Test: storage/indexeddb/intversion-two-opens-no-versions.html
    
    * Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
    (WebCore):
    (WebCore::IDBDatabaseBackendImpl::IDBDatabaseBackendImpl):
    (WebCore::IDBDatabaseBackendImpl::setVersion):
    (WebCore::IDBDatabaseBackendImpl::setVersionInternal):
    Now that this can be called even after an int version is set we have
    to make it revoke the int version.
    
    (WebCore::IDBDatabaseBackendImpl::openConnection):
    Nested ifs were getting deep, so refactor to return early instead.
    
    (WebCore::IDBDatabaseBackendImpl::deleteDatabase):
    (WebCore::IDBDatabaseBackendImpl::resetVersion):
    Now that an int version could have been set before setVersion was
    called we have to reset the int version on abort.
    
    * Modules/indexeddb/IDBDatabaseBackendImpl.h:
    (IDBDatabaseBackendImpl):
    * Modules/indexeddb/IDBLevelDBBackingStore.cpp:
    (WebCore::IDBLevelDBBackingStore::updateIDBDatabaseIntVersion):
    * Modules/indexeddb/IDBOpenDBRequest.cpp:
    0 is now a valid integer version to store to leveldb if an idb
    database is reverting to a string version.
    
    (WebCore::IDBOpenDBRequest::onUpgradeNeeded):
    If the open request did not specify an integer version but
    upgradeneeded is called, it means the database was given the default
    version of 1.
    
    LayoutTests:
    
    Mostly updating expectations about getting an upgradeneeded on a new
    database and the default version being 1 instead of "".
    
    * http/tests/inspector/indexeddb/database-structure-expected.txt:
    * storage/indexeddb/cursor-overloads-expected.txt:
    * storage/indexeddb/cursor-overloads.html:
    * storage/indexeddb/dont-commit-on-blocked-expected.txt:
    * storage/indexeddb/dont-commit-on-blocked.html:
    * storage/indexeddb/factory-deletedatabase-interactions-expected.txt:
    * storage/indexeddb/intversion-and-setversion-expected.txt:
    Remove test that setVersion fires an error if an int version is set.
    Change it to testing that an int version can replace a string version
    that replaced an int version.
    
    * storage/indexeddb/intversion-bad-parameters-expected.txt:
    * storage/indexeddb/intversion-invalid-setversion-has-no-side-effects-expected.txt: Removed.
    setVersion is no longer invalid so this test can be deleted.
    
    * storage/indexeddb/intversion-omit-parameter-expected.txt:
    We now fully pass this test.
    
    * storage/indexeddb/intversion-two-opens-no-versions-expected.txt: Added.
    * storage/indexeddb/intversion-two-opens-no-versions.html: Renamed from LayoutTests/storage/indexeddb/intversion-invalid-setversion-has-no-side-effects.html.
    * storage/indexeddb/list-ordering-expected.txt:
    * storage/indexeddb/noblobs-expected.txt:
    * storage/indexeddb/noblobs.html:
    * storage/indexeddb/open-during-transaction-expected.txt:
    This test had a bug in it AND its behavior is changed. It was trying
    to open one database twice and another once but was actually opening
    three different databases. The behavior change is that now the
    transaction finishes while the last call to open is firing
    upgradeneeded.
    
    * storage/indexeddb/pending-activity-expected.txt:
    * storage/indexeddb/pending-activity-workers-expected.txt:
    * storage/indexeddb/resources/intversion-and-setversion.js:
    (deleteSuccess):
    (initialUpgradeNeeded):
    (openSuccess):
    (firstUpgradeNeeded):
    (transactionCompleted):
    (firstOpenWithVersion):
    (secondSetVersionCallback):
    (setIntVersion2):
    (versionChangeGoingFromStringToInt):
    (version2ConnectionBlocked):
    (version2ConnectionSuccess):
    (errorWhenTryingLowVersion):
    * storage/indexeddb/resources/intversion-invalid-setversion-has-no-side-effects.js: Removed.
    * storage/indexeddb/resources/intversion-two-opens-no-versions.js: Added.
    (test):
    (deleteSuccess):
    (connection1UpgradeNeeded):
    (connection1OpenSuccess):
    (connection2UpgradeNeeded):
    (connection2OpenSuccess):
    * storage/indexeddb/resources/list-ordering.js:
    * storage/indexeddb/resources/open-during-transaction.js:
    (startTransaction.trans.oncomplete):
    (startTransaction):
    (tryOpens.openreq3.onsuccess):
    (tryOpens):
    * storage/indexeddb/resources/pending-activity.js:
    * storage/indexeddb/structured-clone-expected.txt:
    * storage/indexeddb/structured-clone.html:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129037 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    5f450791