Keep newly created IDBIndex objects in deleted map when IDBTransaction is aborted
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jan 2021 18:48:37 +0000 (18:48 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jan 2021 18:48:37 +0000 (18:48 +0000)
commit3af4373c82d85ce272fa0f7657523a904dac427c
tree9229b95823c04a681b0e6de748acd8c5fe046f46
parent8fc4d56e5ee6bed8c466ea70cc9af265c0436d33
Keep newly created IDBIndex objects in deleted map when IDBTransaction is aborted
https://bugs.webkit.org/show_bug.cgi?id=220489
<rdar://problem/70498831>

Patch by Sihui Liu <sihui_liu@appe.com> on 2021-01-11
Reviewed by Youenn Fablet.

Source/WebCore:

When an upgrade transaction is aborted, we move objects from m_deletedIndexes to m_referencedIndexes to revert
the index deletion operation. When updating m_referencedIndexes, we did not check whether key already exists.
Therefore, some indexes in m_referencedIndexes would be replaced and destroyed (since m_referencedIndexes holds
unique pointers) when the index is still referenced by JS.

Tests: storage/indexeddb/modern/abort-index-info-private.html
       storage/indexeddb/modern/abort-index-info.html

* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::rollbackForVersionChangeAbort):

LayoutTests:

* storage/indexeddb/modern/abort-index-info-expected.txt: Added.
* storage/indexeddb/modern/abort-index-info-private-expected.txt: Added.
* storage/indexeddb/modern/abort-index-info-private.html: Added.
* storage/indexeddb/modern/abort-index-info.html: Added.
* storage/indexeddb/modern/resources/abort-index-info.js: Added.
(prepareDatabase):
(versionChangeSuccessCallback.secondRequest.onerror):
(versionChangeSuccessCallback):
(secondUpgradeNeeded):
(checkState):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271368 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/modern/abort-index-info-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/abort-index-info-private-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/abort-index-info-private.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/abort-index-info.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/modern/resources/abort-index-info.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp