tor-browser

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

idbcursor-continue-exception-order.any.js (2817B)


      1 // META: global=window,worker
      2 // META: title=IndexedDB: IDBCursor continue() Exception Ordering
      3 // META: script=resources/support.js
      4 
      5 // Spec: https://w3c.github.io/IndexedDB/#dom-idbcursor-continue
      6 
      7 'use strict';
      8 
      9 indexeddb_test(
     10    (t, db) => {
     11      const s = db.createObjectStore('s');
     12      s.put('value', 'key');
     13    },
     14    (t, db) => {
     15      const s = db.transaction('s', 'readonly').objectStore('s');
     16      const r = s.openKeyCursor();
     17      r.onsuccess = t.step_func(() => {
     18        r.onsuccess = null;
     19        const cursor = r.result;
     20        setTimeout(
     21            t.step_func(() => {
     22              assert_throws_dom(
     23                  'TransactionInactiveError',
     24                  () => {
     25                    cursor.continue({not: 'a valid key'});
     26                  },
     27                  '"Transaction inactive" check (TransactionInactiveError) ' +
     28                      'should precede "invalid key" check (DataError)');
     29              t.done();
     30            }),
     31            0);
     32      });
     33    },
     34    'IDBCursor.continue exception order: TransactionInactiveError vs. DataError');
     35 
     36 indexeddb_test(
     37    (t, db) => {
     38      const s = db.createObjectStore('s');
     39      s.put('value', 'key');
     40    },
     41    (t, db) => {
     42      const s = db.transaction('s', 'readonly').objectStore('s');
     43      const r = s.openKeyCursor();
     44      r.onsuccess = t.step_func(() => {
     45        r.onsuccess = null;
     46        const cursor = r.result;
     47        cursor.continue();
     48        r.onsuccess = t.step_func(() => {
     49          setTimeout(
     50              t.step_func(() => {
     51                assert_throws_dom(
     52                    'TransactionInactiveError',
     53                    () => {
     54                      cursor.continue();
     55                    },
     56                    '"Transaction inactive" check (TransactionInactiveError) ' +
     57                        'should precede "got value flag" check (InvalidStateError)');
     58                t.done();
     59              }),
     60              0);
     61        });
     62      });
     63    },
     64    'IDBCursor.continue exception order: TransactionInactiveError vs. InvalidStateError');
     65 
     66 indexeddb_test(
     67    (t, db) => {
     68      const s = db.createObjectStore('s');
     69      s.put('value', 'key');
     70    },
     71    (t, db) => {
     72      const s = db.transaction('s', 'readonly').objectStore('s');
     73      const r = s.openKeyCursor();
     74      r.onsuccess = t.step_func(() => {
     75        r.onsuccess = null;
     76        const cursor = r.result;
     77        cursor.continue();
     78        assert_throws_dom(
     79            'InvalidStateError',
     80            () => {
     81              cursor.continue({not: 'a valid key'});
     82            },
     83            '"got value flag" check (InvalidStateError) should precede ' +
     84                '"invalid key" check (DataError)');
     85        t.done();
     86      });
     87    },
     88    'IDBCursor.continue exception order: InvalidStateError vs. DataError');