tor-browser

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

idbobjectstore-query-exception-order.any.js (2321B)


      1 // META: global=window,worker
      2 // META: title=IndexedDB: IDBObjectStore query method Ordering
      3 // META: script=resources/support.js
      4 
      5 // Spec: https://w3c.github.io/IndexedDB/#dom-idbobjectstore-get
      6 // Spec: https://w3c.github.io/IndexedDB/#dom-idbobjectstore-getall
      7 // Spec: https://w3c.github.io/IndexedDB/#dom-idbobjectstore-getallkeys
      8 // Spec: https://w3c.github.io/IndexedDB/#dom-idbobjectstore-count
      9 // Spec: https://w3c.github.io/IndexedDB/#dom-idbobjectstore-opencursor
     10 // Spec: https://w3c.github.io/IndexedDB/#dom-idbobjectstore-openkeycursor
     11 
     12 'use strict';
     13 
     14 ['get', 'getAll', 'getAllKeys', 'count', 'openCursor', 'openKeyCursor'].forEach(
     15    method => {
     16      indexeddb_test(
     17          (t, db) => {
     18            const store = db.createObjectStore('s');
     19            const store2 = db.createObjectStore('s2');
     20 
     21            db.deleteObjectStore('s2');
     22 
     23            setTimeout(
     24                t.step_func(() => {
     25                  assert_throws_dom(
     26                      'InvalidStateError',
     27                      () => {
     28                        store2[method]('key');
     29                      },
     30                      '"has been deleted" check (InvalidStateError) should precede ' +
     31                          '"not active" check (TransactionInactiveError)');
     32 
     33                  t.done();
     34                }),
     35                0);
     36          },
     37          (t, db) => {},
     38          `IDBObjectStore.${method} exception order: ` +
     39              'InvalidStateError vs. TransactionInactiveError');
     40 
     41      indexeddb_test(
     42          (t, db) => {
     43            const store = db.createObjectStore('s');
     44          },
     45          (t, db) => {
     46            const tx = db.transaction('s', 'readonly');
     47            const store = tx.objectStore('s');
     48 
     49            setTimeout(
     50                t.step_func(() => {
     51                  assert_throws_dom(
     52                      'TransactionInactiveError',
     53                      () => {
     54                        store[method]({});
     55                      },
     56                      '"not active" check (TransactionInactiveError) should precede ' +
     57                          'query check (DataError)');
     58                  t.done();
     59                }),
     60                0);
     61          },
     62          `IDBObjectStore.${method} exception order: ` +
     63              'TransactionInactiveError vs. DataError');
     64    });