Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: LayoutTests/imported/web-platform-tests/IndexedDB/idbobjectstore_createIndex6-event_order.htm

Issue 560893005: First checked-in import of the W3C's test suites. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add new expectations for newly failing w3c tests Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>IDBObjectStore.createIndex() - event order when unique constraint is trig gered</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#widl-ID BObjectStore-createIndex-IDBIndex-DOMString-name-any-keyPath-IDBIndexParameters- optionalParameters>
6 <meta rel=assert title="The index that is requested to be created can contain co nstraints on the data allowed in the index's referenced object store, such as re quiring uniqueness of the values referenced by the index's keyPath. If the refer enced 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 ob ject. Instead the implementation must queue up an operation to abort the 'versio nchange' transaction which was used for the createIndex call.">
7 <meta rel=assert title="In some implementations it's possible for the implementa tion to asynchronously run into problems creating the index after the createInde x function has returned. For example in implementations where metadata about the newly created index is queued up to be inserted into the database asynchronousl y, or where the implementation might need to ask the user for permission for quo ta 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 t he appropriate error as error parameter.">
8 <meta rel=assert title="if the index can't be created due to unique constraints, ConstraintError must be used as error">
9 <script src=../../../resources/testharness.js></script>
10 <script src=../../../resources/testharnessreport.js></script>
11 <script src=support.js></script>
12
13 <script>
14 var db,
15 events = [],
16 t = async_test(document.title, {timeout: 10000})
17
18 var open_rq = createdb(t);
19 open_rq.onupgradeneeded = function(e) {
20 db = e.target.result;
21 db.onerror = log("db.error");
22 db.onabort = log("db.abort");
23 e.target.transaction.onabort = log("transaction.abort")
24 e.target.transaction.onerror = log("transaction.error")
25 e.target.transaction.oncomplete = log("transaction.complete")
26
27 var txn = e.target.transaction,
28 objStore = db.createObjectStore("store");
29
30 var rq_add1 = objStore.add({ animal: "Unicorn" }, 1);
31 rq_add1.onsuccess = log("rq_add1.success");
32 rq_add1.onerror = log("rq_add1.error");
33
34 var rq_add2 = objStore.add({ animal: "Unicorn" }, 2);
35 rq_add2.onsuccess = log("rq_add2.success");
36 rq_add2.onerror = log("rq_add2.error");
37
38 objStore.createIndex("index", "animal", { unique: true })
39
40 var rq_add3 = objStore.add({ animal: "Unicorn" }, 3);
41 rq_add3.onsuccess = log("rq_add3.success");
42 rq_add3.onerror = log("rq_add3.error");
43 }
44
45 open_rq.onerror = function(e) {
46 log("open_rq.error")(e);
47 assert_object_equals(events, [ "rq_add1.success",
48 "rq_add2.success",
49
50 "rq_add3.error: AbortError",
51 "transaction.error: AbortError",
52 "db.error: AbortError",
53
54 "transaction.abort: ConstraintError",
55 "db.abort: ConstraintError",
56
57 "open_rq.error: AbortError" ],
58 "events");
59 t.done();
60 }
61
62 function log(msg) {
63 return function(e) {
64 if(e && e.target && e.target.error)
65 events.push(msg + ": " + e.target.error.name);
66 else
67 events.push(msg);
68 };
69 }
70 </script>
71
72 <div id=log></div>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698