tor-browser

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

idbobjectstore_keyPath.any.js (925B)


      1 // META: title=IndexedDB: IDBObjectStore keyPath attribute - same object
      2 // META: script=resources/support.js
      3 'use strict';
      4 
      5 indexeddb_test(
      6  (t, db) => {
      7    db.createObjectStore('store', {keyPath: ['a', 'b']});
      8  },
      9  (t, db) => {
     10    const tx = db.transaction('store', 'readonly');
     11    const store = tx.objectStore('store');
     12    assert_equals(typeof store.keyPath, 'object', 'keyPath is an object');
     13    assert_true(Array.isArray(store.keyPath), 'keyPath is an array');
     14 
     15    assert_equals(
     16      store.keyPath, store.keyPath,
     17      'Same object instance is returned each time keyPath is inspected');
     18 
     19    const tx2 = db.transaction('store', 'readonly');
     20    const store2 = tx2.objectStore('store');
     21 
     22    assert_not_equals(
     23      store.keyPath, store2.keyPath,
     24      'Different instances are returned from different store instances.');
     25 
     26    t.done();
     27  },
     28  `IDBObjectStore's keyPath attribute returns the same object.`);