tor-browser

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

idbobjectstore-delete-exception-order.any.js (2152B)


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