tor-browser

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

idbcursor-key.any.js (1060B)


      1 // META: global=window,worker
      2 // META: title=IDBCursor.key
      3 // META: script=resources/support.js
      4 
      5 'use strict';
      6 
      7 function cursor_key(key) {
      8  async_test(t => {
      9    let db;
     10    const open_rq = createdb(t);
     11    open_rq.onupgradeneeded = function(e) {
     12      db = e.target.result;
     13      const objStore = db.createObjectStore('test');
     14      objStore.add('data', key);
     15    };
     16 
     17    open_rq.onsuccess = t.step_func((e) => {
     18      const cursor_rq =
     19          db.transaction('test', 'readonly').objectStore('test').openCursor();
     20 
     21      cursor_rq.onsuccess = t.step_func((e) => {
     22        const cursor = e.target.result;
     23        assert_equals(cursor.value, 'data', 'prerequisite cursor.value');
     24 
     25        assert_key_equals(cursor.key, key, 'key');
     26        assert_readonly(cursor, 'key');
     27 
     28        if (key instanceof Array) {
     29          cursor.key.push('new');
     30          key.push('new');
     31 
     32          assert_key_equals(cursor.key, key, 'key after array push');
     33        }
     34 
     35        t.done();
     36      });
     37    });
     38  });
     39 }
     40 
     41 cursor_key(1);
     42 cursor_key('key');
     43 cursor_key(['my', 'key']);