tor-browser

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

idbdatabase_transaction.any.js (2170B)


      1 // META: title=IDBDatabase.transaction()
      2 // META: global=window,worker
      3 // META: script=resources/support.js
      4 
      5 'use strict';
      6 
      7 async_test(t => {
      8    let db;
      9    const open_rq = createdb(t);
     10 
     11    open_rq.onupgradeneeded = function () { };
     12    open_rq.onsuccess = function (e) {
     13        db = e.target.result;
     14 
     15        assert_throws_dom('NotFoundError', function () { db.transaction('non-existing'); });
     16        t.done();
     17    };
     18 }, "Attempt to open a transaction with invalid scope");
     19 
     20 async_test(t => {
     21    let db;
     22    const open_rq = createdb(t);
     23 
     24    open_rq.onupgradeneeded = function (e) {
     25        db = e.target.result;
     26        db.createObjectStore('readonly');
     27    };
     28    open_rq.onsuccess = function (e) {
     29        var txn = db.transaction('readonly', 'readonly');
     30        assert_equals(txn.mode, "readonly", 'txn.mode');
     31 
     32        t.done();
     33    };
     34 }, "Opening a transaction defaults to a read-only mode");
     35 
     36 async_test(t => {
     37    let db;
     38    const open_rq = createdb(t);
     39 
     40    open_rq.onupgradeneeded = function (e) {
     41        db = e.target.result;
     42        db.createObjectStore('test');
     43    };
     44 
     45    open_rq.onsuccess = function (e) {
     46        db.close();
     47 
     48        assert_throws_dom('InvalidStateError',
     49            function () { db.transaction('test', 'readonly'); });
     50 
     51        t.done();
     52    };
     53 }, "Attempt to open a transaction from closed database connection");
     54 
     55 async_test(t => {
     56    let db;
     57    const open_rq = createdb(t);
     58 
     59    open_rq.onupgradeneeded = function (e) {
     60        db = e.target.result;
     61        db.createObjectStore('test');
     62    };
     63 
     64    open_rq.onsuccess = function (e) {
     65        assert_throws_js(TypeError,
     66            function () { db.transaction('test', 'whatever'); });
     67 
     68        t.done();
     69    };
     70 }, "Attempt to open a transaction with invalid mode");
     71 
     72 async_test(t => {
     73    let db;
     74    const open_rq = createdb(t);
     75 
     76    open_rq.onupgradeneeded = function () { };
     77    open_rq.onsuccess = function (e) {
     78        db = e.target.result;
     79        assert_throws_dom('InvalidAccessError', function () { db.transaction([]); });
     80        t.done();
     81    };
     82 }, "If storeNames is an empty list, the implementation must throw a DOMException of type InvalidAccessError");