tor-browser

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

blob-valid-after-deletion.any.js (1787B)


      1 // META: title=Blob Valid After Deletion
      2 // META: script=resources/support.js
      3 'use strict';
      4 
      5 let key = "key";
      6 
      7 indexeddb_test(
      8  function upgrade(t, db) {
      9    db.createObjectStore('store');
     10  },
     11  function success(t, db) {
     12    const blobAContent = "Blob A content";
     13    const blobBContent = "Blob B content";
     14    const blobA = new Blob([blobAContent], {"type" : "text/plain"});
     15    const blobB = new Blob([blobBContent], {"type" : "text/plain"});
     16    const value = { a0: blobA, a1: blobA, b0: blobB };
     17 
     18    const tx = db.transaction('store', 'readwrite');
     19    var store = tx.objectStore('store');
     20 
     21    store.put(value, key);
     22 
     23    const trans = db.transaction('store', 'readonly');
     24    store = trans.objectStore('store');
     25    const request = store.get(key);
     26 
     27    request.onsuccess = t.step_func(function() {
     28      const record = request.result;
     29 
     30      trans.oncomplete = t.step_func(function() {
     31        const trans = db.transaction('store', 'readwrite');
     32        store = trans.objectStore('store');
     33        const request = store.delete(key);
     34 
     35        trans.oncomplete = t.step_func(function() {
     36          const promise1 = record.a0.text().then(t.step_func(text => { assert_equals(text, blobAContent); },
     37            t.unreached_func()));
     38 
     39          const promise2 = record.a1.text().then(t.step_func(text => { assert_equals(text, blobAContent); },
     40            t.unreached_func()));
     41 
     42          const promise3 = record.b0.text().then(t.step_func(text => { assert_equals(text, blobBContent); },
     43            t.unreached_func()));
     44 
     45          Promise.all([promise1, promise2, promise3]).then(function() {
     46            // The test passes if it successfully completes.
     47            t.done();
     48          });
     49        });
     50      });
     51    });
     52  },
     53  "Blobs stay alive after their records are deleted.");