Skip to content

Truly independent web browser

Tests/LibWeb: Import IndexedDB key path and transaction abort tests

Andreas Kling838d59ecbaea
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.ini
index 0426dc383df..3a6837beff9 100644
--- a/Tests/LibWeb/TestConfig.ini
+++ b/Tests/LibWeb/TestConfig.ini
@@ -478,6 +478,11 @@ Text/input/wpt-import/wasm/webapi/instantiateStreaming-bad-imports.any.worker.ht
Text/input/wpt-import/wasm/webapi/instantiateStreaming.any.worker.html
Text/input/wpt-import/wasm/webapi/invalid-args.any.worker.html
Text/input/wpt-import/wasm/webapi/rejected-arg.any.worker.html
+Text/input/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.html
+Text/input/wpt-import/IndexedDB/keygenerator.any.worker.html
+Text/input/wpt-import/IndexedDB/keypath_invalid.any.sharedworker.html
+Text/input/wpt-import/IndexedDB/keypath_invalid.any.worker.html
+Text/input/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.html
Text/input/wpt-import/encoding/encodeInto.any.worker.html
Text/input/wpt-import/WebCryptoAPI/historical.any.worker.html
Text/input/Worker/Worker-close-after-postMessage.html
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/clone-before-keypath-eval.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/clone-before-keypath-eval.any.txt
new file mode 100644
index 00000000000..0121dce9738
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/clone-before-keypath-eval.any.txt
@@ -0,0 +1,11 @@
+Harness status: OK
+
+Found 6 tests
+
+6 Pass
+Pass Key generator and key path validity check operates on a clone
+Pass Failing key path validity check operates on a clone
+Pass Index key path evaluations operate on a clone
+Pass Store and index key path evaluations operate on the same clone
+Pass Cursor update checks and keypath evaluations operate on a clone
+Pass Blob expando properties are stripped in the clone used for index key path evaluation
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbindex_keyPath.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbindex_keyPath.any.txt
new file mode 100644
index 00000000000..3b6f8d2ec4a
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbindex_keyPath.any.txt
@@ -0,0 +1,9 @@
+Harness status: OK
+
+Found 3 tests
+
+2 Pass
+1 Fail
+Fail IDBIndex's keyPath attribute returns the same object.
+Pass IDBIndex's keyPath array with a single value
+Pass IDBIndex's keyPath array with multiple values
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.txt
new file mode 100644
index 00000000000..119edee212f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.txt
@@ -0,0 +1,27 @@
+Harness status: Error
+
+Found 21 tests
+
+15 Pass
+6 Fail
+Pass Returns an IDBIndex and the properties are set correctly
+Fail Attempt to create an index that requires unique values on an object store already contains duplicates
+Pass The index is usable right after being made
+Fail Event ordering for a later deleted index
+Pass Empty keyPath
+Fail Event order when unique constraint is triggered
+Fail Event ordering for ConstraintError on request
+Pass Index can be valid keys
+Pass IDBObjectStore.createIndex() - empty name
+Pass If an index with the name name already exists in this object store, the implementation must throw a DOMException of type ConstraintError
+Fail If keyPath is not a valid key path, the implementation must throw a DOMException of type SyntaxError
+Pass If the object store has been deleted, the implementation must throw a DOMException of type InvalidStateError
+Pass Operate out versionchange throw InvalidStateError
+Pass InvalidStateError(Incorrect mode) vs. TransactionInactiveError. Mode check should precede state check of the transaction.
+Pass InvalidStateError(Deleted ObjectStore) vs. TransactionInactiveError. Deletion check should precede transaction-state check.
+Pass TransactionInactiveError vs. ConstraintError. Transaction-state check should precede index name check.
+Pass ConstraintError vs. SyntaxError. Index name check should precede syntax check of the key path
+Fail SyntaxError vs. InvalidAccessError. Syntax check should precede multiEntry check of the key path.
+Pass Explicit Primary Key
+Pass Auto-Increment Primary Key
+Pass Auto-Increment Primary Key - invalid key values elsewhere
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_keyPath.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_keyPath.any.txt
new file mode 100644
index 00000000000..bfca0907e54
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/idbobjectstore_keyPath.any.txt
@@ -0,0 +1,6 @@
+Harness status: OK
+
+Found 1 tests
+
+1 Fail
+Fail IDBObjectStore's keyPath attribute returns the same object.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keygenerator.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keygenerator.any.worker.txt
new file mode 100644
index 00000000000..8b1397e2ac7
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keygenerator.any.worker.txt
@@ -0,0 +1,27 @@
+Harness status: OK
+
+Found 21 tests
+
+15 Pass
+6 Fail
+Pass Keygenerator - starts at one, and increments by one
+Pass Keygenerator - increments by one from last set key
+Pass Keygenerator - don't increment when new key is not bigger than current
+Pass Keygenerator ConstraintError when using same id as already generated
+Fail Key generator vs. explicit key 53 bits
+Fail Key generator vs. explicit key greater than 53 bits, less than 64 bits
+Pass Key generator vs. explicit key greater than 53 bits, less than 64 bits (negative)
+Fail Key generator vs. explicit key 63 bits
+Pass Key generator vs. explicit key 63 bits (negative)
+Fail Key generator vs. explicit key 64 bits
+Pass Key generator vs. explicit key 64 bits (negative)
+Fail Key generator vs. explicit key greater than 64 bits, but still finite
+Pass Key generator vs. explicit key greater than 64 bits, but still finite (negative)
+Fail Key generator vs. explicit key equal to Infinity
+Pass Key generator vs. explicit key equal to -Infinity
+Pass Key is injected into value - single segment path
+Pass Key is injected into value - multi-segment path
+Pass Key is injected into value - multi-segment path, partially populated
+Pass put() throws if key cannot be injected - single segment path
+Pass put() throws if key cannot be injected - multi-segment path
+Pass Keygenerator overflow
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keypath.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keypath.any.txt
new file mode 100644
index 00000000000..ab889545ac0
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keypath.any.txt
@@ -0,0 +1,26 @@
+Harness status: OK
+
+Found 20 tests
+
+19 Pass
+1 Fail
+Pass undefined - my.key
+Pass undefined - my.køi
+Pass undefined - my.key_ya
+Pass undefined - public.key$ya
+Pass undefined - true.$
+Pass undefined - my._
+Pass undefined - delete.a7
+Pass undefined - p.p.p.p.p.p.p.p.p.p.p.p.p.p
+Pass undefined - str.length
+Pass undefined - arr.length
+Pass undefined - length
+Pass undefined - '' uses value as key
+Pass undefined - [''] uses value as [key]
+Pass undefined - ['x', 'y']
+Pass undefined - [['x'], 'y'] (stringifies)
+Pass undefined - ['x', {toString->'y'}] (stringifies)
+Pass undefined - name,type
+Pass undefined - name,type.name
+Pass undefined - list with 1 field
+Fail Key path conversion: a self-referential array exhausts the stack
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keypath_invalid.any.sharedworker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keypath_invalid.any.sharedworker.txt
new file mode 100644
index 00000000000..66390d14d4a
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keypath_invalid.any.sharedworker.txt
@@ -0,0 +1,30 @@
+Harness status: OK
+
+Found 24 tests
+
+1 Pass
+23 Fail
+Fail Invalid keyPath - "j a"
+Fail Invalid keyPath - ".yo"
+Fail Invalid keyPath - "yo,lo"
+Pass Invalid keyPath - []
+Fail Invalid keyPath - ["array with space"]
+Fail Invalid keyPath - multidimensional array (invalid toString)
+Fail Invalid keyPath - "3m"
+Fail Invalid keyPath - {toString->3m}
+Fail Invalid keyPath - "my.1337"
+Fail Invalid keyPath - "..yo"
+Fail Invalid keyPath - "y..o"
+Fail Invalid keyPath - "y.o."
+Fail Invalid keyPath - "y.o.."
+Fail Invalid keyPath - "m.*"
+Fail Invalid keyPath - "\"m\""
+Fail Invalid keyPath - "m%"
+Fail Invalid keyPath - "m/"
+Fail Invalid keyPath - "m/a"
+Fail Invalid keyPath - "m&"
+Fail Invalid keyPath - "m!"
+Fail Invalid keyPath - "*"
+Fail Invalid keyPath - "*.*"
+Fail Invalid keyPath - "^m"
+Fail Invalid keyPath - "/m/"
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keypath_invalid.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keypath_invalid.any.worker.txt
new file mode 100644
index 00000000000..66390d14d4a
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keypath_invalid.any.worker.txt
@@ -0,0 +1,30 @@
+Harness status: OK
+
+Found 24 tests
+
+1 Pass
+23 Fail
+Fail Invalid keyPath - "j a"
+Fail Invalid keyPath - ".yo"
+Fail Invalid keyPath - "yo,lo"
+Pass Invalid keyPath - []
+Fail Invalid keyPath - ["array with space"]
+Fail Invalid keyPath - multidimensional array (invalid toString)
+Fail Invalid keyPath - "3m"
+Fail Invalid keyPath - {toString->3m}
+Fail Invalid keyPath - "my.1337"
+Fail Invalid keyPath - "..yo"
+Fail Invalid keyPath - "y..o"
+Fail Invalid keyPath - "y.o."
+Fail Invalid keyPath - "y.o.."
+Fail Invalid keyPath - "m.*"
+Fail Invalid keyPath - "\"m\""
+Fail Invalid keyPath - "m%"
+Fail Invalid keyPath - "m/"
+Fail Invalid keyPath - "m/a"
+Fail Invalid keyPath - "m&"
+Fail Invalid keyPath - "m!"
+Fail Invalid keyPath - "*"
+Fail Invalid keyPath - "*.*"
+Fail Invalid keyPath - "^m"
+Fail Invalid keyPath - "/m/"
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keypath_maxsize.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keypath_maxsize.any.txt
new file mode 100644
index 00000000000..94ae653ac39
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/keypath_maxsize.any.txt
@@ -0,0 +1,8 @@
+Harness status: OK
+
+Found 3 tests
+
+3 Pass
+Pass undefined - ~260 chars
+Pass undefined - ~530 chars
+Pass undefined - ~1050 chars
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-generator-revert.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-generator-revert.any.txt
new file mode 100644
index 00000000000..7e6bbc6a41f
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-generator-revert.any.txt
@@ -0,0 +1,7 @@
+Harness status: OK
+
+Found 2 tests
+
+2 Pass
+Pass The current number of a key generator is reverted when a versionchange transaction aborts
+Pass The current number of a key generator is reverted when a readwrite transaction aborts
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.txt
new file mode 100644
index 00000000000..f4e84f70d6b
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.txt
@@ -0,0 +1,12 @@
+Harness status: OK
+
+Found 6 tests
+
+2 Pass
+4 Fail
+Fail Created stores get their indexes marked as deleted after the transaction that created them aborts
+Pass Deleted stores get their indexes marked as not-deleted after the transaction that deleted them aborts
+Fail Created+deleted stores still have their indexes marked as deleted after the transaction aborts
+Fail Created indexes get marked as deleted after their transaction aborts
+Pass Deleted indexes get marked as not-deleted after the transaction aborts
+Fail Created+deleted indexes are still marked as deleted after their transaction aborts
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.txt
new file mode 100644
index 00000000000..f4e84f70d6b
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.txt
@@ -0,0 +1,12 @@
+Harness status: OK
+
+Found 6 tests
+
+2 Pass
+4 Fail
+Fail Created stores get their indexes marked as deleted after the transaction that created them aborts
+Pass Deleted stores get their indexes marked as not-deleted after the transaction that deleted them aborts
+Fail Created+deleted stores still have their indexes marked as deleted after the transaction aborts
+Fail Created indexes get marked as deleted after their transaction aborts
+Pass Deleted indexes get marked as not-deleted after the transaction aborts
+Fail Created+deleted indexes are still marked as deleted after their transaction aborts
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-multiple-metadata-revert.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-multiple-metadata-revert.any.txt
new file mode 100644
index 00000000000..8c38cdca2c9
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-multiple-metadata-revert.any.txt
@@ -0,0 +1,9 @@
+Harness status: OK
+
+Found 3 tests
+
+1 Pass
+2 Fail
+Fail Deleted indexes in newly created stores are still marked as deleted after the transaction aborts
+Pass Deleted indexes in deleted stores are still marked as not-deleted after the transaction aborts
+Fail Deleted indexes in created+deleted stores are still marked as deleted after their transaction aborts
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-object-store-metadata-revert.any.txt b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-object-store-metadata-revert.any.txt
new file mode 100644
index 00000000000..aaba611783b
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/IndexedDB/transaction-abort-object-store-metadata-revert.any.txt
@@ -0,0 +1,10 @@
+Harness status: OK
+
+Found 4 tests
+
+2 Pass
+2 Fail
+Fail Created stores get marked as deleted after their transaction aborts
+Pass Deleted stores get marked as not-deleted after the transaction aborts
+Fail Created+deleted stores are still marked as deleted after their transaction aborts
+Pass Un-instantiated deleted stores get marked as not-deleted after the transaction aborts
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/clone-before-keypath-eval.any.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/clone-before-keypath-eval.any.html
new file mode 100644
index 00000000000..4b94ced5227
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/clone-before-keypath-eval.any.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>IndexedDB: clone before key path evaluation</title>
+<script>
+self.GLOBAL = {
+ isWindow: function() { return true; },
+ isWorker: function() { return false; },
+ isShadowRealm: function() { return false; },
+};
+</script>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/support.js"></script>
+<div id=log></div>
+<script src="../IndexedDB/clone-before-keypath-eval.any.js"></script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/clone-before-keypath-eval.any.js b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/clone-before-keypath-eval.any.js
new file mode 100644
index 00000000000..817c488d956
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/clone-before-keypath-eval.any.js
@@ -0,0 +1,156 @@
+// META: title=IndexedDB: clone before key path evaluation
+// META: global=window,worker
+// META: script=resources/support.js
+
+'use strict';
+
+function ProbeObject() {
+ this.id_count = 0;
+ this.invalid_id_count = 0;
+ this.prop_count = 0;
+ Object.defineProperties(this, {
+ id: {
+ enumerable: true,
+ get() {
+ ++this.id_count;
+ return 1000 + this.id_count;
+ },
+ },
+ invalid_id: {
+ enumerable: true,
+ get() {
+ ++this.invalid_id_count;
+ return {};
+ },
+ },
+ prop: {
+ enumerable: true,
+ get() {
+ ++this.prop_count;
+ return 2000 + this.prop_count;
+ },
+ },
+ });
+}
+
+function createObjectStoreWithKeyPath(
+ storeName, keyPath, autoIncrement = false) {
+ return (t, db) => {
+ db.createObjectStore(storeName, {keyPath, autoIncrement});
+ };
+}
+
+function createObjectStoreWithIndex(
+ storeName, keyPath, indexName, indexKeyPath) {
+ return (t, db) => {
+ const storeOptions = keyPath ? {keyPath} : {};
+ const store = db.createObjectStore(storeName, storeOptions);
+
+ // If index parameters are provided, create the index.
+ if (indexName && indexKeyPath) {
+ store.createIndex(indexName, indexKeyPath);
+ }
+ };
+}
+
+function createTransactionAndReturnObjectStore(db, storeName) {
+ const tx = db.transaction(storeName, 'readwrite');
+ const store = tx.objectStore(storeName);
+ return {tx, store};
+}
+
+indexeddb_test(createObjectStoreWithKeyPath('store', 'id', true), (t, db) => {
+ const {store} = createTransactionAndReturnObjectStore(db, 'store');
+ const obj = new ProbeObject();
+ store.put(obj);
+ assert_equals(
+ obj.id_count, 1,
+ 'put() operation should access primary key property once');
+ assert_equals(
+ obj.prop_count, 1, 'put() operation should access other properties once');
+ t.done();
+}, 'Key generator and key path validity check operates on a clone');
+
+indexeddb_test(
+ createObjectStoreWithKeyPath('store', 'invalid_id', true), (t, db) => {
+ const {store} = createTransactionAndReturnObjectStore(db, 'store');
+ const obj = new ProbeObject();
+ assert_throws_dom('DataError', () => {
+ store.put(obj);
+ }, 'put() should throw if primary key cannot be injected');
+ assert_equals(
+ obj.invalid_id_count, 1,
+ 'put() operation should access primary key property once');
+ assert_equals(
+ obj.prop_count, 1,
+ 'put() operation should access other properties once');
+ t.done();
+ }, 'Failing key path validity check operates on a clone');
+
+indexeddb_test(
+ createObjectStoreWithIndex('store', null, 'index', 'prop'), (t, db) => {
+ const {store} = createTransactionAndReturnObjectStore(db, 'store');
+ const obj = new ProbeObject();
+ store.put(obj, 'key');
+ assert_equals(
+ obj.prop_count, 1, 'put() should access index key property once');
+ assert_equals(
+ obj.id_count, 1,
+ 'put() operation should access other properties once');
+ t.done();
+ }, 'Index key path evaluations operate on a clone');
+
+indexeddb_test(
+ createObjectStoreWithIndex('store', 'id', 'index', 'prop'), (t, db) => {
+ const {store} = createTransactionAndReturnObjectStore(db, 'store');
+ const obj = new ProbeObject();
+ store.put(obj);
+ assert_equals(
+ obj.id_count, 1, 'put() should access primary key property once');
+ assert_equals(
+ obj.prop_count, 1, 'put() should access index key property once');
+ t.done();
+ }, 'Store and index key path evaluations operate on the same clone');
+
+indexeddb_test(
+ createObjectStoreWithIndex('store', 'id', 'index', 'prop'), (t, db) => {
+ const {store} = createTransactionAndReturnObjectStore(db, 'store');
+ store.put(new ProbeObject());
+
+ store.openCursor().onsuccess = t.step_func((event) => {
+ const cursor = event.target.result;
+
+ const obj = new ProbeObject();
+ cursor.update(obj);
+ assert_equals(
+ obj.id_count, 1, 'put() should access primary key property once');
+ assert_equals(
+ obj.prop_count, 1, 'put() should access index key property once');
+
+ t.done();
+ });
+ }, 'Cursor update checks and keypath evaluations operate on a clone');
+
+indexeddb_test(
+ createObjectStoreWithIndex(
+ 'store', null, 'index', 'blob.expando.val'),
+ (t, db) => {
+ const {store} = createTransactionAndReturnObjectStore(db, 'store');
+
+ const blob = new Blob(['data']);
+ let trapFired = false;
+ blob.expando = new Proxy({val: 'key'}, {
+ getOwnPropertyDescriptor(target, prop) {
+ trapFired = true;
+ return Reflect.getOwnPropertyDescriptor(target, prop);
+ },
+ });
+
+ const request = store.put({blob}, 'key');
+ request.onsuccess = t.step_func(() => {
+ assert_false(trapFired, 'Proxy trap on Blob expando must not fire');
+ t.done();
+ });
+ request.onerror = t.unreached_func('put() should not fail');
+ },
+ 'Blob expando properties are stripped in the clone used for index key path evaluation');
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbindex_keyPath.any.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbindex_keyPath.any.html
new file mode 100644
index 00000000000..295224ba599
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbindex_keyPath.any.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>IndexedDB: IDBIndex keyPath attribute</title>
+<script>
+self.GLOBAL = {
+ isWindow: function() { return true; },
+ isWorker: function() { return false; },
+ isShadowRealm: function() { return false; },
+};
+</script>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/support.js"></script>
+<div id=log></div>
+<script src="../IndexedDB/idbindex_keyPath.any.js"></script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbindex_keyPath.any.js b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbindex_keyPath.any.js
new file mode 100644
index 00000000000..5ea905fd4f3
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbindex_keyPath.any.js
@@ -0,0 +1,75 @@
+// META: title=IndexedDB: IDBIndex keyPath attribute
+// META: script=resources/support.js
+'use strict';
+
+indexeddb_test(
+ (t, db) => {
+ const store = db.createObjectStore('store', {keyPath: ['a', 'b']});
+ store.createIndex('index', ['a', 'b']);
+ },
+ (t, db) => {
+ const tx = db.transaction('store', 'readonly');
+ const store = tx.objectStore('store');
+ const index = store.index('index');
+ assert_equals(typeof index.keyPath, 'object', 'keyPath is an object');
+ assert_true(Array.isArray(index.keyPath), 'keyPath is an array');
+
+ assert_equals(
+ index.keyPath, index.keyPath,
+ 'Same object instance is returned each time keyPath is inspected');
+
+ const tx2 = db.transaction('store', 'readonly');
+ const store2 = tx2.objectStore('store');
+ const index2 = store2.index('index');
+
+ assert_not_equals(
+ index.keyPath, index2.keyPath,
+ 'Different instances are returned from different index instances.');
+
+ t.done();
+ },
+ `IDBIndex's keyPath attribute returns the same object.`);
+
+ indexeddb_test(
+ (t, db) => {
+ const store = db.createObjectStore('store', {autoIncrement: true});
+ store.createIndex('index', ['a']);
+
+ store.add({a: 1, b: 2, c: 3})
+ },
+ (t, db) => {
+ const tx = db.transaction('store', 'readonly');
+ const store = tx.objectStore('store');
+ const index = store.index('index');
+ const cursorReq = index.openCursor();
+
+ cursorReq.onsuccess = t.step_func_done((e) => {
+ const expectedKeyValue = [1];
+ const actualKeyValue = e.target.result.key;
+
+ assert_array_equals(actualKeyValue, expectedKeyValue, "An array keypath should yield an array key");
+ });
+ },
+ `IDBIndex's keyPath array with a single value`);
+
+ indexeddb_test(
+ (t, db) => {
+ const store = db.createObjectStore('store', {autoIncrement: true});
+ store.createIndex('index', ['a', 'b']);
+
+ store.add({a: 1, b: 2, c: 3})
+ },
+ (t, db) => {
+ const tx = db.transaction('store', 'readonly');
+ const store = tx.objectStore('store');
+ const index = store.index('index');
+ const cursorReq = index.openCursor();
+
+ cursorReq.onsuccess = t.step_func_done((e) => {
+ const expectedKeyValue = [1, 2];
+ const actualKeyValue = e.target.result.key;
+
+ assert_array_equals(actualKeyValue, expectedKeyValue, "An array keypath should yield an array key");
+ });
+ },
+ `IDBIndex's keyPath array with multiple values`);
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.html
new file mode 100644
index 00000000000..03d004951b0
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>IDBObjectStore.createIndex()</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../IndexedDB/idbobjectstore_createIndex.any.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.js b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.js
new file mode 100644
index 00000000000..ede6efa3fce
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbobjectstore_createIndex.any.worker.js
@@ -0,0 +1,11 @@
+
+self.GLOBAL = {
+ isWindow: function() { return false; },
+ isWorker: function() { return true; },
+ isShadowRealm: function() { return false; },
+};
+importScripts("/resources/testharness.js");
+self.META_TITLE = "IDBObjectStore.createIndex()";
+importScripts("resources/support.js")
+importScripts("/IndexedDB/idbobjectstore_createIndex.any.js");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbobjectstore_keyPath.any.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbobjectstore_keyPath.any.html
new file mode 100644
index 00000000000..ad29ed4a212
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbobjectstore_keyPath.any.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>IndexedDB: IDBObjectStore keyPath attribute - same object</title>
+<script>
+self.GLOBAL = {
+ isWindow: function() { return true; },
+ isWorker: function() { return false; },
+ isShadowRealm: function() { return false; },
+};
+</script>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/support.js"></script>
+<div id=log></div>
+<script src="../IndexedDB/idbobjectstore_keyPath.any.js"></script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbobjectstore_keyPath.any.js b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbobjectstore_keyPath.any.js
new file mode 100644
index 00000000000..c77c2965ae4
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/idbobjectstore_keyPath.any.js
@@ -0,0 +1,28 @@
+// META: title=IndexedDB: IDBObjectStore keyPath attribute - same object
+// META: script=resources/support.js
+'use strict';
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('store', {keyPath: ['a', 'b']});
+ },
+ (t, db) => {
+ const tx = db.transaction('store', 'readonly');
+ const store = tx.objectStore('store');
+ assert_equals(typeof store.keyPath, 'object', 'keyPath is an object');
+ assert_true(Array.isArray(store.keyPath), 'keyPath is an array');
+
+ assert_equals(
+ store.keyPath, store.keyPath,
+ 'Same object instance is returned each time keyPath is inspected');
+
+ const tx2 = db.transaction('store', 'readonly');
+ const store2 = tx2.objectStore('store');
+
+ assert_not_equals(
+ store.keyPath, store2.keyPath,
+ 'Different instances are returned from different store instances.');
+
+ t.done();
+ },
+ `IDBObjectStore's keyPath attribute returns the same object.`);
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keygenerator.any.worker.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keygenerator.any.worker.html
new file mode 100644
index 00000000000..c8e6a6da923
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keygenerator.any.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../IndexedDB/keygenerator.any.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keygenerator.any.worker.js b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keygenerator.any.worker.js
new file mode 100644
index 00000000000..efe06d0b560
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keygenerator.any.worker.js
@@ -0,0 +1,10 @@
+
+self.GLOBAL = {
+ isWindow: function() { return false; },
+ isWorker: function() { return true; },
+ isShadowRealm: function() { return false; },
+};
+importScripts("/resources/testharness.js");
+importScripts("resources/support.js")
+importScripts("/IndexedDB/keygenerator.any.js");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath.any.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath.any.html
new file mode 100644
index 00000000000..57c5ec04178
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath.any.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Keypath</title>
+<script>
+self.GLOBAL = {
+ isWindow: function() { return true; },
+ isWorker: function() { return false; },
+ isShadowRealm: function() { return false; },
+};
+</script>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/support.js"></script>
+<div id=log></div>
+<script src="../IndexedDB/keypath.any.js"></script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath.any.js b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath.any.js
new file mode 100644
index 00000000000..2b3a7a8022c
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath.any.js
@@ -0,0 +1,152 @@
+// META: global=window,worker
+// META: title=Keypath
+// META: script=resources/support.js
+
+// Spec:
+// http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#key-path-construct
+
+'use strict';
+
+let global_db = createdb_for_multiple_tests();
+
+function keypath(keypath, objects, expected_keys, desc) {
+ let db;
+ let t = async_test(self.title + ' - ' + (desc ? desc : keypath));
+ let store_name = 'store-' + (Date.now()) + Math.random();
+
+ let open_rq = global_db.setTest(t);
+ open_rq.onupgradeneeded = function(e) {
+ db = e.target.result;
+ let objStore = db.createObjectStore(store_name, {keyPath: keypath});
+
+ for (let i = 0; i < objects.length; i++)
+ objStore.add(objects[i]);
+ };
+
+ open_rq.onsuccess = function(e) {
+ let actual_keys = [];
+ let rq = db.transaction(store_name).objectStore(store_name).openCursor();
+
+ rq.onsuccess = t.step_func(function(e) {
+ let cursor = e.target.result;
+
+ if (cursor) {
+ actual_keys.push(cursor.key.valueOf());
+ cursor.continue();
+ } else {
+ assert_key_equals(actual_keys, expected_keys, 'keyorder array');
+ t.done();
+ }
+ });
+ };
+}
+
+keypath('my.key', [{my: {key: 10}}], [10]);
+
+keypath('my.køi', [{my: {køi: 5}}], [5]);
+
+keypath('my.key_ya', [{my: {key_ya: 10}}], [10]);
+
+keypath('public.key$ya', [{public: {key$ya: 10}}], [10]);
+
+keypath('true.$', [{true: {$: 10}}], [10]);
+
+keypath('my._', [{my: {_: 10}}], [10]);
+
+keypath('delete.a7', [{delete: {a7: 10}}], [10]);
+
+keypath(
+ 'p.p.p.p.p.p.p.p.p.p.p.p.p.p',
+ [{p: {p: {p: {p: {p: {p: {p: {p: {p: {p: {p: {p: {p: {p: 10}}}}}}}}}}}}}}],
+ [10]);
+
+keypath(
+ 'str.length', [{str: 'pony'}, {str: 'my'}, {str: 'little'}, {str: ''}],
+ [0, 2, 4, 6]);
+
+keypath(
+ 'arr.length',
+ [
+ {arr: [0, 0, 0, 0]}, {arr: [{}, 0, 'hei', 'length', Infinity, []]},
+ {arr: [10, 10]}, {arr: []}
+ ],
+ [0, 2, 4, 6]);
+
+keypath('length', [[10, 10], '123', {length: 20}], [2, 3, 20]);
+
+keypath(
+ '', [['bags'], 'bean', 10], [10, 'bean', ['bags']],
+ '\'\' uses value as key');
+
+keypath(
+ [''], [['bags'], 'bean', 10], [[10], ['bean'], [['bags']]],
+ '[\'\'] uses value as [key]');
+
+keypath(
+ ['x', 'y'], [{x: 10, y: 20}, {y: 1.337, x: 100}], [[10, 20], [100, 1.337]],
+ '[\'x\', \'y\']');
+
+keypath(
+ [['x'], ['y']], [{x: 10, y: 20}, {y: 1.337, x: 100}],
+ [[10, 20], [100, 1.337]], '[[\'x\'], \'y\'] (stringifies)');
+
+keypath(
+ [
+ 'x', {
+ toString: function() {
+ return 'y'
+ }
+ }
+ ],
+ [{x: 10, y: 20}, {y: 1.337, x: 100}], [[10, 20], [100, 1.337]],
+ '[\'x\', {toString->\'y\'}] (stringifies)');
+
+if (false) {
+ let myblob = Blob(['Yoda'], {type: 'suprawsum'});
+ keypath(
+ ['length', 'type'], [myblob], [4, 'suprawsum'],
+ '[Blob.length, Blob.type]');
+}
+
+// File.name and File.lastModified is not testable automatically
+
+keypath(
+ ['name', 'type'],
+ [
+ {name: 'orange', type: 'fruit'},
+ {name: 'orange', type: ['telecom', 'french']}
+ ],
+ [['orange', 'fruit'], ['orange', ['telecom', 'french']]]);
+
+keypath(
+ ['name', 'type.name'],
+ [
+ {name: 'orange', type: {name: 'fruit'}},
+ {name: 'orange', type: {name: 'telecom'}}
+ ],
+ [['orange', 'fruit'], ['orange', 'telecom']]);
+
+keypath(
+ ['type'],
+ [{name: 'orange', type: 'fruit'}, {name: 'cucumber', type: 'vegetable'}],
+ [['fruit'], ['vegetable']], 'list with 1 field');
+
+// A key path that is a sequence is converted with the WebIDL sequence<DOMString> conversion, which
+// stringifies every item. Stringifying a self-referential array recurses without bound, because
+// ECMA-262 defines no cycle detection for Array.prototype.join
+// (https://tc39.es/ecma262/#sec-array.prototype.join): joining the array converts element 0, which
+// is the array itself, which is joined again. The conversion therefore exceeds an implementation
+// limit and reports an error. It must not quietly substitute the empty string on the repeat visit,
+// which would yield the key path [''] and make each value its own key.
+indexeddb_test(
+ function(t, db) {
+ let loop_array = [];
+ loop_array.push(loop_array);
+ assert_throws_js(RangeError, function() {
+ db.createObjectStore('store', {keyPath: loop_array});
+ }, 'Converting a self-referential key path array should exhaust the stack.');
+ },
+ function(t, db) {
+ t.done();
+ },
+ 'Key path conversion: a self-referential array exhausts the stack');
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_invalid.any.sharedworker.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_invalid.any.sharedworker.html
new file mode 100644
index 00000000000..c03965c0793
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_invalid.any.sharedworker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Invalid keypath</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new SharedWorker("../IndexedDB/keypath_invalid.any.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_invalid.any.worker.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_invalid.any.worker.html
new file mode 100644
index 00000000000..4bb607d47d0
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_invalid.any.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Invalid keypath</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../IndexedDB/keypath_invalid.any.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_invalid.any.worker.js b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_invalid.any.worker.js
new file mode 100644
index 00000000000..a85cf65d09b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_invalid.any.worker.js
@@ -0,0 +1,11 @@
+
+self.GLOBAL = {
+ isWindow: function() { return false; },
+ isWorker: function() { return true; },
+ isShadowRealm: function() { return false; },
+};
+importScripts("/resources/testharness.js");
+self.META_TITLE = "Invalid keypath";
+importScripts("resources/support.js")
+importScripts("/IndexedDB/keypath_invalid.any.js");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_maxsize.any.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_maxsize.any.html
new file mode 100644
index 00000000000..09415e91086
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_maxsize.any.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Keypath</title>
+<script>
+self.GLOBAL = {
+ isWindow: function() { return true; },
+ isWorker: function() { return false; },
+ isShadowRealm: function() { return false; },
+};
+</script>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/support.js"></script>
+<div id=log></div>
+<script src="../IndexedDB/keypath_maxsize.any.js"></script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_maxsize.any.js b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_maxsize.any.js
new file mode 100644
index 00000000000..e20a9b1d3a9
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/keypath_maxsize.any.js
@@ -0,0 +1,78 @@
+// META: global=window,worker
+// META: title=Keypath
+// META: script=resources/support.js
+
+// Spec:
+// http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#key-path-construct
+
+'use strict';
+
+function keypath(keypath, objects, expected_keys, desc) {
+ let db;
+ let t = async_test(self.title + ' - ' + (desc ? desc : keypath));
+ let open_rq = createdb(t);
+
+ open_rq.onupgradeneeded = function(e) {
+ db = e.target.result;
+ let objStore = db.createObjectStore('store', {keyPath: keypath});
+
+ for (let i = 0; i < objects.length; i++)
+ objStore.add(objects[i]);
+ };
+
+ open_rq.onerror = function(e) {
+ assert_unreached(e.target.error.name);
+ };
+
+ open_rq.onsuccess = function(e) {
+ let actual_keys = [],
+ rq = db.transaction('store', 'readonly', {durability: 'relaxed'})
+ .objectStore('store')
+ .openCursor();
+
+ rq.onsuccess = t.step_func(function(e) {
+ let cursor = e.target.result;
+
+ if (cursor) {
+ actual_keys.push(cursor.key.valueOf());
+ cursor.continue();
+ } else {
+ assert_array_equals(actual_keys, expected_keys, 'keyorder array');
+ t.done();
+ }
+ });
+ };
+}
+
+keypath(
+ 'maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai.keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey',
+ [{
+ maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai:
+ {
+ keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey:
+ 10
+ }
+ }],
+ [10], '~260 chars');
+
+keypath(
+ 'maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai_maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai.keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey_keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey',
+ [{
+ maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai_maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai:
+ {
+ keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey_keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey:
+ 10
+ }
+ }],
+ [10], '~530 chars');
+
+keypath(
+ 'maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai_maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai_maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai_maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai.keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey_keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey_keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey_keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey',
+ [{
+ maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai_maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai_maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai_maaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaai:
+ {
+ keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey_keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey_keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey_keeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeey:
+ 10
+ }
+ }],
+ [10], '~1050 chars');
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-generator-revert.any.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-generator-revert.any.html
new file mode 100644
index 00000000000..73bd3b2b13e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-generator-revert.any.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>IndexedDB: aborting transactions reverts an object store's key generator state</title>
+<script>
+self.GLOBAL = {
+ isWindow: function() { return true; },
+ isWorker: function() { return false; },
+ isShadowRealm: function() { return false; },
+};
+</script>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/support-promises.js"></script>
+<script src="resources/support.js"></script>
+<div id=log></div>
+<script src="../IndexedDB/transaction-abort-generator-revert.any.js"></script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-generator-revert.any.js b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-generator-revert.any.js
new file mode 100644
index 00000000000..0c6ffa52d27
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-generator-revert.any.js
@@ -0,0 +1,124 @@
+// META: title=IndexedDB: aborting transactions reverts an object store's key generator state
+// META: global=window,worker
+// META: script=resources/support-promises.js
+// META: script=resources/support.js
+
+// Spec: https://w3c.github.io/IndexedDB/#abort-transaction
+
+'use strict';
+
+promise_test(
+ testCase => {
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(() => {
+ return new Promise((resolve, reject) => {
+ const request = indexedDB.open(databaseName(testCase), 2);
+ request.onupgradeneeded = testCase.step_func(event => {
+ const database = event.target.result;
+ const transaction = event.target.transaction;
+ const store = transaction.objectStore('books');
+ const request2 =
+ store.put({title: 'Bedrock Nights II', author: 'Barney'});
+ request2.onerror = testCase.unreached_func(
+ 'IDBObjectStore.put() should not receive an error request');
+ request2.onsuccess = testCase.step_func(event => {
+ assert_equals(
+ event.target.result, 345679,
+ 'The key generator\'s current number should be set by ' +
+ 'the last put operation in the database creation ' +
+ 'transaction');
+
+ request.onerror = event => {
+ event.preventDefault();
+ resolve(event);
+ };
+ request.onsuccess = () => reject(new Error(
+ 'indexedDB.open should not succeed after the ' +
+ 'versionchange transaction is aborted'));
+
+ transaction.abort();
+ });
+ });
+ request.onerror = event => reject(event.target.error);
+ request.onsuccess = () => reject(new Error(
+ 'indexedDB.open should not succeed without creating a ' +
+ 'versionchange transaction'));
+ });
+ })
+ .then(() => {
+ return openDatabase(testCase, 1);
+ })
+ .then(database => {
+ const transaction = database.transaction(['books'], 'readwrite');
+ const store = transaction.objectStore('books');
+
+ return checkStoreGenerator(
+ testCase, store, 345679,
+ 'The key generator\'s current number should be reverted after the ' +
+ 'transaction modifying it is aborted')
+ .then(() => database.close());
+ });
+ },
+ 'The current number of a key generator is reverted when a versionchange ' +
+ 'transaction aborts');
+
+promise_test(
+ testCase => {
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ })
+ .then(database => {
+ return new Promise((resolve, reject) => {
+ const transaction =
+ database.transaction(['books'], 'readwrite');
+ const store = transaction.objectStore('books');
+ const request = store.put(
+ {title: 'Bedrock Nights II', author: 'Barney'});
+ request.onerror = testCase.unreached_func(
+ 'IDBObjectStore.put() should not receive an error request');
+ request.onsuccess = testCase.step_func(event => {
+ assert_equals(
+ event.target.result, 345679,
+ 'The key generator\'s current number should be set by the ' +
+ 'last put operation in the database creation transaction');
+
+ transaction.onabort = event => {
+ event.preventDefault();
+ resolve(event);
+ };
+ transaction.abort();
+ });
+ transaction.onabort = () => reject(new Error(
+ 'The aborted readwrite transaction should not receive an ' +
+ 'abort event before IDBTransaction.abort() is called'));
+ transaction.oncomplete = () => reject(new Error(
+ 'The aborted readwrite transaction should not receive a ' +
+ 'completed event'));
+ transaction.onerror = () => reject(new Error(
+ 'The aborted readwrite transaction should not receive an ' +
+ 'error event'));
+ })
+ .then(() => database);
+ })
+ .then(database => {
+ const transaction = database.transaction(['books'], 'readwrite');
+ const store = transaction.objectStore('books');
+
+ return checkStoreGenerator(
+ testCase, store, 345679,
+ 'The key generator\'s current number should be reverted after the ' +
+ 'transaction modifying it is aborted')
+ .then(() => database.close());
+ });
+ },
+ 'The current number of a key generator is reverted when a readwrite ' +
+ 'transaction aborts');
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.html
new file mode 100644
index 00000000000..7a84aecd899
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>IndexedDB: aborting transactions reverts index metadata</title>
+<script>
+self.GLOBAL = {
+ isWindow: function() { return true; },
+ isWorker: function() { return false; },
+ isShadowRealm: function() { return false; },
+};
+</script>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/support-promises.js"></script>
+<script src="resources/support.js"></script>
+<div id=log></div>
+<script src="../IndexedDB/transaction-abort-index-metadata-revert.any.js"></script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.js b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.js
new file mode 100644
index 00000000000..9b429795c48
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.js
@@ -0,0 +1,338 @@
+// META: title=IndexedDB: aborting transactions reverts index metadata
+// META: global=window,worker
+// META: script=resources/support-promises.js
+// META: script=resources/support.js
+
+// Spec: https://w3c.github.io/IndexedDB/#abort-transaction
+
+'use strict';
+
+promise_test(
+ testCase => {
+ let store = null;
+ let index = null;
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(
+ () => migrateDatabase(
+ testCase, 2,
+ (database, transaction) => {
+ store = createNotBooksStore(testCase, database);
+ index = store.index('not_by_author');
+ assert_array_equals(
+ store.indexNames, ['not_by_author', 'not_by_title'],
+ 'IDBObjectStore.indexNames should include newly created indexes ' +
+ 'before the transaction is aborted');
+
+ transaction.abort();
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is marked for deletion, immediately after ' +
+ 'IDBTransaction.abort() returns');
+ assert_array_equals(
+ store.indexNames, [],
+ 'IDBObjectStore.indexNames should stop including the newly ' +
+ 'created indexes immediately after IDBTransaction.abort() returns');
+ }))
+ .then(() => {
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is marked for deletion, after the transaction is ' +
+ 'aborted');
+ assert_array_equals(
+ store.indexNames, [],
+ 'IDBObjectStore.indexNames should stop including the newly ' +
+ 'created indexes after the transaction is aborted');
+ });
+ },
+ 'Created stores get their indexes marked as deleted after the transaction ' +
+ 'that created them aborts');
+
+promise_test(
+ testCase => {
+ let store = null;
+ let index = null;
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ createNotBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(
+ () => migrateDatabase(
+ testCase, 2,
+ (database, transaction) => {
+ store = transaction.objectStore('not_books');
+ index = store.index('not_by_author');
+
+ database.deleteObjectStore('not_books');
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is marked for deletion, immediately after ' +
+ 'IDBDatabase.deleteObjectStore() returns');
+ assert_array_equals(
+ store.indexNames, [],
+ 'IDBObjectStore.indexNames should be empty immediately after ' +
+ 'IDBDatabase.deleteObjectStore() returns');
+
+ transaction.abort();
+ assert_throws_dom(
+ 'TransactionInactiveError', () => index.get('query'),
+ 'IDBIndex.get should throw TransactionInactiveError, indicating ' +
+ 'that the index is no longer marked for deletion, immediately ' +
+ 'after IDBTransaction.abort() returns');
+ assert_array_equals(
+ store.indexNames, ['not_by_author', 'not_by_title'],
+ 'IDBObjectStore.indexNames should include the deleted indexes ' +
+ 'immediately after IDBTransaction.abort() returns');
+ }))
+ .then(() => {
+ assert_throws_dom(
+ 'TransactionInactiveError', () => index.get('query'),
+ 'IDBIndex.get should throw TransactionInactiveError, indicating ' +
+ 'that the index is no longer marked for deletion, after the ' +
+ 'transaction is aborted');
+ assert_array_equals(
+ store.indexNames, ['not_by_author', 'not_by_title'],
+ 'IDBObjectStore.indexNames should include the deleted indexes ' +
+ 'after the transaction is aborted');
+ });
+ },
+ 'Deleted stores get their indexes marked as not-deleted after the ' +
+ 'transaction that deleted them aborts');
+
+promise_test(
+ testCase => {
+ let store = null;
+ let index = null;
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(
+ () => migrateDatabase(
+ testCase, 2,
+ (database, transaction) => {
+ store = createNotBooksStore(testCase, database);
+ index = store.index('not_by_author');
+ assert_array_equals(
+ store.indexNames, ['not_by_author', 'not_by_title'],
+ 'IDBObjectStore.indexNames should include newly created indexes ' +
+ 'before the transaction is aborted');
+
+ database.deleteObjectStore('not_books');
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is marked for deletion, immediately after ' +
+ 'IDBDatabase.deleteObjectStore() returns');
+ assert_array_equals(
+ store.indexNames, [],
+ 'IDBObjectStore.indexNames should be empty immediately after ' +
+ 'IDBDatabase.deleteObjectStore() returns');
+
+ transaction.abort();
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is still marked for deletion, immediately after ' +
+ 'IDBTransaction.abort() returns');
+ assert_array_equals(
+ store.indexNames, [],
+ 'IDBObjectStore.indexNames should not include the newly ' +
+ 'created indexes immediately after IDBTransaction.abort() returns');
+ }))
+ .then(() => {
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is still marked for deletion, after the transaction ' +
+ 'is aborted');
+ assert_array_equals(
+ store.indexNames, [],
+ 'IDBObjectStore.indexNames should not include the newly ' +
+ 'created indexes after the transaction is aborted');
+ });
+ },
+ 'Created+deleted stores still have their indexes marked as deleted after ' +
+ 'the transaction aborts');
+
+promise_test(testCase => {
+ let store = null;
+ let index = null;
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ createNotBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(
+ () => migrateDatabase(
+ testCase, 2,
+ (database, transaction) => {
+ store = transaction.objectStore('not_books');
+ index = store.createIndex('not_by_isbn', 'isbn');
+ assert_array_equals(
+ store.indexNames,
+ ['not_by_author', 'not_by_isbn', 'not_by_title'],
+ 'IDBObjectStore.indexNames should include newly created indexes ' +
+ 'before the transaction is aborted');
+
+ transaction.abort();
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is marked for deletion, immediately after ' +
+ 'IDBTransaction.abort() returns');
+ assert_array_equals(
+ store.indexNames, ['not_by_author', 'not_by_title'],
+ 'IDBObjectStore.indexNames should stop including the newly ' +
+ 'created index immediately after IDBTransaction.abort() returns');
+ }))
+ .then(() => {
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is marked for deletion, after the transaction is ' +
+ 'aborted');
+ assert_array_equals(
+ store.indexNames, ['not_by_author', 'not_by_title'],
+ 'IDBObjectStore.indexNames should stop including the newly ' +
+ 'created index after the transaction is aborted');
+ });
+}, 'Created indexes get marked as deleted after their transaction aborts');
+
+promise_test(testCase => {
+ let store = null;
+ let index = null;
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ createNotBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(
+ () => migrateDatabase(
+ testCase, 2,
+ (database, transaction) => {
+ store = transaction.objectStore('not_books');
+ index = store.index('not_by_author');
+
+ store.deleteIndex('not_by_author');
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is marked for deletion, immediately after ' +
+ 'IDBObjectStore.deleteIndex() returns');
+ assert_array_equals(
+ store.indexNames, ['not_by_title'],
+ 'IDBObjectStore.indexNames should not include the deleted index ' +
+ 'immediately after IDBObjectStore.deleteIndex() returns');
+
+ transaction.abort();
+ assert_throws_dom(
+ 'TransactionInactiveError', () => index.get('query'),
+ 'IDBIndex.get should throw TransactionInactiveError, indicating ' +
+ 'that the index is no longer marked for deletion, immediately ' +
+ 'after IDBTransaction.abort() returns');
+ assert_array_equals(
+ store.indexNames, ['not_by_author', 'not_by_title'],
+ 'IDBObjectStore.indexNames should include the deleted indexes ' +
+ 'immediately after IDBTransaction.abort() returns');
+ }))
+ .then(() => {
+ assert_throws_dom(
+ 'TransactionInactiveError', () => index.get('query'),
+ 'IDBIndex.get should throw TransactionInactiveError, indicating ' +
+ 'that the index is no longer marked for deletion, after the ' +
+ 'transaction is aborted');
+ assert_array_equals(
+ store.indexNames, ['not_by_author', 'not_by_title'],
+ 'IDBObjectStore.indexNames should include the deleted indexes ' +
+ 'after the transaction is aborted');
+ });
+}, 'Deleted indexes get marked as not-deleted after the transaction aborts');
+
+promise_test(
+ testCase => {
+ let store = null;
+ let index = null;
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ createNotBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(
+ () => migrateDatabase(
+ testCase, 2,
+ (database, transaction) => {
+ store = transaction.objectStore('not_books');
+ index = store.createIndex('not_by_isbn', 'isbn');
+ assert_array_equals(
+ store.indexNames,
+ ['not_by_author', 'not_by_isbn', 'not_by_title'],
+ 'IDBObjectStore.indexNames should include newly created indexes ' +
+ 'before the transaction is aborted');
+
+ store.deleteIndex('not_by_isbn');
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is marked for deletion, immediately after ' +
+ 'IDBObjectStore.deleteIndex() returns');
+ assert_array_equals(
+ store.indexNames, ['not_by_author', 'not_by_title'],
+ 'IDBObjectStore.indexNames should not include the deleted index ' +
+ 'immediately after IDBObjectStore.deleteIndex() returns');
+
+ transaction.abort();
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is still marked for deletion, immediately after ' +
+ 'IDBTransaction.abort() returns');
+ assert_array_equals(
+ store.indexNames, ['not_by_author', 'not_by_title'],
+ 'IDBObjectStore.indexNames should stop including the newly ' +
+ 'created index immediately after IDBTransaction.abort() returns');
+ }))
+ .then(() => {
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is marked for deletion, after the transaction is ' +
+ 'aborted');
+ assert_array_equals(
+ store.indexNames, ['not_by_author', 'not_by_title'],
+ 'IDBObjectStore.indexNames should stop including the newly ' +
+ 'created index after the transaction is aborted');
+ });
+ },
+ 'Created+deleted indexes are still marked as deleted after their ' +
+ 'transaction aborts');
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.html
new file mode 100644
index 00000000000..d36f82041bf
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.html
@@ -0,0 +1,9 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>IndexedDB: aborting transactions reverts index metadata</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<div id=log></div>
+<script>
+fetch_tests_from_worker(new Worker("../IndexedDB/transaction-abort-index-metadata-revert.any.worker.js"));
+</script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.js b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.js
new file mode 100644
index 00000000000..89500e1c573
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-index-metadata-revert.any.worker.js
@@ -0,0 +1,12 @@
+
+self.GLOBAL = {
+ isWindow: function() { return false; },
+ isWorker: function() { return true; },
+ isShadowRealm: function() { return false; },
+};
+importScripts("/resources/testharness.js");
+self.META_TITLE = "IndexedDB: aborting transactions reverts index metadata";
+importScripts("resources/support-promises.js")
+importScripts("resources/support.js")
+importScripts("/IndexedDB/transaction-abort-index-metadata-revert.any.js");
+done();
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-multiple-metadata-revert.any.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-multiple-metadata-revert.any.html
new file mode 100644
index 00000000000..b3f6680b903
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-multiple-metadata-revert.any.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>IndexedDB: aborting transactions reverts multiple operations on the same metadata</title>
+<script>
+self.GLOBAL = {
+ isWindow: function() { return true; },
+ isWorker: function() { return false; },
+ isShadowRealm: function() { return false; },
+};
+</script>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/support-promises.js"></script>
+<script src="resources/support.js"></script>
+<div id=log></div>
+<script src="../IndexedDB/transaction-abort-multiple-metadata-revert.any.js"></script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-multiple-metadata-revert.any.js b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-multiple-metadata-revert.any.js
new file mode 100644
index 00000000000..9161af8e2ba
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-multiple-metadata-revert.any.js
@@ -0,0 +1,325 @@
+// META: title=IndexedDB: aborting transactions reverts multiple operations on the same metadata
+// META: global=window,worker
+// META: script=resources/support-promises.js
+// META: script=resources/support.js
+
+// Spec: https://w3c.github.io/IndexedDB/#abort-transaction
+
+'use strict';
+
+promise_test(
+ testCase => {
+ let store = null;
+ let index = null;
+ let migrationTransaction = null;
+ let migrationDatabase = null;
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(
+ () => migrateDatabase(
+ testCase, 2,
+ (database, transaction) => {
+ store = createNotBooksStore(testCase, database);
+ migrationDatabase = database;
+ migrationTransaction = transaction;
+ assert_array_equals(
+ database.objectStoreNames, ['books', 'not_books'],
+ 'IDBDatabase.objectStoreNames should include a newly created ' +
+ 'store before the transaction is aborted');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books', 'not_books'],
+ 'IDBTransaction.objectStoreNames should include a newly created ' +
+ 'store before the transaction is aborted');
+
+ index = store.index('not_by_author');
+ store.deleteIndex('not_by_author');
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is marked for deletion, immediately after ' +
+ 'IDBObjectStore.deleteIndex() returns');
+ assert_array_equals(
+ store.indexNames, ['not_by_title'],
+ 'IDBObjectStore.indexNames should not include the deleted index ' +
+ 'immediately after IDBObjectStore.deleteIndex() returns');
+
+ transaction.abort();
+ assert_throws_dom(
+ 'InvalidStateError', () => store.get('query'),
+ 'IDBObjectStore.get should throw InvalidStateError, indicating ' +
+ 'that the store is marked for deletion, immediately after ' +
+ 'IDBTransaction.abort() returns');
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is still marked for deletion, immediately after ' +
+ 'IDBTransaction.abort() returns');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books'],
+ 'IDBTransaction.objectStoreNames should stop including the newly ' +
+ 'created store immediately after IDBTransaction.abort() returns');
+ assert_array_equals(
+ database.objectStoreNames, ['books'],
+ 'IDBDatabase.objectStoreNames should stop including the newly ' +
+ 'created store immediately after IDBTransaction.abort() returns');
+ assert_array_equals(
+ store.indexNames, [],
+ 'IDBObjectStore.indexNames for the newly created store should be ' +
+ 'empty immediately after IDBTransaction.abort() returns');
+ }))
+ .then(() => {
+ assert_throws_dom(
+ 'InvalidStateError', () => store.get('query'),
+ 'IDBObjectStore.get should throw InvalidStateError, indicating ' +
+ 'that the store is marked for deletion, after the transaction is ' +
+ 'aborted');
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is still marked for deletion, after the transaction ' +
+ 'is aborted');
+ assert_array_equals(
+ migrationDatabase.objectStoreNames, ['books'],
+ 'IDBDatabase.objectStoreNames should stop including the newly ' +
+ 'created store after the transaction is aborted');
+ assert_array_equals(
+ migrationTransaction.objectStoreNames, ['books'],
+ 'IDBTransaction.objectStoreNames should stop including the newly ' +
+ 'created store after the transaction is aborted');
+ assert_array_equals(
+ store.indexNames, [],
+ 'IDBObjectStore.indexNames for the newly created store should be ' +
+ 'empty after the transaction is aborted');
+ });
+ },
+ 'Deleted indexes in newly created stores are still marked as deleted ' +
+ 'after the transaction aborts');
+
+promise_test(
+ testCase => {
+ let store = null;
+ let index = null;
+ let migrationTransaction = null;
+ let migrationDatabase = null;
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ createNotBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(
+ () => migrateDatabase(
+ testCase, 2,
+ (database, transaction) => {
+ migrationDatabase = database;
+ migrationTransaction = transaction;
+ store = transaction.objectStore('not_books');
+ index = store.index('not_by_author');
+ store.deleteIndex('not_by_author');
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is marked for deletion, immediately after ' +
+ 'IDBObjectStore.deleteIndex() returns');
+ assert_array_equals(
+ store.indexNames, ['not_by_title'],
+ 'IDBObjectStore.indexNames should not include the deleted index ' +
+ 'immediately after IDBObjectStore.deleteIndex() returns');
+
+ database.deleteObjectStore('not_books');
+ assert_throws_dom(
+ 'InvalidStateError', () => store.get('query'),
+ 'IDBObjectStore.get should throw InvalidStateError, indicating ' +
+ 'that the store is marked for deletion, immediately after ' +
+ 'IDBDatabase.deleteObjectStore() returns');
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is still marked for deletion, immediately after ' +
+ 'IDBObjectStore.deleteIndex() returns');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books'],
+ 'IDBTransaction.objectStoreNames should stop including the ' +
+ 'deleted store immediately after IDBDatabase.deleteObjectStore() ' +
+ 'returns');
+ assert_array_equals(
+ database.objectStoreNames, ['books'],
+ 'IDBDatabase.objectStoreNames should stop including the newly ' +
+ 'created store immediately after IDBDatabase.deleteObjectStore() ' +
+ 'returns');
+ assert_array_equals(
+ store.indexNames, [],
+ 'IDBObjectStore.indexNames for the deleted store should be empty ' +
+ 'immediately after IDBDatabase.deleteObjectStore() returns');
+
+ transaction.abort();
+ assert_throws_dom(
+ 'TransactionInactiveError', () => store.get('query'),
+ 'IDBObjectStore.get should throw TransactionInactiveError, ' +
+ 'indicating that the store is no longer marked for deletion, ' +
+ 'immediately after IDBTransaction.abort() returns');
+ assert_throws_dom(
+ 'TransactionInactiveError', () => index.get('query'),
+ 'IDBIndex.get should throw TransactionInactiveError, indicating ' +
+ 'that the index is no longer marked for deletion, immediately ' +
+ 'after IDBObjectStore.deleteIndex() returns');
+ assert_array_equals(
+ database.objectStoreNames, ['books', 'not_books'],
+ 'IDBDatabase.objectStoreNames should include the deleted store ' +
+ 'store immediately after IDBTransaction.abort() returns');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books', 'not_books'],
+ 'IDBTransaction.objectStoreNames should include the deleted ' +
+ 'store immediately after IDBTransaction.abort() returns');
+ assert_array_equals(
+ store.indexNames, ['not_by_author', 'not_by_title'],
+ 'IDBObjectStore.indexNames for the deleted store should not be ' +
+ 'empty any more immediately after IDBTransaction.abort() returns');
+ }))
+ .then(() => {
+ assert_throws_dom(
+ 'TransactionInactiveError', () => store.get('query'),
+ 'IDBObjectStore.get should throw TransactionInactiveError, ' +
+ 'indicating that the store is no longer marked for deletion, ' +
+ 'after the transaction is aborted');
+ assert_throws_dom(
+ 'TransactionInactiveError', () => index.get('query'),
+ 'IDBIndex.get should throw TransactionInactiveError, indicating ' +
+ 'that the index is no longer marked for deletion, after the ' +
+ 'transaction is aborted');
+ assert_array_equals(
+ migrationDatabase.objectStoreNames, ['books', 'not_books'],
+ 'IDBDatabase.objectStoreNames should include the previously ' +
+ 'deleted store after the transaction is aborted');
+ assert_array_equals(
+ migrationTransaction.objectStoreNames, ['books', 'not_books'],
+ 'IDBTransaction.objectStoreNames should include the previously ' +
+ 'deleted store after the transaction is aborted');
+ assert_array_equals(
+ store.indexNames, ['not_by_author', 'not_by_title'],
+ 'IDBObjectStore.indexNames for the deleted store should not be ' +
+ 'empty after the transaction is aborted');
+ });
+ },
+ 'Deleted indexes in deleted stores are still marked as not-deleted after ' +
+ 'the transaction aborts');
+
+promise_test(
+ testCase => {
+ let store = null;
+ let index = null;
+ let migrationTransaction = null;
+ let migrationDatabase = null;
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(
+ () => migrateDatabase(
+ testCase, 2,
+ (database, transaction) => {
+ store = createNotBooksStore(testCase, database);
+ migrationDatabase = database;
+ migrationTransaction = transaction;
+ index = store.index('not_by_author');
+ store.deleteIndex('not_by_author');
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is marked for deletion, immediately after ' +
+ 'IDBObjectStore.deleteIndex() returns');
+ assert_array_equals(
+ store.indexNames, ['not_by_title'],
+ 'IDBObjectStore.indexNames should not include the deleted index ' +
+ 'immediately after IDBObjectStore.deleteIndex() returns');
+
+ database.deleteObjectStore('not_books');
+ assert_throws_dom(
+ 'InvalidStateError', () => store.get('query'),
+ 'IDBObjectStore.get should throw InvalidStateError, indicating ' +
+ 'that the store is marked for deletion, immediately after ' +
+ 'IDBDatabase.deleteObjectStore() returns');
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is still marked for deletion, immediately after ' +
+ 'IDBDatabase.deleteObjectStore() returns');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books'],
+ 'IDBTransaction.objectStoreNames should stop including the ' +
+ 'deleted store immediately after IDBDatabase.deleteObjectStore() ' +
+ 'returns');
+ assert_array_equals(
+ database.objectStoreNames, ['books'],
+ 'IDBDatabase.objectStoreNames should stop including the newly ' +
+ 'created store immediately after IDBDatabase.deleteObjectStore() ' +
+ 'returns');
+ assert_array_equals(
+ store.indexNames, [],
+ 'IDBObjectStore.indexNames should be empty immediately after ' +
+ 'IDBDatabase.deleteObjectStore() returns');
+
+ transaction.abort();
+ assert_throws_dom(
+ 'InvalidStateError', () => store.get('query'),
+ 'IDBObjectStore.get should throw InvalidStateError, indicating ' +
+ 'that the store is still marked for deletion, immediately after ' +
+ 'IDBTransaction.abort() returns');
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is still marked for deletion, immediately after ' +
+ 'IDBTransaction.abort() returns');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books'],
+ 'IDBTransaction.objectStoreNames should not include the newly ' +
+ 'created store immediately after IDBTransaction.abort() returns');
+ assert_array_equals(
+ database.objectStoreNames, ['books'],
+ 'IDBDatabase.objectStoreNames should not include the newly ' +
+ 'created store immediately after IDBTransaction.abort() returns');
+ assert_array_equals(
+ store.indexNames, [],
+ 'IDBObjectStore.indexNames should be empty immediately after ' +
+ 'IDBTransaction.abort() returns');
+ }))
+ .then(() => {
+ assert_throws_dom(
+ 'InvalidStateError', () => store.get('query'),
+ 'IDBObjectStore.get should throw InvalidStateError, indicating ' +
+ 'that the store is still marked for deletion, after the ' +
+ 'transaction is aborted');
+ assert_throws_dom(
+ 'InvalidStateError', () => index.get('query'),
+ 'IDBIndex.get should throw InvalidStateError, indicating that ' +
+ 'the index is still marked for deletion, after the transaction ' +
+ 'is aborted');
+ assert_array_equals(
+ migrationDatabase.objectStoreNames, ['books'],
+ 'IDBDatabase.objectStoreNames should not include the newly ' +
+ 'created store after the transaction is aborted');
+ assert_array_equals(
+ migrationTransaction.objectStoreNames, ['books'],
+ 'IDBTransaction.objectStoreNames should not include the newly ' +
+ 'created store after the transaction is aborted');
+ assert_array_equals(
+ store.indexNames, [],
+ 'IDBObjectStore.indexNames should be empty after the transaction ' +
+ 'is aborted');
+ });
+ },
+ 'Deleted indexes in created+deleted stores are still marked as deleted ' +
+ 'after their transaction aborts');
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-object-store-metadata-revert.any.html b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-object-store-metadata-revert.any.html
new file mode 100644
index 00000000000..c7164bb79c0
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-object-store-metadata-revert.any.html
@@ -0,0 +1,16 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>IndexedDB: aborting transactions reverts object store metadata</title>
+<script>
+self.GLOBAL = {
+ isWindow: function() { return true; },
+ isWorker: function() { return false; },
+ isShadowRealm: function() { return false; },
+};
+</script>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/support-promises.js"></script>
+<script src="resources/support.js"></script>
+<div id=log></div>
+<script src="../IndexedDB/transaction-abort-object-store-metadata-revert.any.js"></script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-object-store-metadata-revert.any.js b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-object-store-metadata-revert.any.js
new file mode 100644
index 00000000000..d5f14b54de4
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/IndexedDB/transaction-abort-object-store-metadata-revert.any.js
@@ -0,0 +1,274 @@
+// META: title=IndexedDB: aborting transactions reverts object store metadata
+// META: global=window,worker
+// META: script=resources/support-promises.js
+// META: script=resources/support.js
+
+// Spec: https://w3c.github.io/IndexedDB/#abort-transaction
+
+'use strict';
+
+promise_test(testCase => {
+ let store = null;
+ let migrationTransaction = null;
+ let migrationDatabase = null;
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(
+ () => migrateDatabase(
+ testCase, 2,
+ (database, transaction) => {
+ store = createNotBooksStore(testCase, database);
+ migrationDatabase = database;
+ migrationTransaction = transaction;
+ assert_array_equals(
+ database.objectStoreNames, ['books', 'not_books'],
+ 'IDBDatabase.objectStoreNames should include a newly created ' +
+ 'store before the transaction is aborted');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books', 'not_books'],
+ 'IDBTransaction.objectStoreNames should include a newly created ' +
+ 'store before the transaction is aborted');
+
+ transaction.abort();
+ assert_throws_dom(
+ 'InvalidStateError', () => store.get('query'),
+ 'IDBObjectStore.get should throw InvalidStateError, indicating ' +
+ 'that the store is marked for deletion, immediately after ' +
+ 'IDBTransaction.abort() returns');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books'],
+ 'IDBTransaction.objectStoreNames should stop including the newly ' +
+ 'created store immediately after IDBTransaction.abort() returns');
+ assert_array_equals(
+ database.objectStoreNames, ['books'],
+ 'IDBDatabase.objectStoreNames should stop including the newly ' +
+ 'created store immediately after IDBTransaction.abort() returns');
+ }))
+ .then(() => {
+ assert_throws_dom(
+ 'InvalidStateError', () => store.get('query'),
+ 'IDBObjectStore.get should throw InvalidStateError, indicating ' +
+ 'that the store is marked for deletion, after the transaction is ' +
+ 'aborted');
+ assert_array_equals(
+ migrationDatabase.objectStoreNames, ['books'],
+ 'IDBDatabase.objectStoreNames should stop including the newly ' +
+ 'created store after the transaction is aborted');
+ assert_array_equals(
+ migrationTransaction.objectStoreNames, ['books'],
+ 'IDBTransaction.objectStoreNames should stop including the newly ' +
+ 'created store after the transaction is aborted');
+ });
+}, 'Created stores get marked as deleted after their transaction aborts');
+
+promise_test(testCase => {
+ let store = null;
+ let migrationTransaction = null;
+ let migrationDatabase = null;
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ createNotBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(
+ () => migrateDatabase(
+ testCase, 2,
+ (database, transaction) => {
+ migrationDatabase = database;
+ migrationTransaction = transaction;
+ store = transaction.objectStore('not_books');
+
+ database.deleteObjectStore('not_books');
+ assert_throws_dom(
+ 'InvalidStateError', () => store.get('query'),
+ 'IDBObjectStore.get should throw InvalidStateError, indicating ' +
+ 'that the store is marked for deletion, immediately after ' +
+ 'IDBDatabase.deleteObjectStore() returns');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books'],
+ 'IDBTransaction.objectStoreNames should stop including the ' +
+ 'deleted store immediately after IDBDatabase.deleteObjectStore() ' +
+ 'returns');
+ assert_array_equals(
+ database.objectStoreNames, ['books'],
+ 'IDBDatabase.objectStoreNames should stop including the newly ' +
+ 'created store immediately after IDBDatabase.deleteObjectStore() ' +
+ 'returns');
+
+ transaction.abort();
+ assert_throws_dom(
+ 'TransactionInactiveError', () => store.get('query'),
+ 'IDBObjectStore.get should throw TransactionInactiveError, ' +
+ 'indicating that the store is no longer marked for deletion, ' +
+ 'immediately after IDBTransaction.abort() returns');
+ assert_array_equals(
+ database.objectStoreNames, ['books', 'not_books'],
+ 'IDBDatabase.objectStoreNames should include the deleted store ' +
+ 'store immediately after IDBTransaction.abort() returns');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books', 'not_books'],
+ 'IDBTransaction.objectStoreNames should include the deleted ' +
+ 'store immediately after IDBTransaction.abort() returns');
+ }))
+ .then(() => {
+ assert_throws_dom(
+ 'TransactionInactiveError', () => store.get('query'),
+ 'IDBObjectStore.get should throw TransactionInactiveError, ' +
+ 'indicating that the store is no longer marked for deletion, ' +
+ 'after the transaction is aborted');
+ assert_array_equals(
+ migrationDatabase.objectStoreNames, ['books', 'not_books'],
+ 'IDBDatabase.objectStoreNames should include the previously ' +
+ 'deleted store after the transaction is aborted');
+ assert_array_equals(
+ migrationTransaction.objectStoreNames, ['books', 'not_books'],
+ 'IDBTransaction.objectStoreNames should include the previously ' +
+ 'deleted store after the transaction is aborted');
+ });
+}, 'Deleted stores get marked as not-deleted after the transaction aborts');
+
+promise_test(
+ testCase => {
+ let store = null;
+ let migrationTransaction = null;
+ let migrationDatabase = null;
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(
+ () => migrateDatabase(
+ testCase, 2,
+ (database, transaction) => {
+ store = createNotBooksStore(testCase, database);
+ migrationDatabase = database;
+ migrationTransaction = transaction;
+ assert_array_equals(
+ database.objectStoreNames, ['books', 'not_books'],
+ 'IDBDatabase.objectStoreNames should include a newly created ' +
+ 'store before the transaction is aborted');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books', 'not_books'],
+ 'IDBTransaction.objectStoreNames should include a newly created ' +
+ 'store before the transaction is aborted');
+
+ database.deleteObjectStore('not_books');
+ assert_throws_dom(
+ 'InvalidStateError', () => store.get('query'),
+ 'IDBObjectStore.get should throw InvalidStateError, indicating ' +
+ 'that the store is marked for deletion, immediately after ' +
+ 'IDBDatabase.deleteObjectStore() returns');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books'],
+ 'IDBTransaction.objectStoreNames should stop including the ' +
+ 'deleted store immediately after IDBDatabase.deleteObjectStore() ' +
+ 'returns');
+ assert_array_equals(
+ database.objectStoreNames, ['books'],
+ 'IDBDatabase.objectStoreNames should stop including the newly ' +
+ 'created store immediately after IDBDatabase.deleteObjectStore() ' +
+ 'returns');
+
+ transaction.abort();
+ assert_throws_dom(
+ 'InvalidStateError', () => store.get('query'),
+ 'IDBObjectStore.get should throw InvalidStateError, indicating ' +
+ 'that the store is still marked for deletion, immediately after ' +
+ 'IDBTransaction.abort() returns');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books'],
+ 'IDBTransaction.objectStoreNames should not include the newly ' +
+ 'created store immediately after IDBTransaction.abort() returns');
+ assert_array_equals(
+ database.objectStoreNames, ['books'],
+ 'IDBDatabase.objectStoreNames should not include the newly ' +
+ 'created store immediately after IDBTransaction.abort() returns');
+ }))
+ .then(() => {
+ assert_throws_dom(
+ 'InvalidStateError', () => store.get('query'),
+ 'IDBObjectStore.get should throw InvalidStateError, indicating ' +
+ 'that the store is still marked for deletion, after the ' +
+ 'transaction is aborted');
+ assert_array_equals(
+ migrationDatabase.objectStoreNames, ['books'],
+ 'IDBDatabase.objectStoreNames should not include the newly ' +
+ 'created store after the transaction is aborted');
+ assert_array_equals(
+ migrationTransaction.objectStoreNames, ['books'],
+ 'IDBTransaction.objectStoreNames should not include the newly ' +
+ 'created store after the transaction is aborted');
+ });
+ },
+ 'Created+deleted stores are still marked as deleted after their ' +
+ 'transaction aborts');
+
+promise_test(
+ testCase => {
+ let migrationTransaction = null;
+ let migrationDatabase = null;
+ return createDatabase(
+ testCase,
+ (database, transaction) => {
+ createBooksStore(testCase, database);
+ createNotBooksStore(testCase, database);
+ })
+ .then(database => {
+ database.close();
+ })
+ .then(
+ () => migrateDatabase(
+ testCase, 2,
+ (database, transaction) => {
+ migrationDatabase = database;
+ migrationTransaction = transaction;
+
+ database.deleteObjectStore('not_books');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books'],
+ 'IDBTransaction.objectStoreNames should stop including the ' +
+ 'deleted store immediately after IDBDatabase.deleteObjectStore() ' +
+ 'returns');
+ assert_array_equals(
+ database.objectStoreNames, ['books'],
+ 'IDBDatabase.objectStoreNames should stop including the newly ' +
+ 'created store immediately after IDBDatabase.deleteObjectStore() ' +
+ 'returns');
+
+ transaction.abort();
+ assert_array_equals(
+ database.objectStoreNames, ['books', 'not_books'],
+ 'IDBDatabase.objectStoreNames should include the deleted store ' +
+ 'store immediately after IDBTransaction.abort() returns');
+ assert_array_equals(
+ transaction.objectStoreNames, ['books', 'not_books'],
+ 'IDBTransaction.objectStoreNames should include the deleted ' +
+ 'store immediately after IDBTransaction.abort() returns');
+ }))
+ .then(() => {
+ assert_array_equals(
+ migrationDatabase.objectStoreNames, ['books', 'not_books'],
+ 'IDBDatabase.objectStoreNames should include the previously ' +
+ 'deleted store after the transaction is aborted');
+ assert_array_equals(
+ migrationTransaction.objectStoreNames, ['books', 'not_books'],
+ 'IDBTransaction.objectStoreNames should include the previously ' +
+ 'deleted store after the transaction is aborted');
+ });
+ },
+ 'Un-instantiated deleted stores get marked as not-deleted after the ' +
+ 'transaction aborts');