Skip to content

Commit 73adacd

Browse files
committed
Implement IDBTransaction.durability
https://bugs.webkit.org/show_bug.cgi?id=228289 Reviewed by Darin Adler. LayoutTests/imported/w3c: * web-platform-tests/IndexedDB/idlharness.any-expected.txt: * web-platform-tests/IndexedDB/idlharness.any.worker-expected.txt: * web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any-expected.txt: * web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any.worker-expected.txt: Source/WebCore: Spec: https://www.w3.org/TR/IndexedDB/#dom-idbtransaction-durability https://www.w3.org/TR/IndexedDB/#dictdef-idbtransactionoptions IDBTransaction.durability gives a hint about durability of a transaction. If it's strict, backend would try syncing data to database file after transaction commit, which enforces durability. If it's relaxed, it means data may stay in the OS buffer some time after transaction commit, which gives better performance. Firefox and Chrome already implemented durability. They have different ways of setting durability, and we choose to use TransactionOptions as spec. Rebaselined existing tests. New tests: storage/indexeddb/idbtransaction-durability-private.html storage/indexeddb/idbtransaction-durability.html * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * Headers.cmake: * Modules/indexeddb/IDBDatabase.cpp: (WebCore::IDBDatabase::transaction): * Modules/indexeddb/IDBDatabase.h: * Modules/indexeddb/IDBDatabase.idl: * Modules/indexeddb/IDBTransaction.h: * Modules/indexeddb/IDBTransaction.idl: * Modules/indexeddb/IDBTransactionDurability.h: Added. * Modules/indexeddb/IDBTransactionDurability.idl: Added. * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp: (WebCore::IDBServer::SQLiteIDBBackingStore::commitTransaction): * Modules/indexeddb/server/SQLiteIDBTransaction.h: (WebCore::IDBServer::SQLiteIDBTransaction::durability const): * Modules/indexeddb/shared/IDBTransactionInfo.cpp: (WebCore::IDBTransactionInfo::clientTransaction): (WebCore::IDBTransactionInfo::IDBTransactionInfo): (WebCore::IDBTransactionInfo::isolatedCopy): * Modules/indexeddb/shared/IDBTransactionInfo.h: (WebCore::IDBTransactionInfo::durability const): (WebCore::IDBTransactionInfo::encode const): (WebCore::IDBTransactionInfo::decode): * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * platform/sql/SQLiteDatabase.cpp: (WebCore::checkpointModeValue): (WebCore::SQLiteDatabase::checkpoint): (WebCore::SQLiteDatabase::useWALJournalMode): * platform/sql/SQLiteDatabase.h: LayoutTests: * storage/indexeddb/idbtransaction-durability-expected.txt: Added. * storage/indexeddb/idbtransaction-durability-private-expected.txt: Added. * storage/indexeddb/idbtransaction-durability-private.html: Added. * storage/indexeddb/idbtransaction-durability.html: Added. * storage/indexeddb/resources/idbtransaction-durability.js: Added. (onOpenUpgradeNeeded): (onOpenSuccess): (onTransactionComplete): Canonical link: https://commits.webkit.org/240055@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280415 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 4b00bd3 commit 73adacd

32 files changed

Lines changed: 351 additions & 39 deletions

LayoutTests/ChangeLog

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
2021-07-28 Sihui Liu <sihui_liu@apple.com>
2+
3+
Implement IDBTransaction.durability
4+
https://bugs.webkit.org/show_bug.cgi?id=228289
5+
6+
Reviewed by Darin Adler.
7+
8+
* storage/indexeddb/idbtransaction-durability-expected.txt: Added.
9+
* storage/indexeddb/idbtransaction-durability-private-expected.txt: Added.
10+
* storage/indexeddb/idbtransaction-durability-private.html: Added.
11+
* storage/indexeddb/idbtransaction-durability.html: Added.
12+
* storage/indexeddb/resources/idbtransaction-durability.js: Added.
13+
(onOpenUpgradeNeeded):
14+
(onOpenSuccess):
15+
(onTransactionComplete):
16+
117
2021-07-28 Ayumi Kojima <ayumi_kojima@apple.com>
218

319
[ iPad ] platform/ipad/media/modern-media-controls/media-documents/media-document-audio-ios-sizing.html is a flaky timeout.

LayoutTests/imported/w3c/ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2021-07-28 Sihui Liu <sihui_liu@apple.com>
2+
3+
Implement IDBTransaction.durability
4+
https://bugs.webkit.org/show_bug.cgi?id=228289
5+
6+
Reviewed by Darin Adler.
7+
8+
* web-platform-tests/IndexedDB/idlharness.any-expected.txt:
9+
* web-platform-tests/IndexedDB/idlharness.any.worker-expected.txt:
10+
* web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any-expected.txt:
11+
* web-platform-tests/IndexedDB/transaction-relaxed-durability.tentative.any.worker-expected.txt:
12+
113
2021-07-28 Sihui Liu <sihui_liu@apple.com>
214

315
IDBFactory.databases should not return databases with invalid version

LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idlharness.any-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ PASS IDBTransaction interface: existence and properties of interface prototype o
185185
PASS IDBTransaction interface: existence and properties of interface prototype object's @@unscopables property
186186
PASS IDBTransaction interface: attribute objectStoreNames
187187
PASS IDBTransaction interface: attribute mode
188-
FAIL IDBTransaction interface: attribute durability assert_true: The prototype object must have a property "durability" expected true got false
188+
PASS IDBTransaction interface: attribute durability
189189
PASS IDBTransaction interface: attribute db
190190
PASS IDBTransaction interface: attribute error
191191
PASS IDBTransaction interface: operation objectStore(DOMString)

LayoutTests/imported/w3c/web-platform-tests/IndexedDB/idlharness.any.worker-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ PASS IDBTransaction interface: existence and properties of interface prototype o
185185
PASS IDBTransaction interface: existence and properties of interface prototype object's @@unscopables property
186186
PASS IDBTransaction interface: attribute objectStoreNames
187187
PASS IDBTransaction interface: attribute mode
188-
FAIL IDBTransaction interface: attribute durability assert_true: The prototype object must have a property "durability" expected true got false
188+
PASS IDBTransaction interface: attribute durability
189189
PASS IDBTransaction interface: attribute db
190190
PASS IDBTransaction interface: attribute error
191191
PASS IDBTransaction interface: operation objectStore(DOMString)
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11

2-
FAIL Committed data can be read back out: case 0 assert_equals: expected (string) "default" but got (undefined) undefined
3-
FAIL Committed data can be read back out: case 1 assert_equals: expected (string) "default" but got (undefined) undefined
4-
FAIL Committed data can be read back out: case 2 assert_equals: expected (string) "default" but got (undefined) undefined
5-
FAIL Committed data can be read back out: case 3 assert_equals: expected (string) "relaxed" but got (undefined) undefined
6-
FAIL Committed data can be read back out: case 4 assert_equals: expected (string) "strict" but got (undefined) undefined
7-
FAIL Invalid durability option throws a TypeError assert_throws_js: function "function () {
8-
db.transaction(['books'], 'readwrite', { durability: 'invalid' });
9-
}" did not throw
2+
PASS Committed data can be read back out: case 0
3+
PASS Committed data can be read back out: case 1
4+
PASS Committed data can be read back out: case 2
5+
PASS Committed data can be read back out: case 3
6+
PASS Committed data can be read back out: case 4
7+
PASS Invalid durability option throws a TypeError
108

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11

2-
FAIL Committed data can be read back out: case 0 assert_equals: expected (string) "default" but got (undefined) undefined
3-
FAIL Committed data can be read back out: case 1 assert_equals: expected (string) "default" but got (undefined) undefined
4-
FAIL Committed data can be read back out: case 2 assert_equals: expected (string) "default" but got (undefined) undefined
5-
FAIL Committed data can be read back out: case 3 assert_equals: expected (string) "relaxed" but got (undefined) undefined
6-
FAIL Committed data can be read back out: case 4 assert_equals: expected (string) "strict" but got (undefined) undefined
7-
FAIL Invalid durability option throws a TypeError assert_throws_js: function "function () {
8-
db.transaction(['books'], 'readwrite', { durability: 'invalid' });
9-
}" did not throw
2+
PASS Committed data can be read back out: case 0
3+
PASS Committed data can be read back out: case 1
4+
PASS Committed data can be read back out: case 2
5+
PASS Committed data can be read back out: case 3
6+
PASS Committed data can be read back out: case 4
7+
PASS Invalid durability option throws a TypeError
108

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Ensure durability of transaction is expected
2+
3+
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4+
5+
6+
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
7+
8+
indexedDB.deleteDatabase(dbname)
9+
indexedDB.open(dbname)
10+
11+
onOpenUpgradeNeeded():
12+
database = event.target.result
13+
PASS event.target.transaction.durability is "default"
14+
15+
onOpenSuccess():
16+
transaction = database.transaction('objectstore')
17+
PASS transaction.durability is "default"
18+
19+
onTransactionComplete():
20+
PASS transaction.durability is "default"
21+
PASS successfullyParsed is true
22+
23+
TEST COMPLETE
24+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Ensure durability of transaction is expected
2+
3+
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4+
5+
6+
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
7+
8+
indexedDB.deleteDatabase(dbname)
9+
indexedDB.open(dbname)
10+
11+
onOpenUpgradeNeeded():
12+
database = event.target.result
13+
PASS event.target.transaction.durability is "default"
14+
15+
onOpenSuccess():
16+
transaction = database.transaction('objectstore')
17+
PASS transaction.durability is "default"
18+
19+
onTransactionComplete():
20+
PASS transaction.durability is "default"
21+
PASS successfullyParsed is true
22+
23+
TEST COMPLETE
24+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!-- webkit-test-runner [ useEphemeralSession=true ] -->
2+
<html>
3+
<head>
4+
<script src="../../resources/js-test.js"></script>
5+
<script src="resources/shared.js"></script>
6+
</head>
7+
<body>
8+
<script src="resources/idbtransaction-durability.js"></script>
9+
</body>
10+
</html>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html>
2+
<head>
3+
<script src="../../resources/js-test.js"></script>
4+
<script src="resources/shared.js"></script>
5+
</head>
6+
<body>
7+
<script src="resources/idbtransaction-durability.js"></script>
8+
</body>
9+
</html>

0 commit comments

Comments
 (0)