d06efe1d2f91e7bc77a8c0ade62c9bc62d6d1702
[gecko.git] / idbdatabase-transaction-exception-order.html
blobd06efe1d2f91e7bc77a8c0ade62c9bc62d6d1702
1 <!doctype html>
2 <meta charset=utf-8>
3 <title>IndexedDB: IDBDatabase transaction() Exception Ordering</title>
4 <link rel="help" href="https://w3c.github.io/IndexedDB/#dom-idbdatabase-transaction">
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <script src="resources/support.js"></script>
8 <script>
10 indexeddb_test(
11 (t, db) => {
12 db.createObjectStore('s');
14 (t, db) => {
15 db.close();
16 assert_throws_dom('InvalidStateError', () => {
17 db.transaction('no-such-store');
18 }, '"Connection is closed" check (InvalidStateError) should precede ' +
19 '"store names" check (NotFoundError)');
20 t.done();
22 'IDBDatabase.transaction exception order: InvalidStateError vs. NotFoundError'
25 indexeddb_test(
26 (t, db) => {
27 db.createObjectStore('s');
29 (t, db) => {
30 db.close();
31 assert_throws_dom('InvalidStateError', () => {
32 db.transaction([]);
33 }, '"Connection is closed" check (InvalidStateError) should precede ' +
34 '"stores is empty" check (InvalidAccessError)');
35 t.done();
37 'IDBDatabase.transaction exception order: InvalidStateError vs. InvalidAccessError'
40 // Verify that the invalid mode check actually throws an exception
41 indexeddb_test(
42 (t, db) => {
43 db.createObjectStore('s');
45 (t, db) => {
46 assert_throws_js(TypeError, () => {
47 db.transaction('s', 'versionchange');
48 }, '"invalid mode" check should throw TypeError');
49 t.done();
51 'IDBDatabase.transaction throws exception on invalid mode'
54 indexeddb_test(
55 (t, db) => {
56 db.createObjectStore('s');
58 (t, db) => {
59 assert_throws_dom('NotFoundError', () => {
60 db.transaction('no-such-store', 'versionchange');
61 }, '"No such store" check (NotFoundError) should precede ' +
62 '"invalid mode" check (TypeError)');
63 t.done();
65 'IDBDatabase.transaction exception order: NotFoundError vs. TypeError'
68 </script>