tor-browser

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

test_odd_result_order.js (1917B)


      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 data = { key: 5, index: 10 };
     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 
     22  ok(db instanceof IDBDatabase, "Got a real database");
     23 
     24  db.onerror = errorHandler;
     25 
     26  let objectStore = db.createObjectStore("foo", {
     27    keyPath: "key",
     28    autoIncrement: true,
     29  });
     30  objectStore.createIndex("foo", "index");
     31 
     32  event.target.onsuccess = continueToNextStep;
     33  yield undefined;
     34 
     35  objectStore = db.transaction("foo", "readwrite").objectStore("foo");
     36  request = objectStore.add(data);
     37  request.onsuccess = grabEventAndContinueHandler;
     38  event = yield undefined;
     39 
     40  let key;
     41  executeSoon(function () {
     42    key = request.result;
     43    continueToNextStep();
     44  });
     45  yield undefined;
     46 
     47  is(key, data.key, "Got the right key");
     48 
     49  objectStore = db.transaction("foo").objectStore("foo");
     50  objectStore.get(data.key).onsuccess = grabEventAndContinueHandler;
     51  event = yield undefined;
     52 
     53  let obj;
     54  executeSoon(function () {
     55    obj = event.target.result;
     56    continueToNextStep();
     57  });
     58  yield undefined;
     59 
     60  is(obj.key, data.key, "Got the right key");
     61  is(obj.index, data.index, "Got the right property value");
     62 
     63  objectStore = db.transaction("foo", "readwrite").objectStore("foo");
     64  request = objectStore.delete(data.key);
     65  request.onsuccess = grabEventAndContinueHandler;
     66  event = yield undefined;
     67 
     68  key = undefined;
     69  executeSoon(function () {
     70    key = request.result;
     71    continueToNextStep();
     72  }, 0);
     73  yield undefined;
     74 
     75  ok(key === undefined, "Got the right value");
     76 
     77  finishTest();
     78 }