tor-browser

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

idbobjectstore_getAllRecords.any.js (4819B)


      1 // META: title=IndexedDB: Test IDBObjectStore.getAllRecords
      2 // META: global=window,worker
      3 // META: script=resources/nested-cloning-common.js
      4 // META: script=resources/support.js
      5 // META: script=resources/support-get-all.js
      6 // META: script=resources/support-promises.js
      7 // META: timeout=long
      8 
      9 'use strict';
     10 
     11 object_store_get_all_records_test(
     12    /*storeName=*/ 'out-of-line', /*options=*/ {query: /*key=*/ 'c'},
     13    'Single item');
     14 
     15 object_store_get_all_records_test(
     16    /*storeName=*/ 'generated', /*options=*/ {query: /*key=*/ 3},
     17    'Single item with generated key');
     18 
     19 object_store_get_all_records_test(
     20    /*storeName=*/ 'empty', /*options=*/ undefined, 'Empty object store');
     21 
     22 object_store_get_all_records_test(
     23    /*storeName=*/ 'out-of-line', /*options=*/ undefined, 'Get all records');
     24 
     25 object_store_get_all_records_test(
     26    /*storeName=*/ 'out-of-line', /*options=*/ {},
     27    'Get all records with empty options');
     28 
     29 object_store_get_all_records_test(
     30    /*storeName=*/ 'large-values', /*options=*/ undefined,
     31    'Get all records with large values');
     32 
     33 object_store_get_all_records_test(
     34    /*storeName=*/ 'out-of-line', /*options=*/ {count: 10}, 'Count');
     35 
     36 object_store_get_all_records_test(
     37    /*storeName=*/ 'out-of-line',
     38    /*options=*/ {query: IDBKeyRange.bound('g', 'm')},
     39    'Query with bound range');
     40 
     41 object_store_get_all_records_test(
     42    /*storeName=*/ 'out-of-line',
     43    /*options=*/ {query: IDBKeyRange.bound('g', 'm'), count: 3},
     44    'Query with bound range and count');
     45 
     46 object_store_get_all_records_test(
     47    /*storeName=*/ 'out-of-line',
     48    /*options=*/ {
     49      query:
     50          IDBKeyRange.bound('g', 'k', /*lowerOpen=*/ false, /*upperOpen=*/ true)
     51    },
     52    'Query with upper excluded bound range');
     53 
     54 object_store_get_all_records_test(
     55    /*storeName=*/ 'out-of-line',
     56    /*options=*/ {
     57      query:
     58          IDBKeyRange.bound('g', 'k', /*lowerOpen=*/ true, /*upperOpen=*/ false)
     59    },
     60    'Query with lower excluded bound range');
     61 
     62 object_store_get_all_records_test(
     63    /*storeName=*/ 'generated',
     64    /*options=*/ {query: IDBKeyRange.bound(4, 15), count: 3},
     65    'Query with bound range and count for generated keys');
     66 
     67 object_store_get_all_records_test(
     68    /*storeName=*/ 'out-of-line', /*options=*/ {query: 'Doesn\'t exist'},
     69    'Query with nonexistent key');
     70 
     71 object_store_get_all_records_test(
     72    /*storeName=*/ 'out-of-line', /*options=*/ {count: 0}, 'Zero count');
     73 
     74 object_store_get_all_records_test(
     75    /*storeName=*/ 'out-of-line', /*options=*/ {count: 4294967295},
     76    'Max value count');
     77 
     78 object_store_get_all_records_test(
     79    /*storeName=*/ 'out-of-line',
     80    /*options=*/ {query: IDBKeyRange.upperBound('0')},
     81    'Query with empty range where first key < upperBound');
     82 
     83 object_store_get_all_records_test(
     84    /*storeName=*/ 'out-of-line',
     85    /*options=*/ {query: IDBKeyRange.lowerBound('zz')},
     86    'Query with empty range where lowerBound < last key');
     87 
     88 object_store_get_all_records_test(
     89    /*storeName=*/ 'out-of-line', /*options=*/ {direction: 'next'},
     90    'Direction: next');
     91 
     92 object_store_get_all_records_test(
     93    /*storeName=*/ 'out-of-line', /*options=*/ {direction: 'prev'},
     94    'Direction: prev');
     95 
     96 object_store_get_all_records_test(
     97    /*storeName=*/ 'out-of-line', /*options=*/ {direction: 'nextunique'},
     98    'Direction: nextunique');
     99 
    100 object_store_get_all_records_test(
    101    /*storeName=*/ 'out-of-line', /*options=*/ {direction: 'prevunique'},
    102    'Direction: prevunique');
    103 
    104 object_store_get_all_records_test(
    105    /*storeName=*/ 'out-of-line', /*options=*/ {
    106      direction: 'prev',
    107      query: IDBKeyRange.bound('b', 'x'),
    108    },
    109    'Direction and query');
    110 
    111 object_store_get_all_records_test(
    112    /*storeName=*/ 'out-of-line', /*options=*/ {
    113      direction: 'prev',
    114      query: IDBKeyRange.bound('b', 'x'),
    115      count: 4
    116    },
    117    'Direction, query and count');
    118 
    119 object_store_get_all_test_setup(
    120    /*storeName=*/ 'out-of-line', (test, connection, expectedRecords) => {
    121      const transaction = connection.transaction('out-of-line', 'readonly');
    122      const store = transaction.objectStore('out-of-line');
    123      const request = store.getAllRecords();
    124      transaction.commit();
    125 
    126      transaction.oncomplete =
    127          test.unreached_func('transaction completed before request succeeded');
    128 
    129      request.onerror =
    130          test.unreached_func('getAllRecords request must  succeed');
    131 
    132      request.onsuccess = test.step_func((event) => {
    133        const actualResults = event.target.result;
    134        assert_records_equals(actualResults, expectedRecords);
    135        test.done();
    136      });
    137    }, 'Get all records with transaction.commit()');
    138 
    139 get_all_with_invalid_keys_test(
    140    'getAllRecords', /*storeName=*/ 'out-of-line', /*indexName=*/ undefined,
    141    /*shouldUseDictionary=*/ true, 'Get all records with invalid query keys');