IndexedDB: iteration of cursors skip records if updated or deleted
authorsihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Oct 2018 17:11:39 +0000 (17:11 +0000)
committersihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Oct 2018 17:11:39 +0000 (17:11 +0000)
commitc34bc692362cfd70c4c146947ec1816eb4cc57f2
tree5578dcb3ae8ca84736b4a053daac23c4f80cf9c3
parent0e7d407061391be000a13bf1a5d67442e2792de9
IndexedDB: iteration of cursors skip records if updated or deleted
https://bugs.webkit.org/show_bug.cgi?id=190917
<rdar://problem/35250410>

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

Rebaseline the expectation for test that passes.

* web-platform-tests/IndexedDB/idbcursor-iterating-update-expected.txt:

Source/WebCore:

When object store has changes, we cleared cached records and reset the SQLite statement,
updating the boundary to the next key in cursor's direction. Therefore, the cursor could
jump to the next key after update or deletion.
We should cache those records before changing the statement.

Test: storage/indexeddb/cursor-update-while-iterating.html

* Modules/indexeddb/server/SQLiteIDBCursor.cpp:
(WebCore::IDBServer::SQLiteIDBCursor::objectStoreRecordsChanged):
(WebCore::IDBServer::SQLiteIDBCursor::fetch):
* Modules/indexeddb/server/SQLiteIDBCursor.h:

LayoutTests:

* storage/indexeddb/cursor-update-while-iterating-expected.txt: Added.
* storage/indexeddb/cursor-update-while-iterating.html: Added.
* storage/indexeddb/resources/cursor-update-while-iterating.js: Added.
(prepareDatabase):
(onOpenSuccess.request.onsuccess):
(onOpenSuccess):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237590 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idbcursor-iterating-update-expected.txt
LayoutTests/storage/indexeddb/cursor-update-while-iterating-expected.txt [new file with mode: 0644]
LayoutTests/storage/indexeddb/cursor-update-while-iterating.html [new file with mode: 0644]
LayoutTests/storage/indexeddb/resources/cursor-update-while-iterating.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp
Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.h