summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex6-event_order.htm
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex6-event_order.htm
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex6-event_order.htm')
-rw-r--r--testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex6-event_order.htm75
1 files changed, 75 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex6-event_order.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex6-event_order.htm
new file mode 100644
index 000000000..3dcb7330a
--- /dev/null
+++ b/testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex6-event_order.htm
@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>IDBObjectStore.createIndex() - event order when unique constraint is triggered</title>
+<link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal">
+<meta rel=help href=http://odinho.html5.org/IndexedDB/spec/Overview.html#widl-IDBObjectStore-createIndex-IDBIndex-DOMString-name-any-keyPath-IDBIndexParameters-optionalParameters>
+<meta rel=assert title="The index that is requested to be created can contain constraints on the data allowed in the index's referenced object store, such as requiring uniqueness of the values referenced by the index's keyPath. If the referenced object store already contains data which violates these constraints, this must not cause the implementation of createIndex to throw an exception or affect what it returns. The implementation must still create and return an IDBIndex object. Instead the implementation must queue up an operation to abort the 'versionchange' transaction which was used for the createIndex call.">
+<meta rel=assert title="In some implementations it's possible for the implementation to asynchronously run into problems creating the index after the createIndex function has returned. For example in implementations where metadata about the newly created index is queued up to be inserted into the database asynchronously, or where the implementation might need to ask the user for permission for quota reasons. Such implementations must still create and return an IDBIndex object. Instead, once the implementation realizes that creating the index has failed, it must abort the transaction using the steps for aborting a transaction using the appropriate error as error parameter.">
+<meta rel=assert title="if the index can't be created due to unique constraints, ConstraintError must be used as error">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=support.js></script>
+
+<script>
+ // Transaction may fire window.onerror in some implementations.
+ setup({allow_uncaught_exception:true});
+
+ var db,
+ events = [],
+ t = async_test(document.title, {timeout: 10000})
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function(e) {
+ db = e.target.result;
+ db.onerror = log("db.error");
+ db.onabort = log("db.abort");
+ e.target.transaction.onabort = log("transaction.abort")
+ e.target.transaction.onerror = log("transaction.error")
+ e.target.transaction.oncomplete = log("transaction.complete")
+
+ var txn = e.target.transaction,
+ objStore = db.createObjectStore("store");
+
+ var rq_add1 = objStore.add({ animal: "Unicorn" }, 1);
+ rq_add1.onsuccess = log("rq_add1.success");
+ rq_add1.onerror = log("rq_add1.error");
+
+ var rq_add2 = objStore.add({ animal: "Unicorn" }, 2);
+ rq_add2.onsuccess = log("rq_add2.success");
+ rq_add2.onerror = log("rq_add2.error");
+
+ objStore.createIndex("index", "animal", { unique: true })
+
+ var rq_add3 = objStore.add({ animal: "Unicorn" }, 3);
+ rq_add3.onsuccess = log("rq_add3.success");
+ rq_add3.onerror = log("rq_add3.error");
+ }
+
+ open_rq.onerror = function(e) {
+ log("open_rq.error")(e);
+ assert_array_equals(events, [ "rq_add1.success",
+ "rq_add2.success",
+
+ "rq_add3.error: AbortError",
+ "transaction.error: AbortError",
+ "db.error: AbortError",
+
+ "transaction.abort: ConstraintError",
+ "db.abort: ConstraintError",
+
+ "open_rq.error: AbortError" ],
+ "events");
+ t.done();
+ }
+
+ function log(msg) {
+ return function(e) {
+ if(e && e.target && e.target.error)
+ events.push(msg + ": " + e.target.error.name);
+ else
+ events.push(msg);
+ };
+ }
+</script>
+
+<div id=log></div>