From da4c7e7ed675c3bf405668739c3012d140856109 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:42 +0200 Subject: Adding upstream version 126.0. Signed-off-by: Daniel Baumann --- .../IndexedDB/idbdatabase_deleteObjectStore.any.js | 89 +++++++++ .../IndexedDB/idbdatabase_deleteObjectStore.htm | 25 --- .../IndexedDB/idbdatabase_deleteObjectStore3.htm | 23 --- .../idbdatabase_deleteObjectStore4-not_reused.htm | 42 ----- .../tests/IndexedDB/idbobjectstore_delete.any.js | 207 +++++++++++++++++++++ .../tests/IndexedDB/idbobjectstore_delete.htm | 46 ----- .../tests/IndexedDB/idbobjectstore_delete2.htm | 27 --- .../tests/IndexedDB/idbobjectstore_delete3.htm | 47 ----- .../tests/IndexedDB/idbobjectstore_delete4.htm | 48 ----- .../tests/IndexedDB/idbobjectstore_delete5.htm | 32 ---- .../tests/IndexedDB/idbobjectstore_delete6.htm | 36 ---- .../tests/IndexedDB/idbobjectstore_delete7.htm | 27 --- .../IndexedDB/idbobjectstore_deleteIndex.any.js | 42 +++++ .../tests/IndexedDB/idbobjectstore_deleteIndex.htm | 44 ----- .../tests/IndexedDB/idbobjectstore_deleted.htm | 50 ----- .../ready-state-destroyed-execution-context.html | 4 + 16 files changed, 342 insertions(+), 447 deletions(-) create mode 100644 testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore.any.js delete mode 100644 testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore3.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore4-not_reused.htm create mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_delete.any.js delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_delete.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_delete2.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_delete3.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_delete4.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_delete5.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_delete6.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_delete7.htm create mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_deleteIndex.any.js delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_deleteIndex.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_deleted.htm (limited to 'testing/web-platform/tests/IndexedDB') diff --git a/testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore.any.js b/testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore.any.js new file mode 100644 index 0000000000..5288891bd7 --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore.any.js @@ -0,0 +1,89 @@ +// META: global=window,worker +// META: title=IDBDatabase.deleteObjectStore() +// META: script=resources/support.js +// @author Microsoft +// @author Odin Hørthe Omdal + +'use_strict'; + +async_test(t => { + let db; + let add_success = false; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + + const objStore = db.createObjectStore("store", { autoIncrement: true }); + assert_equals(db.objectStoreNames[0], "store", "objectStoreNames"); + + const rq_add = objStore.add(1); + rq_add.onsuccess = function() { add_success = true; }; + rq_add.onerror = fail(t, 'rq_add.error'); + + objStore.createIndex("idx", "a"); + db.deleteObjectStore("store"); + assert_equals(db.objectStoreNames.length, 0, "objectStoreNames.length after delete"); + assert_false(db.objectStoreNames.contains("store")); + + const exc = "InvalidStateError"; + assert_throws_dom(exc, function() { objStore.add(2); }); + assert_throws_dom(exc, function() { objStore.put(3); }); + assert_throws_dom(exc, function() { objStore.get(1); }); + assert_throws_dom(exc, function() { objStore.clear(); }); + assert_throws_dom(exc, function() { objStore.count(); }); + assert_throws_dom(exc, function() { objStore.delete(1); }); + assert_throws_dom(exc, function() { objStore.openCursor(); }); + assert_throws_dom(exc, function() { objStore.index("idx"); }); + assert_throws_dom(exc, function() { objStore.deleteIndex("idx"); }); + assert_throws_dom(exc, function() { objStore.createIndex("idx2", "a"); + }); + }; + + open_rq.onsuccess = function() { + assert_true(add_success, "First add was successful"); + t.done(); + } +}, 'Deleted object store\'s name should be removed from database\'s list. Attempting to use a \ +deleted IDBObjectStore should throw an InvalidStateError'); + +async_test(t => { + const open_rq = createdb(t); + + open_rq.onupgradeneeded = function(e) { + const db = e.target.result; + assert_throws_dom('NotFoundError', function() { db.deleteObjectStore('whatever'); }); + t.done(); + }; +}, 'Attempting to remove an object store that does not exist should throw a NotFoundError'); + +async_test(t => { + const keys = []; + const open_rq = createdb(t); + + open_rq.onupgradeneeded = function(e) { + const db = e.target.result; + + const objStore = db.createObjectStore("resurrected", { autoIncrement: true, keyPath: "k" }); + objStore.add({ k: 5 }).onsuccess = function(e) { keys.push(e.target.result); }; + objStore.add({}).onsuccess = function(e) { keys.push(e.target.result); }; + objStore.createIndex("idx", "i"); + assert_true(objStore.indexNames.contains("idx")); + assert_equals(objStore.keyPath, "k", "keyPath"); + + db.deleteObjectStore("resurrected"); + + const objStore2 = db.createObjectStore("resurrected", { autoIncrement: true }); + objStore2.add("Unicorns'R'us").onsuccess = function(e) { keys.push(e.target.result); }; + assert_false(objStore2.indexNames.contains("idx"), "index exist on new objstore"); + assert_equals(objStore2.keyPath, null, "keyPath"); + + assert_throws_dom("NotFoundError", function() { objStore2.index("idx"); }); + }; + + open_rq.onsuccess = function(e) { + assert_array_equals(keys, [5, 6, 1], "keys"); + t.done(); + }; +}, 'Attempting to access an index that was deleted as part of object store deletion and then \ +recreated using the same object store name should throw a NotFoundError'); diff --git a/testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore.htm b/testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore.htm deleted file mode 100644 index e3f6a775c5..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore.htm +++ /dev/null @@ -1,25 +0,0 @@ - -IDBDatabase.deleteObjectStore() - object store's name is removed from database's list - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore3.htm b/testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore3.htm deleted file mode 100644 index 3ddbe8ec62..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore3.htm +++ /dev/null @@ -1,23 +0,0 @@ - -IDBDatabase.deleteObjectStore() - attempt to remove an object store that does not exist - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore4-not_reused.htm b/testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore4-not_reused.htm deleted file mode 100644 index 0a5e1b83cf..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbdatabase_deleteObjectStore4-not_reused.htm +++ /dev/null @@ -1,42 +0,0 @@ - - -IDBDatabase.deleteObjectStore() - the object store is not reused - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete.any.js b/testing/web-platform/tests/IndexedDB/idbobjectstore_delete.any.js new file mode 100644 index 0000000000..0b731f391d --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/idbobjectstore_delete.any.js @@ -0,0 +1,207 @@ +// META: global=window,worker +// META: title=IDBObjectStore.delete() +// META: script=resources/support.js +// @author Microsoft + +'use_strict'; + +async_test(t => { + let db; + const record = { key: 1, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + + const objStore = db.createObjectStore("test", { keyPath: "key" }); + objStore.add(record); + }; + + open_rq.onsuccess = function(e) { + const delete_rq = db.transaction("test", "readwrite", + { durability: 'relaxed' }) + .objectStore("test") + .delete(record.key); + + delete_rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, undefined); + + e.target.transaction.oncomplete = t.step_func(VerifyRecordRemoved); + }); + }; + + function VerifyRecordRemoved() { + const rq = db.transaction("test", "readonly", + { durability: 'relaxed' }) + .objectStore("test") + .get(record.key); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, undefined); + t.done(); + }); + } +}, 'delete() removes record (inline keys)'); + +async_test(t => { + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + const db = e.target.result; + + const delete_rq = db.createObjectStore("test") + .delete(1); + + delete_rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, undefined); + t.done(); + }); + }; +}, 'delete() key doesn\'t match any records'); + +async_test(t => { + let db; + const record = { test: { obj: { key: 1 } }, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + + const objStore = db.createObjectStore("test", + { keyPath: "test.obj.key" }); + objStore.add(record); + }; + + open_rq.onsuccess = function(e) { + const delete_rq = db.transaction("test", "readwrite", + { durability: 'relaxed' }) + .objectStore("test") + .delete(record.test.obj.key); + + delete_rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, undefined); + + e.target.transaction.oncomplete = t.step_func(VerifyRecordRemoved); + }); + }; + + function VerifyRecordRemoved() { + const rq = db.transaction("test", "readonly", + { durability: 'relaxed' }) + .objectStore("test") + .get(record.test.obj.key); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, undefined); + t.done(); + }); + } +}, 'Object store\'s key path is an object attribute'); + +async_test(t => { + let db; + const key = 1; + const record = { property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + + const objStore = db.createObjectStore("test"); + objStore.add(record, key); + }; + + open_rq.onsuccess = function(e) { + const delete_rq = db.transaction("test", "readwrite", + { durability: 'relaxed' }) + .objectStore("test") + .delete(key); + + delete_rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, undefined); + + e.target.transaction.oncomplete = t.step_func(VerifyRecordRemoved); + }); + }; + + function VerifyRecordRemoved() { + const rq = db.transaction("test", "readonly", + { durability: 'relaxed' }) + .objectStore("test") + .get(key); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, undefined); + t.done(); + }); + } +}, 'delete() removes record (out-of-line keys)'); + +async_test(t => { + let db; + const open_rq = createdb(t); + + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const os = db.createObjectStore("store"); + + for(let i = 0; i < 10; i++) + os.add("data" + i, i); + }; + + open_rq.onsuccess = function (e) { + const os = db.transaction("store", "readwrite", + { durability: 'relaxed' }) + .objectStore("store"); + + os.delete(IDBKeyRange.bound(3, 6)); + os.count().onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, 6, "Count after deleting \ + 3-6 from 10"); + t.done(); + }); + }; +}, 'delete() removes all of the records in the range'); + +async_test(function(t) { + let db; + const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }]; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(event) { + db = event.target.result; + const objStore = db.createObjectStore("store", { keyPath: "pKey" }); + for (let i = 0; i < records.length; i++) { + objStore.add(records[i]); + } + }; + + open_rq.onsuccess = function(event) { + const txn = db.transaction("store", "readonly", + { durability: 'relaxed' }); + const ostore = txn.objectStore("store"); + t.step(function() { + assert_throws_dom("ReadOnlyError", function() { + ostore.delete("primaryKey_0"); + }); + }); + t.done(); + }; +}, 'If the transaction this IDBObjectStore belongs to has its mode set to \ +readonly, throw ReadOnlyError'); + +async_test(t => { + let ostore; + const records = [{ pKey: "primaryKey_0" }, { pKey: "primaryKey_1" }]; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(event) { + const db = event.target.result; + ostore = db.createObjectStore("store", { keyPath: "pKey" }); + db.deleteObjectStore("store"); + assert_throws_dom("InvalidStateError", function() { + ostore.delete("primaryKey_0"); + }); + t.done(); + }; +}, 'If the object store has been deleted, the implementation must throw a \ +DOMException of type InvalidStateError'); diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_delete.htm deleted file mode 100644 index 880309d01a..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete.htm +++ /dev/null @@ -1,46 +0,0 @@ - - -IDBObjectStore.delete() - delete removes record (inline keys) - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete2.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_delete2.htm deleted file mode 100644 index eb71169905..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete2.htm +++ /dev/null @@ -1,27 +0,0 @@ - - -IDBObjectStore.delete() - key doesn't match any records - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete3.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_delete3.htm deleted file mode 100644 index 1ea9dd9958..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete3.htm +++ /dev/null @@ -1,47 +0,0 @@ - - -IDBObjectStore.delete() - object store's key path is an object attribute - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete4.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_delete4.htm deleted file mode 100644 index 9d074bff85..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete4.htm +++ /dev/null @@ -1,48 +0,0 @@ - - -IDBObjectStore.delete() - delete removes record (out-of-line keys) - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete5.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_delete5.htm deleted file mode 100644 index f7696e6efa..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete5.htm +++ /dev/null @@ -1,32 +0,0 @@ - -IDBObjectStore.delete() - removes all of the records in the range - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete6.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_delete6.htm deleted file mode 100644 index 70d8af32fe..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete6.htm +++ /dev/null @@ -1,36 +0,0 @@ - - -IDBObjectStore.delete() - If the transaction this IDBObjectStore belongs to has its mode set to readonly, throw ReadOnlyError - - - - - -
- - diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete7.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_delete7.htm deleted file mode 100644 index a65885cc2b..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_delete7.htm +++ /dev/null @@ -1,27 +0,0 @@ - - -IDBObjectStore.delete() - If the object store has been deleted, the implementation must throw a DOMException of type InvalidStateError - - - - - -
- diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_deleteIndex.any.js b/testing/web-platform/tests/IndexedDB/idbobjectstore_deleteIndex.any.js new file mode 100644 index 0000000000..ed0246e0e7 --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/idbobjectstore_deleteIndex.any.js @@ -0,0 +1,42 @@ +// META: global=window,worker +// META: title=IDBObjectStore.deleteIndex() +// META: script=resources/support.js +// @author Microsoft + +'use_strict'; + +async_test(t => { + let db; + const key = 1; + const record = { property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("test"); + objStore.createIndex("index", "indexedProperty"); + }; + + open_rq.onsuccess = function(e) { + db.close(); + const new_version = createdb(t, db.name, 2); + new_version.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = e.target.transaction.objectStore("test"); + objStore.deleteIndex("index"); + }; + + new_version.onsuccess = function(e) { + let index; + const objStore = db.transaction("test", "readonly", + { durability: 'relaxed' }) + .objectStore("test"); + + assert_throws_dom('NotFoundError', function() + { index = objStore.index("index"); }); + assert_equals(index, undefined); + db.close(); + t.done(); + }; + }; +}, 'IDBObjectStore.deleteIndex() removes the index'); diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_deleteIndex.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_deleteIndex.htm deleted file mode 100644 index f12af6fc53..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_deleteIndex.htm +++ /dev/null @@ -1,44 +0,0 @@ - - -IDBObjectStore.deleteIndex() - removes the index - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_deleted.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_deleted.htm deleted file mode 100644 index 5ccc8fdb1b..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_deleted.htm +++ /dev/null @@ -1,50 +0,0 @@ - - -Attempting to use deleted IDBObjectStore - - - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/ready-state-destroyed-execution-context.html b/testing/web-platform/tests/IndexedDB/ready-state-destroyed-execution-context.html index 8194052391..6b2677fae7 100644 --- a/testing/web-platform/tests/IndexedDB/ready-state-destroyed-execution-context.html +++ b/testing/web-platform/tests/IndexedDB/ready-state-destroyed-execution-context.html @@ -21,6 +21,10 @@ promise_test(async t => { const openRequest = iframe.contentWindow.indexedDB.open(dbname); assert_equals(openRequest.readyState, 'pending'); iframe.remove(); + await new Promise(resolve => { + openRequest.onerror = resolve; + openRequest.onsuccess = resolve; + }); assert_equals(openRequest.readyState, 'done'); }, 'readyState accessor is valid after execution context is destroyed'); -- cgit v1.2.3