tor-browser

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

idbindex-query-exception-order.any.js (2079B)


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