From 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:33 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../back-forward-cache-open-connection.window.js | 4 +- .../tests/IndexedDB/idbindex_count.any.js | 108 ++++++ .../tests/IndexedDB/idbindex_count.htm | 37 -- .../tests/IndexedDB/idbindex_count2.htm | 37 -- .../tests/IndexedDB/idbindex_count3.htm | 28 -- .../tests/IndexedDB/idbindex_count4.htm | 37 -- .../tests/IndexedDB/idbindex_get.any.js | 190 +++++++++ .../web-platform/tests/IndexedDB/idbindex_get.htm | 36 -- .../web-platform/tests/IndexedDB/idbindex_get2.htm | 39 -- .../web-platform/tests/IndexedDB/idbindex_get3.htm | 27 -- .../web-platform/tests/IndexedDB/idbindex_get4.htm | 39 -- .../web-platform/tests/IndexedDB/idbindex_get5.htm | 26 -- .../web-platform/tests/IndexedDB/idbindex_get6.htm | 29 -- .../web-platform/tests/IndexedDB/idbindex_get7.htm | 32 -- .../web-platform/tests/IndexedDB/idbindex_get8.htm | 27 -- .../tests/IndexedDB/idbindex_getAll.any.js | 214 +++++++++++ .../tests/IndexedDB/idbindex_getAll.html | 216 ----------- .../tests/IndexedDB/idbindex_getAllKeys.any.js | 189 +++++++++ .../tests/IndexedDB/idbindex_getAllKeys.html | 192 --------- .../tests/IndexedDB/idbindex_getKey.any.js | 191 +++++++++ .../tests/IndexedDB/idbindex_getKey.htm | 38 -- .../tests/IndexedDB/idbindex_getKey2.htm | 39 -- .../tests/IndexedDB/idbindex_getKey3.htm | 28 -- .../tests/IndexedDB/idbindex_getKey4.htm | 38 -- .../tests/IndexedDB/idbindex_getKey5.htm | 26 -- .../tests/IndexedDB/idbindex_getKey6.htm | 29 -- .../tests/IndexedDB/idbindex_getKey7.htm | 32 -- .../tests/IndexedDB/idbindex_getKey8.htm | 27 -- .../tests/IndexedDB/idbobjectstore_add.any.js | 408 ++++++++++++++++++++ .../tests/IndexedDB/idbobjectstore_add.htm | 35 -- .../tests/IndexedDB/idbobjectstore_add10.htm | 29 -- .../tests/IndexedDB/idbobjectstore_add11.htm | 29 -- .../tests/IndexedDB/idbobjectstore_add12.htm | 29 -- .../tests/IndexedDB/idbobjectstore_add13.htm | 29 -- .../tests/IndexedDB/idbobjectstore_add14.htm | 32 -- .../tests/IndexedDB/idbobjectstore_add15.htm | 31 -- .../tests/IndexedDB/idbobjectstore_add16.htm | 25 -- .../tests/IndexedDB/idbobjectstore_add2.htm | 36 -- .../tests/IndexedDB/idbobjectstore_add3.htm | 39 -- .../tests/IndexedDB/idbobjectstore_add4.htm | 40 -- .../tests/IndexedDB/idbobjectstore_add5.htm | 34 -- .../tests/IndexedDB/idbobjectstore_add6.htm | 47 --- .../tests/IndexedDB/idbobjectstore_add7.htm | 47 --- .../tests/IndexedDB/idbobjectstore_add8.htm | 47 --- .../tests/IndexedDB/idbobjectstore_add9.htm | 27 -- .../tests/IndexedDB/idbobjectstore_put.any.js | 427 +++++++++++++++++++++ .../tests/IndexedDB/idbobjectstore_put.htm | 35 -- .../tests/IndexedDB/idbobjectstore_put10.htm | 29 -- .../tests/IndexedDB/idbobjectstore_put11.htm | 29 -- .../tests/IndexedDB/idbobjectstore_put12.htm | 29 -- .../tests/IndexedDB/idbobjectstore_put13.htm | 29 -- .../tests/IndexedDB/idbobjectstore_put14.htm | 32 -- .../tests/IndexedDB/idbobjectstore_put15.htm | 31 -- .../tests/IndexedDB/idbobjectstore_put16.htm | 25 -- .../tests/IndexedDB/idbobjectstore_put2.htm | 36 -- .../tests/IndexedDB/idbobjectstore_put3.htm | 48 --- .../tests/IndexedDB/idbobjectstore_put4.htm | 40 -- .../tests/IndexedDB/idbobjectstore_put5.htm | 34 -- .../tests/IndexedDB/idbobjectstore_put6.htm | 47 --- .../tests/IndexedDB/idbobjectstore_put7.htm | 47 --- .../tests/IndexedDB/idbobjectstore_put8.htm | 47 --- .../tests/IndexedDB/idbobjectstore_put9.htm | 27 -- 62 files changed, 1729 insertions(+), 2182 deletions(-) create mode 100644 testing/web-platform/tests/IndexedDB/idbindex_count.any.js delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_count.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_count2.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_count3.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_count4.htm create mode 100644 testing/web-platform/tests/IndexedDB/idbindex_get.any.js delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_get.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_get2.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_get3.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_get4.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_get5.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_get6.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_get7.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_get8.htm create mode 100644 testing/web-platform/tests/IndexedDB/idbindex_getAll.any.js delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_getAll.html create mode 100644 testing/web-platform/tests/IndexedDB/idbindex_getAllKeys.any.js delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_getAllKeys.html create mode 100644 testing/web-platform/tests/IndexedDB/idbindex_getKey.any.js delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_getKey.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_getKey2.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_getKey3.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_getKey4.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_getKey5.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_getKey6.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_getKey7.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbindex_getKey8.htm create mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add.any.js delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add10.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add11.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add12.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add13.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add14.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add15.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add16.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add2.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add3.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add4.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add5.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add6.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add7.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add8.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_add9.htm create mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put.any.js delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put10.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put11.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put12.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put13.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put14.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put15.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put16.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put2.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put3.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put4.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put5.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put6.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put7.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put8.htm delete mode 100644 testing/web-platform/tests/IndexedDB/idbobjectstore_put9.htm (limited to 'testing/web-platform/tests/IndexedDB') diff --git a/testing/web-platform/tests/IndexedDB/back-forward-cache-open-connection.window.js b/testing/web-platform/tests/IndexedDB/back-forward-cache-open-connection.window.js index cee7287a0b..db51daa121 100644 --- a/testing/web-platform/tests/IndexedDB/back-forward-cache-open-connection.window.js +++ b/testing/web-platform/tests/IndexedDB/back-forward-cache-open-connection.window.js @@ -29,7 +29,7 @@ promise_test(async t => { await rc2.historyBack(); // The previous page receiving versionchange event should be evicted with the // correct reason. - // `kIgnoreEventAndEvict` will be reported as "internal-error". + // `kIgnoreEventAndEvict` will be reported as "masked". // See `NotRestoredReasonToReportString()`. - await assertNotRestoredFromBFCache(rc1, ['internal-error']); + await assertNotRestoredFromBFCache(rc1, ['masked']); }); diff --git a/testing/web-platform/tests/IndexedDB/idbindex_count.any.js b/testing/web-platform/tests/IndexedDB/idbindex_count.any.js new file mode 100644 index 0000000000..25d743e422 --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/idbindex_count.any.js @@ -0,0 +1,108 @@ +// META: global=window,worker +// META: title=IDBIndex.count() +// META: script=resources/support.js +// @author Microsoft +// @author Odin Hørthe Omdal +// @author Intel + +'use_strict'; + +async_test(t => { + let db; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const store = db.createObjectStore("store", { autoIncrement: true }); + store.createIndex("index", "indexedProperty"); + for (let i = 0; i < 10; i++) { + store.add({ indexedProperty: "data" + i }); + } + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .index("index") + .count(); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, 10); + t.done(); + }); + }; +}, 'count() returns the number of records in the index'); + +async_test(t => { + let db; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const store = db.createObjectStore("store", { autoIncrement: true }); + store.createIndex("index", "indexedProperty"); + + for (let i = 0; i < 10; i++) { + store.add({ indexedProperty: "data" + i }); + } + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .index("index") + .count(IDBKeyRange.bound('data0', 'data4')); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, 5); + t.done(); + }); + }; +}, 'count() returns the number of records that have keys within the range'); + +async_test(t => { + let db; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + + const store = db.createObjectStore("store", { autoIncrement: true }); + store.createIndex("myindex", "idx"); + + for (let i = 0; i < 10; i++) + store.add({ idx: "data_" + (i%2) }); + + store.index("myindex").count("data_0").onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, 5, "count(data_0)"); + t.done(); + }); + }; +}, 'count() returns the number of records that have keys with the key'); + +async_test(t => { + let db; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const store = db.createObjectStore("store", { autoIncrement: true }); + store.createIndex("index", "indexedProperty"); + + for (let i = 0; i < 10; i++) { + store.add({ indexedProperty: "data" + i }); + } + }; + + open_rq.onsuccess = function(e) { + const index = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .index("index"); + + assert_throws_dom("DataError", function () { + index.count(NaN); + }); + + t.done(); + }; +}, 'count() throws DataError when using invalid key'); diff --git a/testing/web-platform/tests/IndexedDB/idbindex_count.htm b/testing/web-platform/tests/IndexedDB/idbindex_count.htm deleted file mode 100644 index 5b45b5223b..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_count.htm +++ /dev/null @@ -1,37 +0,0 @@ - - -IDBIndex.count() - returns the number of records in the index - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbindex_count2.htm b/testing/web-platform/tests/IndexedDB/idbindex_count2.htm deleted file mode 100644 index 2a68770df9..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_count2.htm +++ /dev/null @@ -1,37 +0,0 @@ - - -IDBIndex.count() - returns the number of records that have keys within the range - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbindex_count3.htm b/testing/web-platform/tests/IndexedDB/idbindex_count3.htm deleted file mode 100644 index a94e898554..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_count3.htm +++ /dev/null @@ -1,28 +0,0 @@ - - -IDBIndex.count() - returns the number of records that have keys with the key - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbindex_count4.htm b/testing/web-platform/tests/IndexedDB/idbindex_count4.htm deleted file mode 100644 index ce19968bf1..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_count4.htm +++ /dev/null @@ -1,37 +0,0 @@ - - -IDBIndex.count() - throw DataError when using invalid key - - - - - -
- - diff --git a/testing/web-platform/tests/IndexedDB/idbindex_get.any.js b/testing/web-platform/tests/IndexedDB/idbindex_get.any.js new file mode 100644 index 0000000000..0da228f738 --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/idbindex_get.any.js @@ -0,0 +1,190 @@ +// META: global=window,worker +// META: title=IDBIndex.get() +// META: script=resources/support.js +// @author Microsoft +// @author Intel + +'use_strict'; + +async_test(t => { + let db; + let index; + const record = { key: 1, indexedProperty: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + index = objStore.createIndex("index", "indexedProperty"); + + objStore.add(record); + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .index("index") + .get(record.indexedProperty); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result.key, record.key); + t.done(); + }); + }; +}, 'get() returns the record'); + +async_test(t => { + let db; + const records = [ + { key: 1, indexedProperty: "data" }, + { key: 2, indexedProperty: "data" }, + { key: 3, indexedProperty: "data" } + ]; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("test", { keyPath: "key" }); + objStore.createIndex("index", "indexedProperty"); + + for (let i = 0; i < records.length; i++) + objStore.add(records[i]); + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("test", "readonly", { durability: 'relaxed' }) + .objectStore("test") + .index("index") + .get("data"); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result.key, records[0].key); + t.done(); + }); + }; +}, 'get() returns the record where the index contains duplicate values'); + +async_test(t => { + let db; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const rq = db.createObjectStore("test", { keyPath: "key" }) + .createIndex("index", "indexedProperty") + .get(1); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, undefined); + t.done(); + }); + }; +}, 'get() attempts to retrieve a record that does not exist'); + +async_test(t => { + let db; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const store = db.createObjectStore("store", { keyPath: "key" }); + store.createIndex("index", "indexedProperty"); + + for (let i = 0; i < 10; i++) { + store.add({ key: i, indexedProperty: "data" + i }); + } + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .index("index") + .get(IDBKeyRange.bound('data4', 'data7')); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result.key, 4); + assert_equals(e.target.result.indexedProperty, 'data4'); + + step_timeout(function () { t.done(); }, 4); + }); + }; +}, 'get() returns the record with the first key in the range'); + +async_test(t => { + let db; + const open_rq = createdb(t); + + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + + const index = db.createObjectStore("test", { keyPath: "key" }) + .createIndex("index", "indexedProperty"); + + assert_throws_dom("DataError", function () { + index.get(NaN); + }); + t.done(); + }; +}, 'get() throws DataError when using invalid key'); + +async_test(t => { + let db; + const open_rq = createdb(t); + + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const store = db.createObjectStore("store", { keyPath: "key" }); + const index = store.createIndex("index", "indexedProperty"); + + store.add({ key: 1, indexedProperty: "data" }); + store.deleteIndex("index"); + + assert_throws_dom("InvalidStateError", function () { + index.get("data"); + }); + t.done(); + }; +}, 'get() throws InvalidStateError when the index is deleted'); + +async_test(t => { + let db; + const open_rq = createdb(t); + + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const store = db.createObjectStore("store", { keyPath: "key" }); + const index = store.createIndex("index", "indexedProperty"); + store.add({ key: 1, indexedProperty: "data" }); + }; + + open_rq.onsuccess = function(e) { + db = e.target.result; + const tx = db.transaction('store', 'readonly', { durability: 'relaxed' }); + const index = tx.objectStore('store').index('index'); + tx.abort(); + + assert_throws_dom("TransactionInactiveError", function () { + index.get("data"); + }); + t.done(); + }; +}, 'get() throws TransactionInactiveError on aborted transaction'); + +async_test(t => { + let db; + const open_rq = createdb(t); + + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const store = db.createObjectStore("store", { keyPath: "key" }); + const index = store.createIndex("index", "indexedProperty"); + store.add({ key: 1, indexedProperty: "data" }); + + e.target.transaction.abort(); + + assert_throws_dom("InvalidStateError", function () { + index.get("data"); + }); + t.done(); + }; +}, 'get() throws InvalidStateError on index deleted by aborted upgrade'); diff --git a/testing/web-platform/tests/IndexedDB/idbindex_get.htm b/testing/web-platform/tests/IndexedDB/idbindex_get.htm deleted file mode 100644 index 861d7e54d1..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_get.htm +++ /dev/null @@ -1,36 +0,0 @@ - - -IDBIndex.get() - returns the record - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbindex_get2.htm b/testing/web-platform/tests/IndexedDB/idbindex_get2.htm deleted file mode 100644 index 66d2fee5cb..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_get2.htm +++ /dev/null @@ -1,39 +0,0 @@ - - -IDBIndex.get() - returns the record where the index contains duplicate values - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbindex_get3.htm b/testing/web-platform/tests/IndexedDB/idbindex_get3.htm deleted file mode 100644 index 62a0a4f3ba..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_get3.htm +++ /dev/null @@ -1,27 +0,0 @@ - - -IDBIndex.get() - attempt to retrieve a record that doesn't exist - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbindex_get4.htm b/testing/web-platform/tests/IndexedDB/idbindex_get4.htm deleted file mode 100644 index 369c288071..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_get4.htm +++ /dev/null @@ -1,39 +0,0 @@ - - -IDBIndex.get() - returns the record with the first key in the range - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbindex_get5.htm b/testing/web-platform/tests/IndexedDB/idbindex_get5.htm deleted file mode 100644 index 9b0bfe4b35..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_get5.htm +++ /dev/null @@ -1,26 +0,0 @@ - - -IDBIndex.get() - throw DataError when using invalid key - - - - - -
- - diff --git a/testing/web-platform/tests/IndexedDB/idbindex_get6.htm b/testing/web-platform/tests/IndexedDB/idbindex_get6.htm deleted file mode 100644 index ca51b8492f..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_get6.htm +++ /dev/null @@ -1,29 +0,0 @@ - - -IDBIndex.get() - throw InvalidStateError when the index is deleted - - - - - -
- - diff --git a/testing/web-platform/tests/IndexedDB/idbindex_get7.htm b/testing/web-platform/tests/IndexedDB/idbindex_get7.htm deleted file mode 100644 index 5e9511a0b1..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_get7.htm +++ /dev/null @@ -1,32 +0,0 @@ - - -IDBIndex.get() - throw TransactionInactiveError on aborted transaction - - - - - -
- diff --git a/testing/web-platform/tests/IndexedDB/idbindex_get8.htm b/testing/web-platform/tests/IndexedDB/idbindex_get8.htm deleted file mode 100644 index a2565419b9..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_get8.htm +++ /dev/null @@ -1,27 +0,0 @@ - - -IDBIndex.get() - throw InvalidStateError on index deleted by aborted upgrade - - - - -
- diff --git a/testing/web-platform/tests/IndexedDB/idbindex_getAll.any.js b/testing/web-platform/tests/IndexedDB/idbindex_getAll.any.js new file mode 100644 index 0000000000..36b4c0239a --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/idbindex_getAll.any.js @@ -0,0 +1,214 @@ +// META: global=window,worker +// META: title=IndexedDB: Test IDBIndex.getAll +// META: script=resources/support.js + +'use_strict'; + +const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split(''); +const ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); + +function getall_test(func, name) { + indexeddb_test( + function(t, connection, tx) { + let store = connection.createObjectStore('generated', + {autoIncrement: true, keyPath: 'id'}); + let index = store.createIndex('test_idx', 'upper'); + alphabet.forEach(function(letter) { + store.put({ch: letter, upper: letter.toUpperCase()}); + }); + + store = connection.createObjectStore('out-of-line', null); + index = store.createIndex('test_idx', 'upper'); + alphabet.forEach(function(letter) { + store.put({ch: letter, upper: letter.toUpperCase()}, letter); + }); + + store = connection.createObjectStore('out-of-line-not-unique', null); + index = store.createIndex('test_idx', 'half'); + alphabet.forEach(function(letter) { + if (letter <= 'm') + store.put({ch: letter, half: 'first'}, letter); + else + store.put({ch: letter, half: 'second'}, letter); + }); + + store = connection.createObjectStore('out-of-line-multi', null); + index = store.createIndex('test_idx', 'attribs', {multiEntry: true}); + alphabet.forEach(function(letter) { + attrs = []; + if (['a', 'e', 'i', 'o', 'u'].indexOf(letter) != -1) + attrs.push('vowel'); + else + attrs.push('consonant'); + if (letter == 'a') + attrs.push('first'); + if (letter == 'z') + attrs.push('last'); + store.put({ch: letter, attribs: attrs}, letter); + }); + + store = connection.createObjectStore('empty', null); + index = store.createIndex('test_idx', 'upper'); + }, + func, + name + ); +} + +function createGetAllRequest(t, storeName, connection, range, maxCount) { + const transaction = connection.transaction(storeName, 'readonly'); + const store = transaction.objectStore(storeName); + const index = store.index('test_idx'); + const req = index.getAll(range, maxCount); + req.onerror = t.unreached_func('getAll request should succeed'); + return req; +} + +getall_test(function(t, connection) { + const req = createGetAllRequest(t, 'out-of-line', connection, 'C'); + req.onsuccess = t.step_func(function(evt) { + const data = evt.target.result; + assert_class_string(data, 'Array', 'result should be an array'); + assert_array_equals(data.map(function(e) { return e.ch; }), ['c']); + assert_array_equals(data.map(function(e) { return e.upper; }), ['C']); + t.done(); + }); + }, 'Single item get'); + +getall_test(function(t, connection) { + const req = createGetAllRequest(t, 'empty', connection); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, [], + 'getAll() on empty object store should return an empty array'); + t.done(); + }); + }, 'Empty object store'); + +getall_test(function(t, connection) { + const req = createGetAllRequest(t, 'out-of-line', connection); + req.onsuccess = t.step_func(function(evt) { + const data = evt.target.result; + assert_class_string(data, 'Array', 'result should be an array'); + assert_array_equals(data.map(function(e) { return e.ch; }), alphabet); + assert_array_equals(data.map(function(e) { return e.upper; }), ALPHABET); + t.done(); + }); + }, 'Get all keys'); + +getall_test(function(t, connection) { + const req = createGetAllRequest(t, 'out-of-line', connection, undefined, + 10); + req.onsuccess = t.step_func(function(evt) { + const data = evt.target.result; + assert_class_string(data, 'Array', 'result should be an array'); + assert_array_equals(data.map(function(e) { return e.ch; }), 'abcdefghij'.split('')); + assert_array_equals(data.map(function(e) { return e.upper; }), 'ABCDEFGHIJ'.split('')); + t.done(); + }); + }, 'maxCount=10'); + +getall_test(function(t, connection) { + const req = createGetAllRequest(t, 'out-of-line', connection, + IDBKeyRange.bound('G', 'M')); + req.onsuccess = t.step_func(function(evt) { + const data = evt.target.result; + assert_array_equals(data.map(function(e) { return e.ch; }), 'ghijklm'.split('')); + assert_array_equals(data.map(function(e) { return e.upper; }), 'GHIJKLM'.split('')); + t.done(); + }); + }, 'Get bound range'); + +getall_test(function(t, connection) { + const req = createGetAllRequest(t, 'out-of-line', connection, + IDBKeyRange.bound('G', 'M'), 3); + req.onsuccess = t.step_func(function(evt) { + const data = evt.target.result; + assert_class_string(data, 'Array', 'result should be an array'); + assert_array_equals(data.map(function(e) { return e.ch; }), 'ghi'.split('')); + assert_array_equals(data.map(function(e) { return e.upper; }), 'GHI'.split('')); + t.done(); + }); + }, 'Get bound range with maxCount'); + +getall_test(function(t, connection) { + const req = createGetAllRequest(t, 'out-of-line', connection, + IDBKeyRange.bound('G', 'K', false, true)); + req.onsuccess = t.step_func(function(evt) { + const data = evt.target.result; + assert_class_string(data, 'Array', 'result should be an array'); + assert_array_equals(data.map(function(e) { return e.ch; }), 'ghij'.split('')); + assert_array_equals(data.map(function(e) { return e.upper; }), 'GHIJ'.split('')); + t.done(); + }); + }, 'Get upper excluded'); + +getall_test(function(t, connection) { + const req = createGetAllRequest(t, 'out-of-line', connection, + IDBKeyRange.bound('G', 'K', true, false)); + req.onsuccess = t.step_func(function(evt) { + const data = evt.target.result; + assert_class_string(data, 'Array', 'result should be an array'); + assert_array_equals(data.map(function(e) { return e.ch; }), 'hijk'.split('')); + assert_array_equals(data.map(function(e) { return e.upper; }), 'HIJK'.split('')); + t.done(); + }); + }, 'Get lower excluded'); + +getall_test(function(t, connection) { + const req = createGetAllRequest(t, 'generated', + connection, IDBKeyRange.bound(4, 15), 3); + req.onsuccess = t.step_func(function(evt) { + const data = evt.target.result; + assert_true(Array.isArray(data)); + assert_equals(data.length, 0); + t.done(); + }); + }, 'Get bound range (generated) with maxCount'); + +getall_test(function(t, connection) { + const req = createGetAllRequest(t, 'out-of-line', + connection, "Doesn't exist"); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, [], + 'getAll() using a nonexistent key should return an empty array'); + t.done(); + req.onerror = t.unreached_func('getAll request should succeed'); + }); + }, 'Non existent key'); + +getall_test(function(t, connection) { + const req = createGetAllRequest(t, 'out-of-line', connection, + undefined, 0); + req.onsuccess = t.step_func(function(evt) { + const data = evt.target.result; + assert_class_string(data, 'Array', 'result should be an array'); + assert_array_equals(data.map(function(e) { return e.ch; }), alphabet); + assert_array_equals(data.map(function(e) { return e.upper; }), ALPHABET); + t.done(); + }); + }, 'maxCount=0'); + +getall_test(function(t, connection) { + const req = createGetAllRequest(t, 'out-of-line-not-unique', connection, + 'first'); + req.onsuccess = t.step_func(function(evt) { + const data = evt.target.result; + assert_class_string(data, 'Array', 'result should be an array'); + assert_array_equals(data.map(function(e) { return e.ch; }), 'abcdefghijklm'.split('')); + assert_true(data.every(function(e) { return e.half === 'first'; })); + t.done(); + }); + }, 'Retrieve multiEntry key'); + +getall_test(function(t, connection) { + const req = createGetAllRequest(t, 'out-of-line-multi', connection, + 'vowel'); + req.onsuccess = t.step_func(function(evt) { + const data = evt.target.result; + assert_class_string(data, 'Array', 'result should be an array'); + assert_array_equals(data.map(function(e) { return e.ch; }), ['a', 'e', 'i', 'o', 'u']); + assert_array_equals(data[0].attribs, ['vowel', 'first']); + assert_true(data.every(function(e) { return e.attribs[0] === 'vowel'; })); + t.done(); + }); + }, 'Retrieve one key multiple values'); diff --git a/testing/web-platform/tests/IndexedDB/idbindex_getAll.html b/testing/web-platform/tests/IndexedDB/idbindex_getAll.html deleted file mode 100644 index bd2a021386..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_getAll.html +++ /dev/null @@ -1,216 +0,0 @@ - -IndexedDB: Test IDBIndex.getAll. - - - - diff --git a/testing/web-platform/tests/IndexedDB/idbindex_getAllKeys.any.js b/testing/web-platform/tests/IndexedDB/idbindex_getAllKeys.any.js new file mode 100644 index 0000000000..92f3cc1269 --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/idbindex_getAllKeys.any.js @@ -0,0 +1,189 @@ +// META: global=window,worker +// META: title=IndexedDB: Test IDBIndex.getAllKeys. +// META: script=resources/support.js + +'use_strict'; + +const alphabet = 'abcdefghijklmnopqrstuvwxyz'.split(''); + +function getall_test(func, name) { + indexeddb_test( + function(t, connection, tx) { + let store = connection.createObjectStore('generated', + {autoIncrement: true, keyPath: 'id'}); + let index = store.createIndex('test_idx', 'upper'); + alphabet.forEach(function(letter) { + store.put({ch: letter, upper: letter.toUpperCase()}); + }); + + store = connection.createObjectStore('out-of-line', null); + index = store.createIndex('test_idx', 'upper'); + alphabet.forEach(function(letter) { + store.put({ch: letter, upper: letter.toUpperCase()}, letter); + }); + + store = connection.createObjectStore('out-of-line-multi', null); + index = store.createIndex('test_idx', 'attribs', {multiEntry: true}); + alphabet.forEach(function(letter) { + attrs = []; + if (['a', 'e', 'i', 'o', 'u'].indexOf(letter) != -1) + attrs.push('vowel'); + else + attrs.push('consonant'); + if (letter == 'a') + attrs.push('first'); + if (letter == 'z') + attrs.push('last'); + store.put({ch: letter, attribs: attrs}, letter.toUpperCase()); + }); + + store = connection.createObjectStore('empty', null); + index = store.createIndex('test_idx', 'upper'); + }, + func, + name + ); +} + +function createGetAllKeysRequest(t, storeName, connection, range, maxCount) { + const transaction = connection.transaction(storeName, 'readonly'); + const store = transaction.objectStore(storeName); + const index = store.index('test_idx'); + const req = index.getAllKeys(range, maxCount); + req.onerror = t.unreached_func('getAllKeys request should succeed'); + return req; +} + +getall_test(function(t, connection) { + const req = createGetAllKeysRequest(t, 'out-of-line', connection, 'C'); + req.onsuccess = t.step_func(function(evt) { + const data = evt.target.result; + assert_array_equals(evt.target.result, ['c']); + t.done(); + }); + }, 'Single item get'); + +getall_test(function(t, connection) { + const req = createGetAllKeysRequest(t, 'empty', connection); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, [], + 'getAllKeys() on empty object store should return empty array'); + t.done(); + }); + }, 'Empty object store'); + +getall_test(function(t, connection) { + const req = createGetAllKeysRequest(t, 'out-of-line', connection); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, alphabet, + 'getAllKeys() should return a..z'); + t.done(); + }); + }, 'Get all keys'); + +getall_test(function(t, connection) { + const req = createGetAllKeysRequest(t, 'generated', connection); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26], + 'getAllKeys() should return 1..26'); + t.done(); + }); + }, 'Get all generated keys'); + +getall_test(function(t, connection) { + const req = createGetAllKeysRequest(t, 'out-of-line', connection, undefined, + 10); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, + 'abcdefghij'.split(''), + 'getAllKeys() should return a..j'); + t.done(); + }); + }, 'maxCount=10'); + +getall_test(function(t, connection) { + const req = createGetAllKeysRequest(t, 'out-of-line', connection, + IDBKeyRange.bound('G', 'M')); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, + 'ghijklm'.split(''), + 'getAllKeys() should return g..m'); + t.done(); + }); + }, 'Get bound range'); + +getall_test(function(t, connection) { + const req = createGetAllKeysRequest(t, 'out-of-line', connection, + IDBKeyRange.bound('G', 'M'), 3); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, + ['g', 'h', 'i'], + 'getAllKeys() should return g..i'); + t.done(); + }); + }, 'Get bound range with maxCount'); + +getall_test(function(t, connection) { + const req = createGetAllKeysRequest(t, 'out-of-line', connection, + IDBKeyRange.bound('G', 'K', false, true)); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, + ['g', 'h', 'i', 'j'], + 'getAllKeys() should return g..j'); + t.done(); + }); + }, 'Get upper excluded'); + +getall_test(function(t, connection) { + const req = createGetAllKeysRequest(t, 'out-of-line', connection, + IDBKeyRange.bound('G', 'K', true, false)); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, + ['h', 'i', 'j', 'k'], + 'getAllKeys() should return h..k'); + t.done(); + }); + }, 'Get lower excluded'); + +getall_test(function(t, connection) { + const req = createGetAllKeysRequest(t, 'generated', + connection, IDBKeyRange.bound(4, 15), 3); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, [], + 'getAllKeys() should return []'); + t.done(); + }); + }, 'Get bound range (generated) with maxCount'); + +getall_test(function(t, connection) { + const req = createGetAllKeysRequest(t, 'out-of-line', + connection, "Doesn't exist"); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, [], + 'getAllKeys() using a nonexistent key should return empty array'); + t.done(); + req.onerror = t.unreached_func('getAllKeys request should succeed'); + }); + }, 'Non existent key'); + +getall_test(function(t, connection) { + const req = createGetAllKeysRequest(t, 'out-of-line', connection, + undefined, 0); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, alphabet, + 'getAllKeys() should return a..z'); + t.done(); + }); + }, 'maxCount=0'); + +getall_test(function(t, connection) { + const req = createGetAllKeysRequest(t, 'out-of-line-multi', connection, + 'vowel'); + req.onsuccess = t.step_func(function(evt) { + assert_array_equals(evt.target.result, ['A','E','I','O','U']) + t.done(); + }); + req.onerror = t.unreached_func('getAllKeys request should succeed'); + }, 'Retrieve multiEntry keys'); diff --git a/testing/web-platform/tests/IndexedDB/idbindex_getAllKeys.html b/testing/web-platform/tests/IndexedDB/idbindex_getAllKeys.html deleted file mode 100644 index 5640bfdee7..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_getAllKeys.html +++ /dev/null @@ -1,192 +0,0 @@ - -IndexedDB: Test IDBIndex.getAllKeys. - - - - diff --git a/testing/web-platform/tests/IndexedDB/idbindex_getKey.any.js b/testing/web-platform/tests/IndexedDB/idbindex_getKey.any.js new file mode 100644 index 0000000000..677a70e7cb --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/idbindex_getKey.any.js @@ -0,0 +1,191 @@ +// META: global=window,worker +// META: title=IDBIndex.getKey() +// META: script=resources/support.js +// @author Microsoft +// @author Intel + +'use_strict'; + +async_test(t => { + let db; + const record = { key: 1, indexedProperty: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("test", { keyPath: "key" }); + objStore.createIndex("index", "indexedProperty"); + + objStore.add(record); + }; + + open_rq.onsuccess = function(e) { + let rq = db.transaction("test", "readonly", { durability: 'relaxed' }) + .objectStore("test"); + + rq = rq.index("index"); + + rq = rq.getKey("data"); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, record.key); + t.done(); + }); + }; +}, 'getKey() returns the record\'s primary key'); + +async_test(t => { + let db; + const records = [ + { key: 1, indexedProperty: "data" }, + { key: 2, indexedProperty: "data" }, + { key: 3, indexedProperty: "data" } + ]; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + var objStore = db.createObjectStore("test", { keyPath: "key" }); + objStore.createIndex("index", "indexedProperty"); + + for (let i = 0; i < records.length; i++) + objStore.add(records[i]); + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("test", "readonly", { durability: 'relaxed' }) + .objectStore("test") + .index("index") + .getKey("data"); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, records[0].key); + t.done(); + }); + }; +}, 'getKey() returns the record\'s primary key where the index contains duplicate values'); + +async_test(t => { + let db; + const open_rq = createdb(t); + + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const rq = db.createObjectStore("test", { keyPath: "key" }) + .createIndex("index", "indexedProperty") + .getKey(1); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, undefined); + t.done(); + }); + }; +}, 'getKey() attempt to retrieve the primary key of a record that doesn\'t exist'); + +async_test(t => { + let db; + + const open_rq = createdb(t); + + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const store = db.createObjectStore("store", { keyPath: "key" }); + store.createIndex("index", "indexedProperty"); + + for (let i = 0; i < 10; i++) { + store.add({ key: i, indexedProperty: "data" + i }); + } + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .index("index") + .getKey(IDBKeyRange.bound('data4', 'data7')); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result, 4); + + step_timeout(function () { t.done(); }, 4) + }); + }; +}, 'getKey() returns the key of the first record within the range'); + +async_test(t => { + let db; + const open_rq = createdb(t); + + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + + const index = db.createObjectStore("test", { keyPath: "key" }) + .createIndex("index", "indexedProperty"); + + assert_throws_dom("DataError", function () { + index.getKey(NaN); + }); + t.done(); + }; +}, 'getKey() throws DataError when using invalid key'); + +async_test(t => { + let db; + const open_rq = createdb(t); + + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const store = db.createObjectStore("store", { keyPath: "key" }); + const index = store.createIndex("index", "indexedProperty"); + + store.add({ key: 1, indexedProperty: "data" }); + store.deleteIndex("index"); + + assert_throws_dom("InvalidStateError", function () { + index.getKey("data"); + }); + t.done(); + }; +}, 'getKey() throws InvalidStateError when the index is deleted'); + +async_test(t => { + let db; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const store = db.createObjectStore("store", { keyPath: "key" }); + const index = store.createIndex("index", "indexedProperty"); + store.add({ key: 1, indexedProperty: "data" }); + }; + + open_rq.onsuccess = function(e) { + db = e.target.result; + const tx = db.transaction('store', 'readonly', { durability: 'relaxed' }); + const index = tx.objectStore('store').index('index'); + tx.abort(); + + assert_throws_dom("TransactionInactiveError", function () { + index.getKey("data"); + }); + t.done(); + }; +}, 'getKey() throws TransactionInactiveError on aborted transaction'); + +async_test(t => { + let db; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const store = db.createObjectStore("store", { keyPath: "key" }); + const index = store.createIndex("index", "indexedProperty"); + store.add({ key: 1, indexedProperty: "data" }); + + e.target.transaction.abort(); + + assert_throws_dom("InvalidStateError", function () { + index.getKey("data"); + }); + t.done(); + }; +}, 'getKey() throws InvalidStateError on index deleted by aborted upgrade'); diff --git a/testing/web-platform/tests/IndexedDB/idbindex_getKey.htm b/testing/web-platform/tests/IndexedDB/idbindex_getKey.htm deleted file mode 100644 index 101e8f06b7..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_getKey.htm +++ /dev/null @@ -1,38 +0,0 @@ - - -IDBIndex.getKey() - returns the record's primary key - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbindex_getKey2.htm b/testing/web-platform/tests/IndexedDB/idbindex_getKey2.htm deleted file mode 100644 index 488368d7f4..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_getKey2.htm +++ /dev/null @@ -1,39 +0,0 @@ - - -IDBIndex.getKey() - returns the record's primary key where the index contains duplicate values - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbindex_getKey3.htm b/testing/web-platform/tests/IndexedDB/idbindex_getKey3.htm deleted file mode 100644 index 40ed76d174..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_getKey3.htm +++ /dev/null @@ -1,28 +0,0 @@ - - -IDBIndex.getKey() - attempt to retrieve the primary key of a record that doesn't exist - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbindex_getKey4.htm b/testing/web-platform/tests/IndexedDB/idbindex_getKey4.htm deleted file mode 100644 index 8c81a272ae..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_getKey4.htm +++ /dev/null @@ -1,38 +0,0 @@ - - -IDBIndex.getKey() - returns the key of the first record within the range - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbindex_getKey5.htm b/testing/web-platform/tests/IndexedDB/idbindex_getKey5.htm deleted file mode 100644 index 3155131397..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_getKey5.htm +++ /dev/null @@ -1,26 +0,0 @@ - - -IDBIndex.getKey() - throw DataError when using invalid key - - - - - -
- - diff --git a/testing/web-platform/tests/IndexedDB/idbindex_getKey6.htm b/testing/web-platform/tests/IndexedDB/idbindex_getKey6.htm deleted file mode 100644 index b71967d4fb..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_getKey6.htm +++ /dev/null @@ -1,29 +0,0 @@ - - -IDBIndex.getKey() - throw InvalidStateError when the index is deleted - - - - - -
- - diff --git a/testing/web-platform/tests/IndexedDB/idbindex_getKey7.htm b/testing/web-platform/tests/IndexedDB/idbindex_getKey7.htm deleted file mode 100644 index 6a64df3116..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_getKey7.htm +++ /dev/null @@ -1,32 +0,0 @@ - - -IDBIndex.getKey() - throw TransactionInactiveError on aborted transaction - - - - - -
- diff --git a/testing/web-platform/tests/IndexedDB/idbindex_getKey8.htm b/testing/web-platform/tests/IndexedDB/idbindex_getKey8.htm deleted file mode 100644 index cf0affb210..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbindex_getKey8.htm +++ /dev/null @@ -1,27 +0,0 @@ - - -IDBIndex.getKey() - throw InvalidStateError on index deleted by aborted upgrade - - - - -
- diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add.any.js b/testing/web-platform/tests/IndexedDB/idbobjectstore_add.any.js new file mode 100644 index 0000000000..dfc15294e8 --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/idbobjectstore_add.any.js @@ -0,0 +1,408 @@ +// META: global=window,worker +// META: title=IDBObjectStore.add() +// META: script=resources/support.js +// @author Microsoft +// @author Intel + +'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("store", { keyPath: "key" }); + + objStore.add(record); + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .get(record.key); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result.property, record.property); + assert_equals(e.target.result.key, record.key); + t.done(); + }); + }; +}, 'add() with an inline key'); + +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("store"); + + objStore.add(record, key); + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .get(key); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result.property, record.property); + + t.done(); + }); + }; +}, 'add() with an out-of-line key'); + +async_test(t => { + const record = { key: 1, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + objStore.add(record); + + const rq = objStore.add(record); + rq.onsuccess = fail(t, "success on adding duplicate record"); + + rq.onerror = t.step_func(function(e) { + assert_equals(e.target.error.name, "ConstraintError"); + assert_equals(rq.error.name, "ConstraintError"); + assert_equals(e.type, "error"); + + e.preventDefault(); + e.stopPropagation(); + }); + }; + + // Defer done, giving rq.onsuccess a chance to run + open_rq.onsuccess = function(e) { + t.done(); + }; +}, 'add() record with same key already exists'); + +async_test(t => { + const record = { key: 1, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + const objStore = db.createObjectStore("store", { autoIncrement: true }); + objStore.createIndex("i1", "property", { unique: true }); + objStore.add(record); + + const rq = objStore.add(record); + rq.onsuccess = fail(t, "success on adding duplicate indexed record"); + + rq.onerror = t.step_func(function(e) { + assert_equals(rq.error.name, "ConstraintError"); + assert_equals(e.target.error.name, "ConstraintError"); + assert_equals(e.type, "error"); + + e.preventDefault(); + e.stopPropagation(); + }); + }; + + // Defer done, giving a spurious rq.onsuccess a chance to run + open_rq.onsuccess = function(e) { + t.done(); + }; +}, 'add() where an index has unique:true specified'); + +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("store", + { keyPath: "test.obj.key" }); + objStore.add(record); + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .get(record.test.obj.key); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result.property, record.property); + + t.done(); + }); + }; +}, 'add() object store\'s key path is an object attribute'); + +async_test(t => { + let db; + const record = { property: "data" }; + const expected_keys = [1, 2, 3, 4]; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "key", + autoIncrement: true }); + + objStore.add(record); + objStore.add(record); + objStore.add(record); + objStore.add(record); + }; + + open_rq.onsuccess = function(e) { + const actual_keys = []; + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .openCursor(); + + rq.onsuccess = t.step_func(function(e) { + const cursor = e.target.result; + + if (cursor) { + actual_keys.push(cursor.value.key); + cursor.continue(); + } else { + assert_array_equals(actual_keys, expected_keys); + t.done(); + } + }); + }; +}, 'add() autoIncrement and inline keys'); + +async_test(t => { + let db; + const record = { property: "data" }; + const expected_keys = [1, 2, 3, 4]; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store", { autoIncrement: true }); + + objStore.add(record); + objStore.add(record); + objStore.add(record); + objStore.add(record); + }; + + open_rq.onsuccess = function(e) { + const actual_keys = []; + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .openCursor(); + + rq.onsuccess = t.step_func(function(e) { + const cursor = e.target.result; + + if (cursor) { + actual_keys.push(cursor.key); + cursor.continue(); + } else { + assert_array_equals(actual_keys, expected_keys); + t.done(); + } + }); + }; +}, 'add() autoIncrement and out-of-line keys'); + +async_test(t => { + let db; + const record = { property: "data" }; + const expected_keys = [1, 2, 3, 4]; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "test.obj.key", + autoIncrement: true }); + + objStore.add(record); + objStore.add(record); + objStore.add(record); + objStore.add(record); + }; + + open_rq.onsuccess = function(e) { + const actual_keys = []; + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .openCursor(); + + rq.onsuccess = t.step_func(function(e) { + const cursor = e.target.result; + + if (cursor) { + actual_keys.push(cursor.value.test.obj.key); + cursor.continue(); + } else { + assert_array_equals(actual_keys, expected_keys); + t.done(); + } + }); + }; +}, 'Object store has autoIncrement:true and the key path is an object \ +attribute'); + +async_test(t => { + const record = { key: 1, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let rq; + db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + + assert_throws_dom("DataError", function() { + rq = objStore.add(record, 1); + }); + + assert_equals(rq, undefined); + t.done(); + }; + }, 'Attempt to \'add()\' a record that does not meet the constraints of an \ + object store\'s inline key requirements'); + +async_test(t => { + const record = { property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + let rq; + const objStore = db.createObjectStore("store"); + + assert_throws_dom("DataError", function() { + rq = objStore.add(record); + }); + + assert_equals(rq, undefined); + t.done(); + }; +}, 'Attempt to call \'add()\' without a key parameter when the object store \ +uses out-of-line keys'); + +async_test(t => { + const record = { key: { value: 1 }, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + + let rq; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + + assert_throws_dom("DataError", function() { + rq = objStore.add(record); + }); + + assert_equals(rq, undefined); + t.done(); + }; +}, 'Attempt to \'add()\' a record where the record\'s key does not meet the \ +constraints of a valid key'); + +async_test(t => { + const record = { property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + + let rq; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + + assert_throws_dom("DataError", function() { + rq = objStore.add(record); + }); + + assert_equals(rq, undefined); + t.done(); + }; +}, 'Attempt to \'add()\' a record where the record\'s in-line key is not \ + defined'); + +async_test(t => { + const record = { property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + + let rq; + const objStore = db.createObjectStore("store"); + + assert_throws_dom("DataError", function() { + rq = objStore.add(record, { value: 1 }); + }); + + assert_equals(rq, undefined); + t.done(); + }; +}, 'Attempt to \'add()\' a record where the out of line key provided does not \ +meet the constraints of a valid key'); + +async_test(t => { + const record = { key: 1, indexedProperty: { property: "data" } }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + + let rq; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + + objStore.createIndex("index", "indexedProperty"); + + rq = objStore.add(record); + + assert_true(rq instanceof IDBRequest); + rq.onsuccess = function() { + t.done(); + } + }; +}, 'add() a record where a value being indexed does not meet the constraints \ +of a valid key'); + +async_test(t => { + let db; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function (event) { + db = event.target.result; + db.createObjectStore("store", {keyPath: "pKey"}); + } + + 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.add({pKey: "primaryKey_0"}); + }); + }); + t.done(); + } +}, 'If the transaction this IDBObjectStore belongs to has its mode set to \ +readonly, throw ReadOnlyError'); + +async_test(t => { + const open_rq = createdb(t); + open_rq.onupgradeneeded = function (event) { + let db = event.target.result; + const ostore = db.createObjectStore("store", {keyPath: "pKey"}); + db.deleteObjectStore("store"); + assert_throws_dom("InvalidStateError", function() { + ostore.add({pKey: "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_add.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add.htm deleted file mode 100644 index 33ea094388..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add.htm +++ /dev/null @@ -1,35 +0,0 @@ - - -IDBObjectStore.add() - add with an inline key - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add10.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add10.htm deleted file mode 100644 index d84004250d..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add10.htm +++ /dev/null @@ -1,29 +0,0 @@ - - -IDBObjectStore.add() - Attempt to call 'add' without an key parameter when the object store uses out-of-line keys - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add11.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add11.htm deleted file mode 100644 index b1d9f71fd0..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add11.htm +++ /dev/null @@ -1,29 +0,0 @@ - - -IDBObjectStore.add() - Attempt to add a record where the record's key does not meet the constraints of a valid key - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add12.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add12.htm deleted file mode 100644 index fc5a7bcebb..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add12.htm +++ /dev/null @@ -1,29 +0,0 @@ - - -IDBObjectStore.add() - Attempt to add a record where the record's in-line key is not defined - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add13.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add13.htm deleted file mode 100644 index ec82989b01..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add13.htm +++ /dev/null @@ -1,29 +0,0 @@ - - -IDBObjectStore.add() - Attempt to add a record where the out of line key provided does not meet the constraints of a valid key - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add14.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add14.htm deleted file mode 100644 index 10bf8a18ce..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add14.htm +++ /dev/null @@ -1,32 +0,0 @@ - - -IDBObjectStore.add() - Add a record where a value being indexed does not meet the constraints of a valid key - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add15.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add15.htm deleted file mode 100644 index a6f897911b..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add15.htm +++ /dev/null @@ -1,31 +0,0 @@ - - -IDBObjectStore.add() - If the transaction this IDBObjectStore belongs to has its mode set to readonly, throw ReadOnlyError - - - - - -
- - diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add16.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add16.htm deleted file mode 100644 index 453082340f..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add16.htm +++ /dev/null @@ -1,25 +0,0 @@ - - -IDBObjectStore.add() - 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_add2.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add2.htm deleted file mode 100644 index 6f6e3eab27..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add2.htm +++ /dev/null @@ -1,36 +0,0 @@ - - -IDBObjectStore.add() - add with an out-of-line key - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add3.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add3.htm deleted file mode 100644 index 9209e7505d..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add3.htm +++ /dev/null @@ -1,39 +0,0 @@ - - -IDBObjectStore.add() - record with same key already exists - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add4.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add4.htm deleted file mode 100644 index 35d88fe3a2..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add4.htm +++ /dev/null @@ -1,40 +0,0 @@ - - -IDBObjectStore.add() - add where an index has unique:true specified - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add5.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add5.htm deleted file mode 100644 index 0cb124ff4b..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add5.htm +++ /dev/null @@ -1,34 +0,0 @@ - - -IDBObjectStore.add() - object store's key path is an object attribute - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add6.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add6.htm deleted file mode 100644 index b6ff5a5a50..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add6.htm +++ /dev/null @@ -1,47 +0,0 @@ - - -IDBObjectStore.add() - autoIncrement and inline keys - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add7.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add7.htm deleted file mode 100644 index cd63917c3f..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add7.htm +++ /dev/null @@ -1,47 +0,0 @@ - - -IDBObjectStore.add() - autoIncrement and out-of-line keys - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add8.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add8.htm deleted file mode 100644 index c827adf6ef..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add8.htm +++ /dev/null @@ -1,47 +0,0 @@ - - -IDBObjectStore.add() - object store has autoIncrement:true and the key path is an object attribute - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_add9.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_add9.htm deleted file mode 100644 index 27061afd9c..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_add9.htm +++ /dev/null @@ -1,27 +0,0 @@ - - -IDBObjectStore.add() - Attempt to add a record that does not meet the constraints of an object store's inline key requirements - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put.any.js b/testing/web-platform/tests/IndexedDB/idbobjectstore_put.any.js new file mode 100644 index 0000000000..89303291e9 --- /dev/null +++ b/testing/web-platform/tests/IndexedDB/idbobjectstore_put.any.js @@ -0,0 +1,427 @@ +// META: global=window,worker +// META: title=IDBObjectStore.put() +// META: script=resources/support.js +// @author Microsoft +// @author Intel + +'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("store", { keyPath: "key" }); + + objStore.put(record); + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", + { durability: 'relaxed' }) + .objectStore("store") + .get(record.key); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result.property, record.property); + assert_equals(e.target.result.key, record.key); + t.done(); + }); + }; +}, 'put() with an inline key'); + +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("store"); + + objStore.put(record, key); + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", {durability: 'relaxed'}) + .objectStore("store") + .get(key); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result.property, record.property); + + t.done(); + }); + }; +},'put() with an out-of-line key'); + +async_test(t => { + let db; + let success_event; + const record = { key: 1, property: "data" }; + const record_put = { key: 1, property: "changed", more: ["stuff", 2] }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + objStore.put(record); + + const rq = objStore.put(record_put); + rq.onerror = fail(t, "error on put"); + + rq.onsuccess = t.step_func(function(e) { + success_event = true; + }); + }; + + open_rq.onsuccess = function(e) { + assert_true(success_event); + + const rq = db.transaction("store", "readonly", + { durability: 'relaxed' }) + .objectStore("store") + .get(1); + + rq.onsuccess = t.step_func(function(e) { + const rec = e.target.result; + + assert_equals(rec.key, record_put.key); + assert_equals(rec.property, record_put.property); + assert_array_equals(rec.more, record_put.more); + + t.done(); + }); + }; +}, 'put() record with key already exists'); + +async_test(t => { + const record = { key: 1, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + const objStore = db.createObjectStore("store", { + autoIncrement: true }); + objStore.createIndex("i1", "property", { unique: true }); + objStore.put(record); + + const rq = objStore.put(record); + rq.onsuccess = fail(t, "success on putting duplicate indexed record"); + + rq.onerror = t.step_func(function(e) { + assert_equals(rq.error.name, "ConstraintError"); + assert_equals(e.target.error.name, "ConstraintError"); + + assert_equals(e.type, "error"); + + e.preventDefault(); + e.stopPropagation(); + }); + }; + + // Defer done, giving a spurious rq.onsuccess a chance to run + open_rq.onsuccess = function(e) { + t.done(); + }; +}, 'put() where an index has unique:true specified'); + +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("store", + { keyPath: "test.obj.key" }); + objStore.put(record); + }; + + open_rq.onsuccess = function(e) { + const rq = db.transaction("store", "readonly", + { durability: 'relaxed' }) + .objectStore("store") + .get(record.test.obj.key); + + rq.onsuccess = t.step_func(function(e) { + assert_equals(e.target.result.property, record.property); + + t.done(); + }); + }; +}, 'Object store\'s key path is an object attribute'); + +async_test(t => { + let db; + const record = { property: "data" }; + const expected_keys = [1, 2, 3, 4]; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "key", + autoIncrement: true }); + + objStore.put(record); + objStore.put(record); + objStore.put(record); + objStore.put(record); + }; + + open_rq.onsuccess = function(e) { + let actual_keys = []; + const rq = db.transaction("store", "readonly", { durability: 'relaxed' }) + .objectStore("store") + .openCursor(); + + rq.onsuccess = t.step_func(function(e) { + const cursor = e.target.result; + + if (cursor) { + actual_keys.push(cursor.value.key); + cursor.continue(); + } else { + assert_array_equals(actual_keys, expected_keys); + t.done(); + } + }); + }; + }, 'autoIncrement and inline keys'); + +async_test(t => { + let db; + const record = { property: "data" }; + const expected_keys = [1, 2, 3, 4]; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "key", + autoIncrement: true }); + + objStore.put(record); + objStore.put(record); + objStore.put(record); + objStore.put(record); + }; + + open_rq.onsuccess = function(e) { + const actual_keys = []; + const rq = db.transaction("store", "readonly", + { durability: 'relaxed' }) + .objectStore("store") + .openCursor(); + + rq.onsuccess = t.step_func(function(e) { + const cursor = e.target.result; + + if(cursor) { + actual_keys.push(cursor.value.key); + cursor.continue(); + } else { + assert_array_equals(actual_keys, expected_keys); + t.done(); + } + }); + }; +}, 'autoIncrement and out-of-line keys'); + +async_test(t => { + let db; + const record = { property: "data" }; + const expected_keys = [1, 2, 3, 4]; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + db = e.target.result; + const objStore = db.createObjectStore("store", + { keyPath: "test.obj.key", autoIncrement: true }); + + objStore.put(record); + objStore.put(record); + objStore.put(record); + objStore.put(record); + }; + + open_rq.onsuccess = function(e) { + const actual_keys = []; + const rq = db.transaction("store", "readonly", + { durability: 'relaxed' }) + .objectStore("store") + .openCursor(); + + rq.onsuccess = t.step_func(function(e) { + const cursor = e.target.result; + + if (cursor) { + actual_keys.push(cursor.value.test.obj.key); + cursor.continue(); + } else { + assert_array_equals(actual_keys, expected_keys); + t.done(); + } + }); + }; +}, 'Object store has autoIncrement:true and the key path is an object \ +attribute'); + +async_test(t => { + const record = { key: 1, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let rq; + const db = e.target.result; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + + assert_throws_dom("DataError", function() { + rq = objStore.put(record, 1); + }); + + assert_equals(rq, undefined); + t.done(); + }; +}, 'Attempt to put() a record that does not meet the constraints of an object \ +store\'s inline key requirements'); + +async_test(t => { + const record = { property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + let db = e.target.result; + + let rq; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + + assert_throws_dom("DataError", function() { + rq = objStore.put(record); + }); + + assert_equals(rq, undefined); + t.done(); + }; +}, 'Attempt to call put() without an key parameter when the object store uses \ +out-of-line keys'); + +async_test(t => { + const record = { key: { value: 1 }, property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + const db = e.target.result; + + let rq; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + + assert_throws_dom("DataError", function() { + rq = objStore.put(record); + }); + + assert_equals(rq, undefined); + t.done(); + }; +}, 'Attempt to put() a record where the record\'s key does not meet the \ +constraints of a valid key'); + +async_test(t => { + const record = { property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + const db = e.target.result; + + let rq; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + + assert_throws_dom("DataError", function() { + rq = objStore.put(record); + }); + + assert_equals(rq, undefined); + t.done(); + }; +}, 'Attempt to put() a record where the record\'s in-line key is not defined'); + +async_test(t => { + const record = { property: "data" }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + const db = e.target.result; + + let rq; + const objStore = db.createObjectStore("store"); + + assert_throws_dom("DataError", function() { + rq = objStore.put(record, { value: 1 }); + }); + + assert_equals(rq, undefined); + t.done(); + }; +}, 'Attempt to put() a record where the out of line key provided does not \ +meet the constraints of a valid key'); + +async_test(t => { + const record = { key: 1, indexedProperty: { property: "data" } }; + + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(e) { + const db = e.target.result; + + let rq; + const objStore = db.createObjectStore("store", { keyPath: "key" }); + + objStore.createIndex("index", "indexedProperty"); + + rq = objStore.put(record); + + assert_true(rq instanceof IDBRequest); + rq.onsuccess = function() { + t.done(); + }; + }; +}, 'put() a record where a value being indexed does not meet the constraints \ +of a valid key'); + +async_test(t => { + let db; + const open_rq = createdb(t); + open_rq.onupgradeneeded = function(event) { + db = event.target.result; + db.createObjectStore("store", { keyPath: "pKey" }); + }; + + 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.put({ pKey: "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 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.put({ pKey: "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_put.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put.htm deleted file mode 100644 index e277ce54a2..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put.htm +++ /dev/null @@ -1,35 +0,0 @@ - - -IDBObjectStore.put() - put with an inline key - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put10.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put10.htm deleted file mode 100644 index 6882e8e4b5..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put10.htm +++ /dev/null @@ -1,29 +0,0 @@ - - -IDBObjectStore.put() - Attempt to call 'put' without an key parameter when the object store uses out-of-line keys - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put11.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put11.htm deleted file mode 100644 index a5ed2db357..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put11.htm +++ /dev/null @@ -1,29 +0,0 @@ - - -IDBObjectStore.put() - Attempt to put a record where the record's key does not meet the constraints of a valid key - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put12.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put12.htm deleted file mode 100644 index 0693980277..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put12.htm +++ /dev/null @@ -1,29 +0,0 @@ - - -IDBObjectStore.put() - Attempt to put a record where the record's in-line key is not defined - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put13.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put13.htm deleted file mode 100644 index 8ae6561fc5..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put13.htm +++ /dev/null @@ -1,29 +0,0 @@ - - -IDBObjectStore.put() - Attempt to put a record where the out of line key provided does not meet the constraints of a valid key - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put14.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put14.htm deleted file mode 100644 index bc5647f4c1..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put14.htm +++ /dev/null @@ -1,32 +0,0 @@ - - -IDBObjectStore.put() - Put a record where a value being indexed does not meet the constraints of a valid key - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put15.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put15.htm deleted file mode 100644 index e7affaddd4..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put15.htm +++ /dev/null @@ -1,31 +0,0 @@ - - -IDBObjectStore.put() - If the transaction this IDBObjectStore belongs to has its mode set to readonly, throw ReadOnlyError - - - - - -
- - diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put16.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put16.htm deleted file mode 100644 index e298ba8849..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put16.htm +++ /dev/null @@ -1,25 +0,0 @@ - - -IDBObjectStore.put() - 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_put2.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put2.htm deleted file mode 100644 index 733e2cb154..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put2.htm +++ /dev/null @@ -1,36 +0,0 @@ - - -IDBObjectStore.put() - put with an out-of-line key - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put3.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put3.htm deleted file mode 100644 index b7792bdaf1..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put3.htm +++ /dev/null @@ -1,48 +0,0 @@ - - -IDBObjectStore.put() - record with same key already exists - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put4.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put4.htm deleted file mode 100644 index 4a59836eb6..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put4.htm +++ /dev/null @@ -1,40 +0,0 @@ - - -IDBObjectStore.put() - put where an index has unique:true specified - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put5.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put5.htm deleted file mode 100644 index 6e945e27d2..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put5.htm +++ /dev/null @@ -1,34 +0,0 @@ - - -IDBObjectStore.put() - object store's key path is an object attribute - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put6.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put6.htm deleted file mode 100644 index f0b6f0b98d..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put6.htm +++ /dev/null @@ -1,47 +0,0 @@ - - -IDBObjectStore.put() - autoIncrement and inline keys - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put7.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put7.htm deleted file mode 100644 index e41959f211..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put7.htm +++ /dev/null @@ -1,47 +0,0 @@ - - -IDBObjectStore.put() - autoIncrement and out-of-line keys - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put8.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put8.htm deleted file mode 100644 index 2bec639d32..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put8.htm +++ /dev/null @@ -1,47 +0,0 @@ - - -IDBObjectStore.put() - object store has autoIncrement:true and the key path is an object attribute - - - - - - - -
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_put9.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_put9.htm deleted file mode 100644 index dff9415d69..0000000000 --- a/testing/web-platform/tests/IndexedDB/idbobjectstore_put9.htm +++ /dev/null @@ -1,27 +0,0 @@ - - -IDBObjectStore.put() - Attempt to put a record that does not meet the constraints of an object store's inline key requirements - - - - - - - -
-- cgit v1.2.3