tor-browser

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

transaction-scheduling-ordering.any.js (1137B)


      1 // META: script=resources/support.js
      2 'use strict';
      3 
      4 indexeddb_test(
      5  (t, db) => {
      6    const store = db.createObjectStore('store');
      7  },
      8 
      9  (t, db) => {
     10    // Create in order tx1, tx2.
     11    const tx1 = db.transaction('store', 'readwrite');
     12    const tx2 = db.transaction('store', 'readwrite');
     13 
     14    // Use in order tx2, tx1.
     15    tx2.objectStore('store').get(0);
     16    tx1.objectStore('store').get(0);
     17 
     18    const order = [];
     19    const done = barrier_func(2, t.step_func_done(() => {
     20      // IndexedDB Spec:
     21      // https://w3c.github.io/IndexedDB/#transaction-scheduling
     22      //
     23      // If multiple "readwrite" transactions are attempting to
     24      // access the same object store (i.e. if they have overlapping
     25      // scope), the transaction that was created first must be the
     26      // transaction which gets access to the object store first.
     27      //
     28      assert_array_equals(order, [1, 2]);
     29    }));
     30 
     31    tx1.oncomplete = t.step_func(e => {
     32      order.push(1);
     33      done();
     34    });
     35 
     36    tx2.oncomplete = t.step_func(e => {
     37      order.push(2);
     38      done();
     39    });
     40  },
     41  "Verify Indexed DB transactions are ordered per spec");