tor-browser

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

transaction-lifetime-empty.any.js (2484B)


      1 // META: title=IndexedDB: Commit ordering of empty transactions
      2 // META: global=window,worker
      3 // META: script=resources/support.js
      4 
      5 'use strict';
      6 
      7 indexeddb_test(
      8    (t, db) => {
      9      db.createObjectStore('store');
     10    },
     11    (t, db) => {
     12      let saw = expect(t, [
     13        'rq1.onsuccess', 'rq2.onsuccess', 'tx1.oncomplete', 'tx2.oncomplete'
     14      ]);
     15 
     16      let tx1 = db.transaction('store', 'readwrite');
     17      tx1.onabort = t.unreached_func('transaction should commit');
     18      tx1.oncomplete = t.step_func(() => saw('tx1.oncomplete'));
     19 
     20      let store = tx1.objectStore('store');
     21      let rq1 = store.put('a', 1);
     22      rq1.onerror = t.unreached_func('put should succeed');
     23      rq1.onsuccess = t.step_func(() => {
     24        saw('rq1.onsuccess');
     25 
     26        let tx2 = db.transaction('store', 'readonly');
     27        tx2.onabort = t.unreached_func('transaction should commit');
     28        tx2.oncomplete = t.step_func(() => saw('tx2.oncomplete'));
     29 
     30        let rq2 = store.put('b', 2);
     31        rq2.onsuccess = t.step_func(() => saw('rq2.onsuccess'));
     32        rq2.onerror = t.unreached_func('request should succeed');
     33      });
     34    },
     35    'Transactions without requests complete in the expected order');
     36 
     37 indexeddb_test(
     38    (t, db) => {
     39      db.createObjectStore('store');
     40    },
     41    (t, db) => {
     42      let saw = expect(t, [
     43        'rq1.onsuccess', 'rq2.onsuccess', 'tx1.oncomplete', 'tx2.oncomplete',
     44        'tx3.oncomplete'
     45      ]);
     46      let tx1 = db.transaction('store', 'readwrite');
     47      tx1.onabort = t.unreached_func('transaction should commit');
     48      tx1.oncomplete = t.step_func(() => saw('tx1.oncomplete'));
     49 
     50      let store = tx1.objectStore('store');
     51      let rq1 = store.put('a', 1);
     52      rq1.onerror = t.unreached_func('put should succeed');
     53      rq1.onsuccess = t.step_func(() => {
     54        saw('rq1.onsuccess');
     55 
     56        let tx2 = db.transaction('store', 'readonly');
     57        tx2.onabort = t.unreached_func('transaction should commit');
     58        tx2.oncomplete = t.step_func(() => saw('tx2.oncomplete'));
     59 
     60        let tx3 = db.transaction('store', 'readonly');
     61        tx3.onabort = t.unreached_func('transaction should commit');
     62        tx3.oncomplete = t.step_func(() => saw('tx3.oncomplete'));
     63 
     64        let rq2 = store.put('b', 2);
     65        rq2.onsuccess = t.step_func(() => saw('rq2.onsuccess'));
     66        rq2.onerror = t.unreached_func('request should succeed');
     67      });
     68    },
     69    'Multiple transactions without requests complete in the expected order');