OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> |
| 3 <title>IDBObjectStore.createIndex() - Event ordering for ConstraintError on requ
est</title> |
| 4 <link rel="author" href="mailto:odinho@opera.com" title="Odin Hørthe Omdal"> |
| 5 <meta rel=help href=http://odinho.html5.org/IndexedDB/spec/Overview.html#dfn-ste
ps-for-aborting-a-transaction> |
| 6 <meta rel=assert title="Unless error was set to null, create a DOMError object a
nd set its name to error. Set transaction's error property to this newly created
DOMError."> |
| 7 <meta rel=assert title="If the transaction's request list contain any requests w
hose done flag is still false, abort the steps for asynchronously executing a re
quest for each such request and queue a task to perform the following steps:"> |
| 8 <meta rel=assert title="set the request's error attribute to a DOMError with a t
ype of AbortError."> |
| 9 <meta rel=assert title="Dispatch an event at request. The event must use the Eve
nt interface and have its type set to 'error'. The event bubbles and is cancelab
le. The propagation path for the event is transaction's connection, then transac
tion and finally the request. There is no default action for the event."> |
| 10 <meta rel=assert title="Queue up an operation to dispatch an event at transactio
n. 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 t
ransaction's connection and then transaction."> |
| 11 <script src="../../../resources/testharness.js"></script> |
| 12 <script src="../../../resources/testharnessreport.js"></script> |
| 13 <script src="support.js"></script> |
| 14 |
| 15 <script> |
| 16 var db, |
| 17 events = [], |
| 18 t = async_test(document.title, {timeout: 10000}) |
| 19 |
| 20 var open_rq = createdb(t); |
| 21 open_rq.onupgradeneeded = function(e) { |
| 22 db = e.target.result; |
| 23 var txn = e.target.transaction; |
| 24 db.onerror = log("db.error"); |
| 25 db.onabort = log("db.abort"); |
| 26 txn.onabort = log("transaction.abort") |
| 27 txn.onerror = log("transaction.error") |
| 28 txn.oncomplete = log("transaction.complete") |
| 29 |
| 30 var objStore = db.createObjectStore("store"); |
| 31 |
| 32 var rq_add1 = objStore.add({ animal: "Unicorn" }, 1); |
| 33 rq_add1.onsuccess = log("rq_add1.success"); |
| 34 rq_add1.onerror = log("rq_add1.error"); |
| 35 |
| 36 objStore.createIndex("index", "animal", { unique: true }) |
| 37 |
| 38 var rq_add2 = objStore.add({ animal: "Unicorn" }, 2); |
| 39 rq_add2.onsuccess = log("rq_add2.success"); |
| 40 rq_add2.onerror = log("rq_add2.error"); |
| 41 |
| 42 var rq_add3 = objStore.add({ animal: "Horse" }, 3); |
| 43 rq_add3.onsuccess = log("rq_add3.success"); |
| 44 rq_add3.onerror = log("rq_add3.error"); |
| 45 } |
| 46 |
| 47 open_rq.onerror = function(e) { |
| 48 log("open_rq.error")(e); |
| 49 assert_object_equals(events, [ "rq_add1.success", |
| 50 |
| 51 "rq_add2.error: ConstraintError", |
| 52 "transaction.error: ConstraintError", |
| 53 "db.error: ConstraintError", |
| 54 |
| 55 "rq_add3.error: AbortError", |
| 56 "transaction.error: AbortError", |
| 57 "db.error: AbortError", |
| 58 |
| 59 "transaction.abort: ConstraintError", |
| 60 "db.abort: ConstraintError", |
| 61 |
| 62 "open_rq.error: AbortError" ], |
| 63 "events"); |
| 64 t.done(); |
| 65 } |
| 66 |
| 67 function log(msg) { |
| 68 return function(e) { |
| 69 if(e && e.target && e.target.error) |
| 70 events.push(msg + ": " + e.target.error.name); |
| 71 else |
| 72 events.push(msg); |
| 73 }; |
| 74 } |
| 75 </script> |
| 76 |
| 77 <div id="log"></div> |
OLD | NEW |