tor-browser

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

idbobjectstore_openCursor.any.js (818B)


      1 // META: global=window,worker
      2 // META: title=IDBObjectStore.openCursor() - iterate through 100 objects
      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 = t.step_func(e => {
     12    db = e.target.result;
     13    let store = db.createObjectStore('store');
     14 
     15    for (let i = 0; i < 100; i++)
     16      store.add('record_' + i, i);
     17  });
     18 
     19  open_rq.onsuccess = t.step_func(e => {
     20    let count = 0;
     21    let txn = db.transaction('store', 'readonly');
     22 
     23    txn.objectStore('store').openCursor().onsuccess = t.step_func(function(e) {
     24      if (e.target.result) {
     25        count += 1;
     26        e.target.result.continue();
     27      }
     28    })
     29 
     30    txn.oncomplete = t.step_func(function() {
     31      assert_equals(count, 100);
     32      t.done();
     33    })
     34  });
     35 });