tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

idbobjectstore-deleteIndex-exception-order.any.js (2332B)


      1 // META: global=window,worker
      2 // META: title=IndexedDB: IDBObjectStore deleteIndex() Exception Ordering
      3 // META: script=resources/support.js
      4 
      5 // Spec: https://w3c.github.io/IndexedDB/#dom-idbobjectstore-deleteindex
      6 
      7 'use strict';
      8 
      9 indexeddb_test(
     10    (t, db) => {
     11      const store = db.createObjectStore('s');
     12      store.createIndex('i', 'keyPath');
     13    },
     14    (t, db) => {
     15      const tx = db.transaction('s', 'readonly');
     16      const store = tx.objectStore('s');
     17 
     18      setTimeout(
     19          t.step_func(() => {
     20            assert_throws_dom(
     21                'InvalidStateError',
     22                () => {
     23                  store.deleteIndex('i');
     24                },
     25                '"running an upgrade transaction" check (InvalidStateError) ' +
     26                    'should precede "not active" check (TransactionInactiveError)');
     27            t.done();
     28          }),
     29          0);
     30    },
     31    'IDBObjectStore.deleteIndex exception order: ' +
     32        'InvalidStateError #1 vs. TransactionInactiveError');
     33 
     34 indexeddb_test(
     35    (t, db) => {
     36      const store = db.createObjectStore('s');
     37      const index = store.createIndex('i', 'keyPath');
     38 
     39      db.deleteObjectStore('s');
     40 
     41      setTimeout(
     42          t.step_func(() => {
     43            assert_throws_dom(
     44                'InvalidStateError',
     45                () => {
     46                  store.deleteIndex('i');
     47                },
     48                '"deleted" check (InvalidStateError) ' +
     49                    'should precede "not active" check (TransactionInactiveError)');
     50            t.done();
     51          }),
     52          0);
     53    },
     54    (t, db) => {},
     55    'IDBObjectStore.deleteIndex exception order: ' +
     56        'InvalidStateError #2 vs. TransactionInactiveError');
     57 
     58 indexeddb_test(
     59    (t, db) => {
     60      const store = db.createObjectStore('s');
     61 
     62      setTimeout(
     63          t.step_func(() => {
     64            assert_throws_dom(
     65                'TransactionInactiveError',
     66                () => {
     67                  store.deleteIndex('nope');
     68                },
     69                '"not active" check (TransactionInactiveError) should precede ' +
     70                    '"name in store" check (NotFoundError)');
     71            t.done();
     72          }),
     73          0);
     74    },
     75    (t, db) => {},
     76    'IDBObjectStore.deleteIndex exception order: ' +
     77        'TransactionInactiveError vs. NotFoundError');