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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/IndexedDB/idbdatabase-createObjectStore-exception-order.htm

Issue 2659513002: Upstream an assortment of IndexedDB tests to WPT. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>IndexedDB: IDBDatabase createObjectStore() Exception Ordering</title> 2 <title>IndexedDB: IDBDatabase createObjectStore() Exception Ordering</title>
3 <meta charset=utf-8> 3 <meta charset=utf-8>
4 <link rel="help" href="https://w3c.github.io/IndexedDB/#dom-idbdatabase-createob jectstore"> 4 <link rel="help" href="https://w3c.github.io/IndexedDB/#dom-idbdatabase-createob jectstore">
5 <script src="../../resources/testharness.js"></script> 5 <script src="/resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 6 <script src="/resources/testharnessreport.js"></script>
7 <script src="resources/testharness-helpers.js"></script> 7 <script src="support.js"></script>
8 <script> 8 <script>
9 9
10 indexeddb_test( 10 indexeddb_test(
11 (t, db, req) => { 11 (t, db, txn) => {
12 db.createObjectStore('s'); 12 db.createObjectStore('s');
13 13
14 req.transaction.onabort = () => { 14 txn.onabort = () => {
15 setTimeout(t.step_func(() => { 15 setTimeout(t.step_func(() => {
16 assert_throws( 16 assert_throws(
17 'InvalidStateError', () => { db.createObjectStore('s2'); }, 17 'InvalidStateError', () => { db.createObjectStore('s2'); },
18 '"running an upgrade transaction" check (InvalidStateError) ' + 18 '"running an upgrade transaction" check (InvalidStateError) ' +
19 'should precede "not active" check (TransactionInactiveError)'); 19 'should precede "not active" check (TransactionInactiveError)');
20 20
21 t.done(); 21 t.done();
22 }), 0); 22 }), 0);
23 }; 23 };
24 req.onerror = null; 24 txn.abort();
25 req.transaction.abort();
26 }, 25 },
27 (t, db) => { t.assert_unreached('open should fail'); }, 26 (t, db) => { t.assert_unreached('open should fail'); },
28 'IDBDatabase.createObjectStore exception order: ' + 27 'IDBDatabase.createObjectStore exception order: ' +
29 'InvalidStateError vs. TransactionInactiveError' 28 'InvalidStateError vs. TransactionInactiveError'
30 ); 29 );
31 30
32 indexeddb_test( 31 indexeddb_test(
33 (t, db, req) => { 32 (t, db, txn) => {
34 const store = db.createObjectStore('s'); 33 const store = db.createObjectStore('s');
35 34
36 req.onerror = null; 35 txn.onerror = null;
jsbell 2017/01/26 19:27:29 Is txn.onerror set or was this an accidental conve
pwnall 2017/01/27 00:01:52 Accidental. Thanks for catching this!
37 req.transaction.abort(); 36 txn.abort();
38 37
39 assert_throws( 38 assert_throws(
40 'TransactionInactiveError', 39 'TransactionInactiveError',
41 () => { db.createObjectStore('s2', {keyPath: '-invalid-'}); }, 40 () => { db.createObjectStore('s2', {keyPath: '-invalid-'}); },
42 '"not active" check (TransactionInactiveError) should precede ' + 41 '"not active" check (TransactionInactiveError) should precede ' +
43 '"valid key path" check (SyntaxError)'); 42 '"valid key path" check (SyntaxError)');
44 43
45 t.done(); 44 t.done();
46 }, 45 },
47 (t, db) => { t.assert_unreached('open should fail'); }, 46 (t, db) => { t.assert_unreached('open should fail'); },
(...skipping 12 matching lines...) Expand all
60 }, 59 },
61 (t, db) => {}, 60 (t, db) => {},
62 'IDBDatabase.createObjectStore exception order: ' + 61 'IDBDatabase.createObjectStore exception order: ' +
63 'SyntaxError vs. ConstraintError' 62 'SyntaxError vs. ConstraintError'
64 ); 63 );
65 64
66 indexeddb_test( 65 indexeddb_test(
67 (t, db) => { 66 (t, db) => {
68 db.createObjectStore('s'); 67 db.createObjectStore('s');
69 assert_throws('ConstraintError', () => { 68 assert_throws('ConstraintError', () => {
70 db.createObjectStore('s', {autoIncrement: true, 69 db.createObjectStore('s', {autoIncrement: true, keyPath: ''});
71 keyPath: ''});
72 }, '"already exists" check (ConstraintError) should precede ' + 70 }, '"already exists" check (ConstraintError) should precede ' +
73 '"autoIncrement vs. keyPath" check (InvalidAccessError)'); 71 '"autoIncrement vs. keyPath" check (InvalidAccessError)');
74 t.done(); 72 t.done();
75 }, 73 },
76 (t, db) => {}, 74 (t, db) => {},
77 'IDBDatabase.createObjectStore exception order: ' + 75 'IDBDatabase.createObjectStore exception order: ' +
78 'ConstraintError vs. InvalidAccessError' 76 'ConstraintError vs. InvalidAccessError'
79 ); 77 );
80 78
81 </script> 79 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698