tor-browser

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

test_cursor_cycle.js (1266B)


      1 /**
      2 * Any copyright is dedicated to the Public Domain.
      3 * http://creativecommons.org/publicdomain/zero/1.0/
      4 */
      5 
      6 /* exported testGenerator */
      7 var testGenerator = testSteps();
      8 
      9 function* testSteps() {
     10  const Bob = { ss: "237-23-7732", name: "Bob" };
     11 
     12  let request = indexedDB.open(
     13    this.window ? window.location.pathname : "Splendid Test",
     14    1
     15  );
     16  request.onerror = errorHandler;
     17  request.onupgradeneeded = grabEventAndContinueHandler;
     18  let event = yield undefined;
     19 
     20  let db = event.target.result;
     21  event.target.onsuccess = continueToNextStep;
     22 
     23  let objectStore = db.createObjectStore("foo", { keyPath: "ss" });
     24  objectStore.createIndex("name", "name", { unique: true });
     25  objectStore.add(Bob);
     26  yield undefined;
     27 
     28  db
     29    .transaction("foo", "readwrite")
     30    .objectStore("foo")
     31    .index("name")
     32    .openCursor().onsuccess = function (event) {
     33    event.target.transaction.oncomplete = continueToNextStep;
     34    let cursor = event.target.result;
     35    if (cursor) {
     36      let objectStore = event.target.transaction.objectStore("foo");
     37      objectStore.delete(Bob.ss).onsuccess = function () {
     38        cursor.continue();
     39      };
     40    }
     41  };
     42  yield undefined;
     43  finishTest();
     44 
     45  objectStore = null; // Bug 943409 workaround.
     46 
     47  yield undefined;
     48 }