tor-browser

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

test_object_identity.js (1470B)


      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  let request = indexedDB.open(
     11    this.window ? window.location.pathname : "Splendid Test",
     12    1
     13  );
     14  request.onerror = errorHandler;
     15  request.onupgradeneeded = grabEventAndContinueHandler;
     16  let event = yield undefined;
     17 
     18  let db = event.target.result;
     19  let transaction = event.target.transaction;
     20 
     21  let objectStore1 = db.createObjectStore("foo");
     22  let objectStore2 = transaction.objectStore("foo");
     23  ok(objectStore1 === objectStore2, "Got same objectStores");
     24 
     25  let index1 = objectStore1.createIndex("bar", "key");
     26  let index2 = objectStore2.index("bar");
     27  ok(index1 === index2, "Got same indexes");
     28 
     29  request.onsuccess = continueToNextStep;
     30  yield undefined;
     31 
     32  transaction = db.transaction(db.objectStoreNames);
     33 
     34  let objectStore3 = transaction.objectStore("foo");
     35  let objectStore4 = transaction.objectStore("foo");
     36  ok(objectStore3 === objectStore4, "Got same objectStores");
     37 
     38  ok(objectStore3 !== objectStore1, "Different objectStores");
     39  ok(objectStore4 !== objectStore2, "Different objectStores");
     40 
     41  let index3 = objectStore3.index("bar");
     42  let index4 = objectStore4.index("bar");
     43  ok(index3 === index4, "Got same indexes");
     44 
     45  ok(index3 !== index1, "Different indexes");
     46  ok(index4 !== index2, "Different indexes");
     47 
     48  finishTest();
     49 }