summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex7-event_order.htm
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex7-event_order.htm
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex7-event_order.htm')
-rw-r--r--testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex7-event_order.htm80
1 files changed, 80 insertions, 0 deletions
diff --git a/testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex7-event_order.htm b/testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex7-event_order.htm
new file mode 100644
index 0000000000..9be4c563f4
--- /dev/null
+++ b/testing/web-platform/tests/IndexedDB/idbobjectstore_createIndex7-event_order.htm
@@ -0,0 +1,80 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>IDBObjectStore.createIndex() - Event ordering for ConstraintError on request</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#dfn-steps-for-aborting-a-transaction>
+<meta rel=assert title="Unless error was set to null, create a DOMException object and set its name to error. Set transaction's error property to this newly created DOMException.">
+<meta rel=assert title="If the transaction's request list contain any requests whose done flag is still false, abort the steps for asynchronously executing a request for each such request and queue a task to perform the following steps:">
+<meta rel=assert title="set the request's error attribute to a DOMException with a type of AbortError.">
+<meta rel=assert title="Dispatch an event at request. The event must use the Event interface and have its type set to 'error'. The event bubbles and is cancelable. The propagation path for the event is transaction's connection, then transaction and finally the request. There is no default action for the event.">
+<meta rel=assert title="Queue up an operation to dispatch an event at transaction. The event must use the Event interface and have its type set to 'abort'. The event does bubble but is not cancelable. The propagation path for the event is transaction's connection and then transaction.">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/support.js"></script>
+
+<script>
+ // Transaction may fire window.onerror in some implementations.
+ setup({allow_uncaught_exception:true});
+
+ var db,
+ events = [],
+ t = async_test()
+
+ var open_rq = createdb(t);
+ open_rq.onupgradeneeded = function(e) {
+ db = e.target.result;
+ var txn = e.target.transaction;
+ db.onerror = log("db.error");
+ db.onabort = log("db.abort");
+ txn.onabort = log("transaction.abort")
+ txn.onerror = log("transaction.error")
+ txn.oncomplete = log("transaction.complete")
+
+ var 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");
+
+ objStore.createIndex("index", "animal", { unique: true })
+
+ var rq_add2 = objStore.add({ animal: "Unicorn" }, 2);
+ rq_add2.onsuccess = log("rq_add2.success");
+ rq_add2.onerror = log("rq_add2.error");
+
+ var rq_add3 = objStore.add({ animal: "Horse" }, 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.error: ConstraintError",
+ "transaction.error: ConstraintError",
+ "db.error: ConstraintError",
+
+ "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>