tor-browser

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

test_optionalArguments.js (43096B)


      1 /**
      2 * Any copyright is dedicated to the Public Domain.
      3 * http://creativecommons.org/publicdomain/zero/1.0/
      4 */
      5 
      6 var testGenerator = testSteps();
      7 
      8 function* testSteps() {
      9  const osName = "people";
     10  const indexName = "weight";
     11 
     12  const data = [
     13    { ssn: "237-23-7732", name: "Bob", height: 60, weight: 120 },
     14    { ssn: "237-23-7733", name: "Ann", height: 52, weight: 110 },
     15    { ssn: "237-23-7734", name: "Ron", height: 73, weight: 180 },
     16    { ssn: "237-23-7735", name: "Sue", height: 58, weight: 130 },
     17    { ssn: "237-23-7736", name: "Joe", height: 65, weight: 150 },
     18    { ssn: "237-23-7737", name: "Pat", height: 65 },
     19    { ssn: "237-23-7738", name: "Mel", height: 66, weight: {} },
     20    { ssn: "237-23-7739", name: "Tom", height: 62, weight: 130 },
     21  ];
     22 
     23  const weightSort = [1, 0, 3, 7, 4, 2];
     24 
     25  let request = indexedDB.open(
     26    this.window ? window.location.pathname : "Splendid Test",
     27    1
     28  );
     29  request.onerror = errorHandler;
     30  request.onupgradeneeded = grabEventAndContinueHandler;
     31  request.onsuccess = grabEventAndContinueHandler;
     32  let event = yield undefined;
     33 
     34  is(event.type, "upgradeneeded", "Got upgradeneeded event");
     35 
     36  let db = event.target.result;
     37  db.onerror = errorHandler;
     38 
     39  let objectStore = db.createObjectStore(osName, { keyPath: "ssn" });
     40  objectStore.createIndex(indexName, "weight", { unique: false });
     41 
     42  for (let i of data) {
     43    objectStore.add(i);
     44  }
     45 
     46  event = yield undefined;
     47 
     48  is(event.type, "success", "Got success event");
     49 
     50  try {
     51    IDBKeyRange.bound(1, -1);
     52    ok(false, "Bound keyRange with backwards args should throw!");
     53  } catch (e) {
     54    is(e.name, "DataError", "Threw correct exception");
     55    is(e.code, 0, "Threw with correct code");
     56  }
     57 
     58  try {
     59    IDBKeyRange.bound(1, 1);
     60    ok(true, "Bound keyRange with same arg should be ok");
     61  } catch (e) {
     62    ok(false, "Bound keyRange with same arg should have been ok");
     63  }
     64 
     65  try {
     66    IDBKeyRange.bound(1, 1, true);
     67    ok(false, "Bound keyRange with same arg and open should throw!");
     68  } catch (e) {
     69    is(e.name, "DataError", "Threw correct exception");
     70    is(e.code, 0, "Threw with correct code");
     71  }
     72 
     73  try {
     74    IDBKeyRange.bound(1, 1, true, true);
     75    ok(false, "Bound keyRange with same arg and open should throw!");
     76  } catch (e) {
     77    is(e.name, "DataError", "Threw correct exception");
     78    is(e.code, 0, "Threw with correct code");
     79  }
     80 
     81  objectStore = db.transaction(osName).objectStore(osName);
     82 
     83  try {
     84    objectStore.get();
     85    ok(false, "Get with unspecified arg should have thrown");
     86  } catch (e) {
     87    ok(true, "Get with unspecified arg should have thrown");
     88  }
     89 
     90  try {
     91    objectStore.get(undefined);
     92    ok(false, "Get with undefined should have thrown");
     93  } catch (e) {
     94    ok(true, "Get with undefined arg should have thrown");
     95  }
     96 
     97  try {
     98    objectStore.get(null);
     99    ok(false, "Get with null should have thrown");
    100  } catch (e) {
    101    is(e instanceof DOMException, true, "Got right kind of exception");
    102    is(e.name, "DataError", "Correct error.");
    103    is(e.code, 0, "Correct code.");
    104  }
    105 
    106  objectStore.get(data[2].ssn).onsuccess = grabEventAndContinueHandler;
    107  event = yield undefined;
    108 
    109  is(event.target.result.name, data[2].name, "Correct data");
    110 
    111  let keyRange = IDBKeyRange.only(data[2].ssn);
    112 
    113  objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
    114  event = yield undefined;
    115 
    116  is(event.target.result.name, data[2].name, "Correct data");
    117 
    118  keyRange = IDBKeyRange.lowerBound(data[2].ssn);
    119 
    120  objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
    121  event = yield undefined;
    122 
    123  is(event.target.result.name, data[2].name, "Correct data");
    124 
    125  keyRange = IDBKeyRange.lowerBound(data[2].ssn, true);
    126 
    127  objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
    128  event = yield undefined;
    129 
    130  is(event.target.result.name, data[3].name, "Correct data");
    131 
    132  keyRange = IDBKeyRange.upperBound(data[2].ssn);
    133 
    134  objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
    135  event = yield undefined;
    136 
    137  is(event.target.result.name, data[0].name, "Correct data");
    138 
    139  keyRange = IDBKeyRange.bound(data[2].ssn, data[4].ssn);
    140 
    141  objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
    142  event = yield undefined;
    143 
    144  is(event.target.result.name, data[2].name, "Correct data");
    145 
    146  keyRange = IDBKeyRange.bound(data[2].ssn, data[4].ssn, true);
    147 
    148  objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
    149  event = yield undefined;
    150 
    151  is(event.target.result.name, data[3].name, "Correct data");
    152 
    153  objectStore = db.transaction(osName, "readwrite").objectStore(osName);
    154 
    155  try {
    156    objectStore.delete();
    157    ok(false, "Delete with unspecified arg should have thrown");
    158  } catch (e) {
    159    ok(true, "Delete with unspecified arg should have thrown");
    160  }
    161 
    162  try {
    163    objectStore.delete(undefined);
    164    ok(false, "Delete with undefined should have thrown");
    165  } catch (e) {
    166    ok(true, "Delete with undefined arg should have thrown");
    167  }
    168 
    169  try {
    170    objectStore.delete(null);
    171    ok(false, "Delete with null should have thrown");
    172  } catch (e) {
    173    is(e instanceof DOMException, true, "Got right kind of exception");
    174    is(e.name, "DataError", "Correct error.");
    175    is(e.code, 0, "Correct code.");
    176  }
    177 
    178  objectStore.count().onsuccess = grabEventAndContinueHandler;
    179  event = yield undefined;
    180 
    181  is(event.target.result, data.length, "Correct count");
    182 
    183  objectStore.delete(data[2].ssn).onsuccess = grabEventAndContinueHandler;
    184  event = yield undefined;
    185 
    186  ok(event.target.result === undefined, "Correct result");
    187 
    188  objectStore.count().onsuccess = grabEventAndContinueHandler;
    189  event = yield undefined;
    190 
    191  is(event.target.result, data.length - 1, "Correct count");
    192 
    193  keyRange = IDBKeyRange.bound(data[3].ssn, data[5].ssn);
    194 
    195  objectStore.delete(keyRange).onsuccess = grabEventAndContinueHandler;
    196  event = yield undefined;
    197 
    198  ok(event.target.result === undefined, "Correct result");
    199 
    200  objectStore.count().onsuccess = grabEventAndContinueHandler;
    201  event = yield undefined;
    202 
    203  is(event.target.result, data.length - 4, "Correct count");
    204 
    205  keyRange = IDBKeyRange.lowerBound(10);
    206 
    207  objectStore.delete(keyRange).onsuccess = grabEventAndContinueHandler;
    208  event = yield undefined;
    209 
    210  ok(event.target.result === undefined, "Correct result");
    211 
    212  objectStore.count().onsuccess = grabEventAndContinueHandler;
    213  event = yield undefined;
    214 
    215  is(event.target.result, 0, "Correct count");
    216 
    217  event.target.transaction.oncomplete = grabEventAndContinueHandler;
    218 
    219  for (let i of data) {
    220    objectStore.add(i);
    221  }
    222 
    223  yield undefined;
    224 
    225  objectStore = db.transaction(osName).objectStore(osName);
    226 
    227  objectStore.count().onsuccess = grabEventAndContinueHandler;
    228  event = yield undefined;
    229 
    230  is(event.target.result, data.length, "Correct count");
    231 
    232  let count = 0;
    233 
    234  objectStore.openCursor().onsuccess = function (event) {
    235    let cursor = event.target.result;
    236    if (cursor) {
    237      count++;
    238      cursor.continue();
    239    } else {
    240      testGenerator.next();
    241    }
    242  };
    243  yield undefined;
    244 
    245  is(count, data.length, "Correct count for no arg to openCursor");
    246 
    247  count = 0;
    248 
    249  objectStore.openCursor(null).onsuccess = function (event) {
    250    let cursor = event.target.result;
    251    if (cursor) {
    252      count++;
    253      cursor.continue();
    254    } else {
    255      testGenerator.next();
    256    }
    257  };
    258  yield undefined;
    259 
    260  is(count, data.length, "Correct count for null arg to openCursor");
    261 
    262  count = 0;
    263 
    264  objectStore.openCursor(undefined).onsuccess = function (event) {
    265    let cursor = event.target.result;
    266    if (cursor) {
    267      count++;
    268      cursor.continue();
    269    } else {
    270      testGenerator.next();
    271    }
    272  };
    273  yield undefined;
    274 
    275  is(count, data.length, "Correct count for undefined arg to openCursor");
    276 
    277  count = 0;
    278 
    279  objectStore.openCursor(data[2].ssn).onsuccess = function (event) {
    280    let cursor = event.target.result;
    281    if (cursor) {
    282      count++;
    283      cursor.continue();
    284    } else {
    285      testGenerator.next();
    286    }
    287  };
    288  yield undefined;
    289 
    290  is(count, 1, "Correct count for single key arg to openCursor");
    291 
    292  count = 0;
    293 
    294  objectStore.openCursor("foo").onsuccess = function (event) {
    295    let cursor = event.target.result;
    296    if (cursor) {
    297      count++;
    298      cursor.continue();
    299    } else {
    300      testGenerator.next();
    301    }
    302  };
    303  yield undefined;
    304 
    305  is(count, 0, "Correct count for non-existent single key arg to openCursor");
    306 
    307  count = 0;
    308  keyRange = IDBKeyRange.only(data[2].ssn);
    309 
    310  objectStore.openCursor(keyRange).onsuccess = function (event) {
    311    let cursor = event.target.result;
    312    if (cursor) {
    313      count++;
    314      cursor.continue();
    315    } else {
    316      testGenerator.next();
    317    }
    318  };
    319  yield undefined;
    320 
    321  is(count, 1, "Correct count for only keyRange arg to openCursor");
    322 
    323  count = 0;
    324  keyRange = IDBKeyRange.lowerBound(data[2].ssn);
    325 
    326  objectStore.openCursor(keyRange).onsuccess = function (event) {
    327    let cursor = event.target.result;
    328    if (cursor) {
    329      count++;
    330      cursor.continue();
    331    } else {
    332      testGenerator.next();
    333    }
    334  };
    335  yield undefined;
    336 
    337  is(count, data.length - 2, "Correct count for lowerBound arg to openCursor");
    338 
    339  count = 0;
    340  keyRange = IDBKeyRange.lowerBound(data[2].ssn, true);
    341 
    342  objectStore.openCursor(keyRange).onsuccess = function (event) {
    343    let cursor = event.target.result;
    344    if (cursor) {
    345      count++;
    346      cursor.continue();
    347    } else {
    348      testGenerator.next();
    349    }
    350  };
    351  yield undefined;
    352 
    353  is(count, data.length - 3, "Correct count for lowerBound arg to openCursor");
    354 
    355  count = 0;
    356  keyRange = IDBKeyRange.lowerBound("foo");
    357 
    358  objectStore.openCursor(keyRange).onsuccess = function (event) {
    359    let cursor = event.target.result;
    360    if (cursor) {
    361      count++;
    362      cursor.continue();
    363    } else {
    364      testGenerator.next();
    365    }
    366  };
    367  yield undefined;
    368 
    369  is(count, 0, "Correct count for non-existent lowerBound arg to openCursor");
    370 
    371  count = 0;
    372  keyRange = IDBKeyRange.bound(data[2].ssn, data[3].ssn);
    373 
    374  objectStore.openCursor(keyRange).onsuccess = function (event) {
    375    let cursor = event.target.result;
    376    if (cursor) {
    377      count++;
    378      cursor.continue();
    379    } else {
    380      testGenerator.next();
    381    }
    382  };
    383  yield undefined;
    384 
    385  is(count, 2, "Correct count for bound arg to openCursor");
    386 
    387  count = 0;
    388  keyRange = IDBKeyRange.bound(data[2].ssn, data[3].ssn, true);
    389 
    390  objectStore.openCursor(keyRange).onsuccess = function (event) {
    391    let cursor = event.target.result;
    392    if (cursor) {
    393      count++;
    394      cursor.continue();
    395    } else {
    396      testGenerator.next();
    397    }
    398  };
    399  yield undefined;
    400 
    401  is(count, 1, "Correct count for bound arg to openCursor");
    402 
    403  count = 0;
    404  keyRange = IDBKeyRange.bound(data[2].ssn, data[3].ssn, true, true);
    405 
    406  objectStore.openCursor(keyRange).onsuccess = function (event) {
    407    let cursor = event.target.result;
    408    if (cursor) {
    409      count++;
    410      cursor.continue();
    411    } else {
    412      testGenerator.next();
    413    }
    414  };
    415  yield undefined;
    416 
    417  is(count, 0, "Correct count for bound arg to openCursor");
    418 
    419  let index = objectStore.index(indexName);
    420 
    421  count = 0;
    422 
    423  index.openKeyCursor().onsuccess = function (event) {
    424    let cursor = event.target.result;
    425    if (cursor) {
    426      count++;
    427      cursor.continue();
    428    } else {
    429      testGenerator.next();
    430    }
    431  };
    432  yield undefined;
    433 
    434  is(
    435    count,
    436    weightSort.length,
    437    "Correct count for unspecified arg to index.openKeyCursor"
    438  );
    439 
    440  count = 0;
    441 
    442  index.openKeyCursor(null).onsuccess = function (event) {
    443    let cursor = event.target.result;
    444    if (cursor) {
    445      count++;
    446      cursor.continue();
    447    } else {
    448      testGenerator.next();
    449    }
    450  };
    451  yield undefined;
    452 
    453  is(
    454    count,
    455    weightSort.length,
    456    "Correct count for null arg to index.openKeyCursor"
    457  );
    458 
    459  count = 0;
    460 
    461  index.openKeyCursor(undefined).onsuccess = function (event) {
    462    let cursor = event.target.result;
    463    if (cursor) {
    464      count++;
    465      cursor.continue();
    466    } else {
    467      testGenerator.next();
    468    }
    469  };
    470  yield undefined;
    471 
    472  is(
    473    count,
    474    weightSort.length,
    475    "Correct count for undefined arg to index.openKeyCursor"
    476  );
    477 
    478  count = 0;
    479 
    480  index.openKeyCursor(data[0].weight).onsuccess = function (event) {
    481    let cursor = event.target.result;
    482    if (cursor) {
    483      count++;
    484      cursor.continue();
    485    } else {
    486      testGenerator.next();
    487    }
    488  };
    489  yield undefined;
    490 
    491  is(count, 1, "Correct count for single key arg to index.openKeyCursor");
    492 
    493  count = 0;
    494 
    495  index.openKeyCursor("foo").onsuccess = function (event) {
    496    let cursor = event.target.result;
    497    if (cursor) {
    498      count++;
    499      cursor.continue();
    500    } else {
    501      testGenerator.next();
    502    }
    503  };
    504  yield undefined;
    505 
    506  is(count, 0, "Correct count for non-existent key arg to index.openKeyCursor");
    507 
    508  count = 0;
    509  keyRange = IDBKeyRange.only("foo");
    510 
    511  index.openKeyCursor(keyRange).onsuccess = function (event) {
    512    let cursor = event.target.result;
    513    if (cursor) {
    514      count++;
    515      cursor.continue();
    516    } else {
    517      testGenerator.next();
    518    }
    519  };
    520  yield undefined;
    521 
    522  is(
    523    count,
    524    0,
    525    "Correct count for non-existent keyRange arg to index.openKeyCursor"
    526  );
    527 
    528  count = 0;
    529  keyRange = IDBKeyRange.only(data[0].weight);
    530 
    531  index.openKeyCursor(keyRange).onsuccess = function (event) {
    532    let cursor = event.target.result;
    533    if (cursor) {
    534      count++;
    535      cursor.continue();
    536    } else {
    537      testGenerator.next();
    538    }
    539  };
    540  yield undefined;
    541 
    542  is(count, 1, "Correct count for only keyRange arg to index.openKeyCursor");
    543 
    544  count = 0;
    545  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
    546 
    547  index.openKeyCursor(keyRange).onsuccess = function (event) {
    548    let cursor = event.target.result;
    549    if (cursor) {
    550      count++;
    551      cursor.continue();
    552    } else {
    553      testGenerator.next();
    554    }
    555  };
    556  yield undefined;
    557 
    558  is(
    559    count,
    560    weightSort.length,
    561    "Correct count for lowerBound keyRange arg to index.openKeyCursor"
    562  );
    563 
    564  count = 0;
    565  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
    566 
    567  index.openKeyCursor(keyRange).onsuccess = function (event) {
    568    let cursor = event.target.result;
    569    if (cursor) {
    570      count++;
    571      cursor.continue();
    572    } else {
    573      testGenerator.next();
    574    }
    575  };
    576  yield undefined;
    577 
    578  is(
    579    count,
    580    weightSort.length - 1,
    581    "Correct count for lowerBound keyRange arg to index.openKeyCursor"
    582  );
    583 
    584  count = 0;
    585  keyRange = IDBKeyRange.lowerBound("foo");
    586 
    587  index.openKeyCursor(keyRange).onsuccess = function (event) {
    588    let cursor = event.target.result;
    589    if (cursor) {
    590      count++;
    591      cursor.continue();
    592    } else {
    593      testGenerator.next();
    594    }
    595  };
    596  yield undefined;
    597 
    598  is(
    599    count,
    600    0,
    601    "Correct count for lowerBound keyRange arg to index.openKeyCursor"
    602  );
    603 
    604  count = 0;
    605  keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight);
    606 
    607  index.openKeyCursor(keyRange).onsuccess = function (event) {
    608    let cursor = event.target.result;
    609    if (cursor) {
    610      count++;
    611      cursor.continue();
    612    } else {
    613      testGenerator.next();
    614    }
    615  };
    616  yield undefined;
    617 
    618  is(
    619    count,
    620    1,
    621    "Correct count for upperBound keyRange arg to index.openKeyCursor"
    622  );
    623 
    624  count = 0;
    625  keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
    626 
    627  index.openKeyCursor(keyRange).onsuccess = function (event) {
    628    let cursor = event.target.result;
    629    if (cursor) {
    630      count++;
    631      cursor.continue();
    632    } else {
    633      testGenerator.next();
    634    }
    635  };
    636  yield undefined;
    637 
    638  is(
    639    count,
    640    0,
    641    "Correct count for upperBound keyRange arg to index.openKeyCursor"
    642  );
    643 
    644  count = 0;
    645  keyRange = IDBKeyRange.upperBound(
    646    data[weightSort[weightSort.length - 1]].weight
    647  );
    648 
    649  index.openKeyCursor(keyRange).onsuccess = function (event) {
    650    let cursor = event.target.result;
    651    if (cursor) {
    652      count++;
    653      cursor.continue();
    654    } else {
    655      testGenerator.next();
    656    }
    657  };
    658  yield undefined;
    659 
    660  is(
    661    count,
    662    weightSort.length,
    663    "Correct count for upperBound keyRange arg to index.openKeyCursor"
    664  );
    665 
    666  count = 0;
    667  keyRange = IDBKeyRange.upperBound(
    668    data[weightSort[weightSort.length - 1]].weight,
    669    true
    670  );
    671 
    672  index.openKeyCursor(keyRange).onsuccess = function (event) {
    673    let cursor = event.target.result;
    674    if (cursor) {
    675      count++;
    676      cursor.continue();
    677    } else {
    678      testGenerator.next();
    679    }
    680  };
    681  yield undefined;
    682 
    683  is(
    684    count,
    685    weightSort.length - 1,
    686    "Correct count for upperBound keyRange arg to index.openKeyCursor"
    687  );
    688 
    689  count = 0;
    690  keyRange = IDBKeyRange.upperBound("foo");
    691 
    692  index.openKeyCursor(keyRange).onsuccess = function (event) {
    693    let cursor = event.target.result;
    694    if (cursor) {
    695      count++;
    696      cursor.continue();
    697    } else {
    698      testGenerator.next();
    699    }
    700  };
    701  yield undefined;
    702 
    703  is(
    704    count,
    705    weightSort.length,
    706    "Correct count for upperBound keyRange arg to index.openKeyCursor"
    707  );
    708 
    709  count = 0;
    710  keyRange = IDBKeyRange.upperBound(0);
    711 
    712  index.openKeyCursor(keyRange).onsuccess = function (event) {
    713    let cursor = event.target.result;
    714    if (cursor) {
    715      count++;
    716      cursor.continue();
    717    } else {
    718      testGenerator.next();
    719    }
    720  };
    721  yield undefined;
    722 
    723  is(
    724    count,
    725    0,
    726    "Correct count for upperBound keyRange arg to index.openKeyCursor"
    727  );
    728 
    729  count = 0;
    730  keyRange = IDBKeyRange.bound(
    731    data[weightSort[0]].weight,
    732    data[weightSort[weightSort.length - 1]].weight
    733  );
    734 
    735  index.openKeyCursor(keyRange).onsuccess = function (event) {
    736    let cursor = event.target.result;
    737    if (cursor) {
    738      count++;
    739      cursor.continue();
    740    } else {
    741      testGenerator.next();
    742    }
    743  };
    744  yield undefined;
    745 
    746  is(
    747    count,
    748    weightSort.length,
    749    "Correct count for bound keyRange arg to index.openKeyCursor"
    750  );
    751 
    752  count = 0;
    753  keyRange = IDBKeyRange.bound(
    754    data[weightSort[0]].weight,
    755    data[weightSort[weightSort.length - 1]].weight,
    756    true
    757  );
    758 
    759  index.openKeyCursor(keyRange).onsuccess = function (event) {
    760    let cursor = event.target.result;
    761    if (cursor) {
    762      count++;
    763      cursor.continue();
    764    } else {
    765      testGenerator.next();
    766    }
    767  };
    768  yield undefined;
    769 
    770  is(
    771    count,
    772    weightSort.length - 1,
    773    "Correct count for bound keyRange arg to index.openKeyCursor"
    774  );
    775 
    776  count = 0;
    777  keyRange = IDBKeyRange.bound(
    778    data[weightSort[0]].weight,
    779    data[weightSort[weightSort.length - 1]].weight,
    780    true,
    781    true
    782  );
    783 
    784  index.openKeyCursor(keyRange).onsuccess = function (event) {
    785    let cursor = event.target.result;
    786    if (cursor) {
    787      count++;
    788      cursor.continue();
    789    } else {
    790      testGenerator.next();
    791    }
    792  };
    793  yield undefined;
    794 
    795  is(
    796    count,
    797    weightSort.length - 2,
    798    "Correct count for bound keyRange arg to index.openKeyCursor"
    799  );
    800 
    801  count = 0;
    802  keyRange = IDBKeyRange.bound(
    803    data[weightSort[0]].weight - 1,
    804    data[weightSort[weightSort.length - 1]].weight + 1
    805  );
    806 
    807  index.openKeyCursor(keyRange).onsuccess = function (event) {
    808    let cursor = event.target.result;
    809    if (cursor) {
    810      count++;
    811      cursor.continue();
    812    } else {
    813      testGenerator.next();
    814    }
    815  };
    816  yield undefined;
    817 
    818  is(
    819    count,
    820    weightSort.length,
    821    "Correct count for bound keyRange arg to index.openKeyCursor"
    822  );
    823 
    824  count = 0;
    825  keyRange = IDBKeyRange.bound(
    826    data[weightSort[0]].weight - 2,
    827    data[weightSort[0]].weight - 1
    828  );
    829 
    830  index.openKeyCursor(keyRange).onsuccess = function (event) {
    831    let cursor = event.target.result;
    832    if (cursor) {
    833      count++;
    834      cursor.continue();
    835    } else {
    836      testGenerator.next();
    837    }
    838  };
    839  yield undefined;
    840 
    841  is(count, 0, "Correct count for bound keyRange arg to index.openKeyCursor");
    842 
    843  count = 0;
    844  keyRange = IDBKeyRange.bound(
    845    data[weightSort[1]].weight,
    846    data[weightSort[2]].weight
    847  );
    848 
    849  index.openKeyCursor(keyRange).onsuccess = function (event) {
    850    let cursor = event.target.result;
    851    if (cursor) {
    852      count++;
    853      cursor.continue();
    854    } else {
    855      testGenerator.next();
    856    }
    857  };
    858  yield undefined;
    859 
    860  is(count, 3, "Correct count for bound keyRange arg to index.openKeyCursor");
    861 
    862  count = 0;
    863 
    864  index.openCursor().onsuccess = function (event) {
    865    let cursor = event.target.result;
    866    if (cursor) {
    867      count++;
    868      cursor.continue();
    869    } else {
    870      testGenerator.next();
    871    }
    872  };
    873  yield undefined;
    874 
    875  is(
    876    count,
    877    weightSort.length,
    878    "Correct count for unspecified arg to index.openCursor"
    879  );
    880 
    881  count = 0;
    882 
    883  index.openCursor(null).onsuccess = function (event) {
    884    let cursor = event.target.result;
    885    if (cursor) {
    886      count++;
    887      cursor.continue();
    888    } else {
    889      testGenerator.next();
    890    }
    891  };
    892  yield undefined;
    893 
    894  is(
    895    count,
    896    weightSort.length,
    897    "Correct count for null arg to index.openCursor"
    898  );
    899 
    900  count = 0;
    901 
    902  index.openCursor(undefined).onsuccess = function (event) {
    903    let cursor = event.target.result;
    904    if (cursor) {
    905      count++;
    906      cursor.continue();
    907    } else {
    908      testGenerator.next();
    909    }
    910  };
    911  yield undefined;
    912 
    913  is(
    914    count,
    915    weightSort.length,
    916    "Correct count for undefined arg to index.openCursor"
    917  );
    918 
    919  count = 0;
    920 
    921  index.openCursor(data[0].weight).onsuccess = function (event) {
    922    let cursor = event.target.result;
    923    if (cursor) {
    924      count++;
    925      cursor.continue();
    926    } else {
    927      testGenerator.next();
    928    }
    929  };
    930  yield undefined;
    931 
    932  is(count, 1, "Correct count for single key arg to index.openCursor");
    933 
    934  count = 0;
    935 
    936  index.openCursor("foo").onsuccess = function (event) {
    937    let cursor = event.target.result;
    938    if (cursor) {
    939      count++;
    940      cursor.continue();
    941    } else {
    942      testGenerator.next();
    943    }
    944  };
    945  yield undefined;
    946 
    947  is(count, 0, "Correct count for non-existent key arg to index.openCursor");
    948 
    949  count = 0;
    950  keyRange = IDBKeyRange.only("foo");
    951 
    952  index.openCursor(keyRange).onsuccess = function (event) {
    953    let cursor = event.target.result;
    954    if (cursor) {
    955      count++;
    956      cursor.continue();
    957    } else {
    958      testGenerator.next();
    959    }
    960  };
    961  yield undefined;
    962 
    963  is(
    964    count,
    965    0,
    966    "Correct count for non-existent keyRange arg to index.openCursor"
    967  );
    968 
    969  count = 0;
    970  keyRange = IDBKeyRange.only(data[0].weight);
    971 
    972  index.openCursor(keyRange).onsuccess = function (event) {
    973    let cursor = event.target.result;
    974    if (cursor) {
    975      count++;
    976      cursor.continue();
    977    } else {
    978      testGenerator.next();
    979    }
    980  };
    981  yield undefined;
    982 
    983  is(count, 1, "Correct count for only keyRange arg to index.openCursor");
    984 
    985  count = 0;
    986  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
    987 
    988  index.openCursor(keyRange).onsuccess = function (event) {
    989    let cursor = event.target.result;
    990    if (cursor) {
    991      count++;
    992      cursor.continue();
    993    } else {
    994      testGenerator.next();
    995    }
    996  };
    997  yield undefined;
    998 
    999  is(
   1000    count,
   1001    weightSort.length,
   1002    "Correct count for lowerBound keyRange arg to index.openCursor"
   1003  );
   1004 
   1005  count = 0;
   1006  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
   1007 
   1008  index.openCursor(keyRange).onsuccess = function (event) {
   1009    let cursor = event.target.result;
   1010    if (cursor) {
   1011      count++;
   1012      cursor.continue();
   1013    } else {
   1014      testGenerator.next();
   1015    }
   1016  };
   1017  yield undefined;
   1018 
   1019  is(
   1020    count,
   1021    weightSort.length - 1,
   1022    "Correct count for lowerBound keyRange arg to index.openCursor"
   1023  );
   1024 
   1025  count = 0;
   1026  keyRange = IDBKeyRange.lowerBound("foo");
   1027 
   1028  index.openCursor(keyRange).onsuccess = function (event) {
   1029    let cursor = event.target.result;
   1030    if (cursor) {
   1031      count++;
   1032      cursor.continue();
   1033    } else {
   1034      testGenerator.next();
   1035    }
   1036  };
   1037  yield undefined;
   1038 
   1039  is(count, 0, "Correct count for lowerBound keyRange arg to index.openCursor");
   1040 
   1041  count = 0;
   1042  keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight);
   1043 
   1044  index.openCursor(keyRange).onsuccess = function (event) {
   1045    let cursor = event.target.result;
   1046    if (cursor) {
   1047      count++;
   1048      cursor.continue();
   1049    } else {
   1050      testGenerator.next();
   1051    }
   1052  };
   1053  yield undefined;
   1054 
   1055  is(count, 1, "Correct count for upperBound keyRange arg to index.openCursor");
   1056 
   1057  count = 0;
   1058  keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
   1059 
   1060  index.openCursor(keyRange).onsuccess = function (event) {
   1061    let cursor = event.target.result;
   1062    if (cursor) {
   1063      count++;
   1064      cursor.continue();
   1065    } else {
   1066      testGenerator.next();
   1067    }
   1068  };
   1069  yield undefined;
   1070 
   1071  is(count, 0, "Correct count for upperBound keyRange arg to index.openCursor");
   1072 
   1073  count = 0;
   1074  keyRange = IDBKeyRange.upperBound(
   1075    data[weightSort[weightSort.length - 1]].weight
   1076  );
   1077 
   1078  index.openCursor(keyRange).onsuccess = function (event) {
   1079    let cursor = event.target.result;
   1080    if (cursor) {
   1081      count++;
   1082      cursor.continue();
   1083    } else {
   1084      testGenerator.next();
   1085    }
   1086  };
   1087  yield undefined;
   1088 
   1089  is(
   1090    count,
   1091    weightSort.length,
   1092    "Correct count for upperBound keyRange arg to index.openCursor"
   1093  );
   1094 
   1095  count = 0;
   1096  keyRange = IDBKeyRange.upperBound(
   1097    data[weightSort[weightSort.length - 1]].weight,
   1098    true
   1099  );
   1100 
   1101  index.openCursor(keyRange).onsuccess = function (event) {
   1102    let cursor = event.target.result;
   1103    if (cursor) {
   1104      count++;
   1105      cursor.continue();
   1106    } else {
   1107      testGenerator.next();
   1108    }
   1109  };
   1110  yield undefined;
   1111 
   1112  is(
   1113    count,
   1114    weightSort.length - 1,
   1115    "Correct count for upperBound keyRange arg to index.openCursor"
   1116  );
   1117 
   1118  count = 0;
   1119  keyRange = IDBKeyRange.upperBound("foo");
   1120 
   1121  index.openCursor(keyRange).onsuccess = function (event) {
   1122    let cursor = event.target.result;
   1123    if (cursor) {
   1124      count++;
   1125      cursor.continue();
   1126    } else {
   1127      testGenerator.next();
   1128    }
   1129  };
   1130  yield undefined;
   1131 
   1132  is(
   1133    count,
   1134    weightSort.length,
   1135    "Correct count for upperBound keyRange arg to index.openCursor"
   1136  );
   1137 
   1138  count = 0;
   1139  keyRange = IDBKeyRange.upperBound(0);
   1140 
   1141  index.openCursor(keyRange).onsuccess = function (event) {
   1142    let cursor = event.target.result;
   1143    if (cursor) {
   1144      count++;
   1145      cursor.continue();
   1146    } else {
   1147      testGenerator.next();
   1148    }
   1149  };
   1150  yield undefined;
   1151 
   1152  is(count, 0, "Correct count for upperBound keyRange arg to index.openCursor");
   1153 
   1154  count = 0;
   1155  keyRange = IDBKeyRange.bound(
   1156    data[weightSort[0]].weight,
   1157    data[weightSort[weightSort.length - 1]].weight
   1158  );
   1159 
   1160  index.openCursor(keyRange).onsuccess = function (event) {
   1161    let cursor = event.target.result;
   1162    if (cursor) {
   1163      count++;
   1164      cursor.continue();
   1165    } else {
   1166      testGenerator.next();
   1167    }
   1168  };
   1169  yield undefined;
   1170 
   1171  is(
   1172    count,
   1173    weightSort.length,
   1174    "Correct count for bound keyRange arg to index.openCursor"
   1175  );
   1176 
   1177  count = 0;
   1178  keyRange = IDBKeyRange.bound(
   1179    data[weightSort[0]].weight,
   1180    data[weightSort[weightSort.length - 1]].weight,
   1181    true
   1182  );
   1183 
   1184  index.openCursor(keyRange).onsuccess = function (event) {
   1185    let cursor = event.target.result;
   1186    if (cursor) {
   1187      count++;
   1188      cursor.continue();
   1189    } else {
   1190      testGenerator.next();
   1191    }
   1192  };
   1193  yield undefined;
   1194 
   1195  is(
   1196    count,
   1197    weightSort.length - 1,
   1198    "Correct count for bound keyRange arg to index.openCursor"
   1199  );
   1200 
   1201  count = 0;
   1202  keyRange = IDBKeyRange.bound(
   1203    data[weightSort[0]].weight,
   1204    data[weightSort[weightSort.length - 1]].weight,
   1205    true,
   1206    true
   1207  );
   1208 
   1209  index.openCursor(keyRange).onsuccess = function (event) {
   1210    let cursor = event.target.result;
   1211    if (cursor) {
   1212      count++;
   1213      cursor.continue();
   1214    } else {
   1215      testGenerator.next();
   1216    }
   1217  };
   1218  yield undefined;
   1219 
   1220  is(
   1221    count,
   1222    weightSort.length - 2,
   1223    "Correct count for bound keyRange arg to index.openCursor"
   1224  );
   1225 
   1226  count = 0;
   1227  keyRange = IDBKeyRange.bound(
   1228    data[weightSort[0]].weight - 1,
   1229    data[weightSort[weightSort.length - 1]].weight + 1
   1230  );
   1231 
   1232  index.openCursor(keyRange).onsuccess = function (event) {
   1233    let cursor = event.target.result;
   1234    if (cursor) {
   1235      count++;
   1236      cursor.continue();
   1237    } else {
   1238      testGenerator.next();
   1239    }
   1240  };
   1241  yield undefined;
   1242 
   1243  is(
   1244    count,
   1245    weightSort.length,
   1246    "Correct count for bound keyRange arg to index.openCursor"
   1247  );
   1248 
   1249  count = 0;
   1250  keyRange = IDBKeyRange.bound(
   1251    data[weightSort[0]].weight - 2,
   1252    data[weightSort[0]].weight - 1
   1253  );
   1254 
   1255  index.openCursor(keyRange).onsuccess = function (event) {
   1256    let cursor = event.target.result;
   1257    if (cursor) {
   1258      count++;
   1259      cursor.continue();
   1260    } else {
   1261      testGenerator.next();
   1262    }
   1263  };
   1264  yield undefined;
   1265 
   1266  is(count, 0, "Correct count for bound keyRange arg to index.openCursor");
   1267 
   1268  count = 0;
   1269  keyRange = IDBKeyRange.bound(
   1270    data[weightSort[1]].weight,
   1271    data[weightSort[2]].weight
   1272  );
   1273 
   1274  index.openCursor(keyRange).onsuccess = function (event) {
   1275    let cursor = event.target.result;
   1276    if (cursor) {
   1277      count++;
   1278      cursor.continue();
   1279    } else {
   1280      testGenerator.next();
   1281    }
   1282  };
   1283  yield undefined;
   1284 
   1285  is(count, 3, "Correct count for bound keyRange arg to index.openCursor");
   1286 
   1287  try {
   1288    index.get();
   1289    ok(false, "Get with unspecified arg should have thrown");
   1290  } catch (e) {
   1291    ok(true, "Get with unspecified arg should have thrown");
   1292  }
   1293 
   1294  try {
   1295    index.get(undefined);
   1296    ok(false, "Get with undefined should have thrown");
   1297  } catch (e) {
   1298    ok(true, "Get with undefined arg should have thrown");
   1299  }
   1300 
   1301  try {
   1302    index.get(null);
   1303    ok(false, "Get with null should have thrown");
   1304  } catch (e) {
   1305    is(e instanceof DOMException, true, "Got right kind of exception");
   1306    is(e.name, "DataError", "Correct error.");
   1307    is(e.code, 0, "Correct code.");
   1308  }
   1309 
   1310  index.get(data[0].weight).onsuccess = grabEventAndContinueHandler;
   1311  event = yield undefined;
   1312 
   1313  is(event.target.result.weight, data[0].weight, "Got correct result");
   1314 
   1315  keyRange = IDBKeyRange.only(data[0].weight);
   1316 
   1317  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1318  event = yield undefined;
   1319 
   1320  is(event.target.result.weight, data[0].weight, "Got correct result");
   1321 
   1322  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
   1323 
   1324  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1325  event = yield undefined;
   1326 
   1327  is(
   1328    event.target.result.weight,
   1329    data[weightSort[0]].weight,
   1330    "Got correct result"
   1331  );
   1332 
   1333  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight - 1);
   1334 
   1335  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1336  event = yield undefined;
   1337 
   1338  is(
   1339    event.target.result.weight,
   1340    data[weightSort[0]].weight,
   1341    "Got correct result"
   1342  );
   1343 
   1344  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight + 1);
   1345 
   1346  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1347  event = yield undefined;
   1348 
   1349  is(
   1350    event.target.result.weight,
   1351    data[weightSort[1]].weight,
   1352    "Got correct result"
   1353  );
   1354 
   1355  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
   1356 
   1357  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1358  event = yield undefined;
   1359 
   1360  is(
   1361    event.target.result.weight,
   1362    data[weightSort[1]].weight,
   1363    "Got correct result"
   1364  );
   1365 
   1366  keyRange = IDBKeyRange.bound(
   1367    data[weightSort[0]].weight,
   1368    data[weightSort[1]].weight
   1369  );
   1370 
   1371  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1372  event = yield undefined;
   1373 
   1374  is(
   1375    event.target.result.weight,
   1376    data[weightSort[0]].weight,
   1377    "Got correct result"
   1378  );
   1379 
   1380  keyRange = IDBKeyRange.bound(
   1381    data[weightSort[0]].weight,
   1382    data[weightSort[1]].weight,
   1383    true
   1384  );
   1385 
   1386  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1387  event = yield undefined;
   1388 
   1389  is(
   1390    event.target.result.weight,
   1391    data[weightSort[1]].weight,
   1392    "Got correct result"
   1393  );
   1394 
   1395  keyRange = IDBKeyRange.bound(
   1396    data[weightSort[0]].weight,
   1397    data[weightSort[1]].weight,
   1398    true,
   1399    true
   1400  );
   1401 
   1402  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1403  event = yield undefined;
   1404 
   1405  is(event.target.result, undefined, "Got correct result");
   1406 
   1407  keyRange = IDBKeyRange.upperBound(data[weightSort[5]].weight);
   1408 
   1409  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1410  event = yield undefined;
   1411 
   1412  is(
   1413    event.target.result.weight,
   1414    data[weightSort[0]].weight,
   1415    "Got correct result"
   1416  );
   1417 
   1418  keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
   1419 
   1420  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1421  event = yield undefined;
   1422 
   1423  is(event.target.result, undefined, "Got correct result");
   1424 
   1425  try {
   1426    index.getKey();
   1427    ok(false, "Get with unspecified arg should have thrown");
   1428  } catch (e) {
   1429    ok(true, "Get with unspecified arg should have thrown");
   1430  }
   1431 
   1432  try {
   1433    index.getKey(undefined);
   1434    ok(false, "Get with undefined should have thrown");
   1435  } catch (e) {
   1436    ok(true, "Get with undefined arg should have thrown");
   1437  }
   1438 
   1439  try {
   1440    index.getKey(null);
   1441    ok(false, "Get with null should have thrown");
   1442  } catch (e) {
   1443    is(e instanceof DOMException, true, "Got right kind of exception");
   1444    is(e.name, "DataError", "Correct error.");
   1445    is(e.code, 0, "Correct code.");
   1446  }
   1447 
   1448  index.getKey(data[0].weight).onsuccess = grabEventAndContinueHandler;
   1449  event = yield undefined;
   1450 
   1451  is(event.target.result, data[0].ssn, "Got correct result");
   1452 
   1453  keyRange = IDBKeyRange.only(data[0].weight);
   1454 
   1455  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
   1456  event = yield undefined;
   1457 
   1458  is(event.target.result, data[0].ssn, "Got correct result");
   1459 
   1460  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
   1461 
   1462  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
   1463  event = yield undefined;
   1464 
   1465  is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
   1466 
   1467  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight - 1);
   1468 
   1469  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
   1470  event = yield undefined;
   1471 
   1472  is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
   1473 
   1474  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight + 1);
   1475 
   1476  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
   1477  event = yield undefined;
   1478 
   1479  is(event.target.result, data[weightSort[1]].ssn, "Got correct result");
   1480 
   1481  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
   1482 
   1483  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
   1484  event = yield undefined;
   1485 
   1486  is(event.target.result, data[weightSort[1]].ssn, "Got correct result");
   1487 
   1488  keyRange = IDBKeyRange.bound(
   1489    data[weightSort[0]].weight,
   1490    data[weightSort[1]].weight
   1491  );
   1492 
   1493  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
   1494  event = yield undefined;
   1495 
   1496  is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
   1497 
   1498  keyRange = IDBKeyRange.bound(
   1499    data[weightSort[0]].weight,
   1500    data[weightSort[1]].weight,
   1501    true
   1502  );
   1503 
   1504  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
   1505  event = yield undefined;
   1506 
   1507  is(event.target.result, data[weightSort[1]].ssn, "Got correct result");
   1508 
   1509  keyRange = IDBKeyRange.bound(
   1510    data[weightSort[0]].weight,
   1511    data[weightSort[1]].weight,
   1512    true,
   1513    true
   1514  );
   1515 
   1516  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
   1517  event = yield undefined;
   1518 
   1519  is(event.target.result, undefined, "Got correct result");
   1520 
   1521  keyRange = IDBKeyRange.upperBound(data[weightSort[5]].weight);
   1522 
   1523  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
   1524  event = yield undefined;
   1525 
   1526  is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
   1527 
   1528  keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
   1529 
   1530  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
   1531  event = yield undefined;
   1532 
   1533  is(event.target.result, undefined, "Got correct result");
   1534 
   1535  count = 0;
   1536 
   1537  index.openKeyCursor().onsuccess = function (event) {
   1538    let cursor = event.target.result;
   1539    if (cursor) {
   1540      count++;
   1541      cursor.continue();
   1542    } else {
   1543      testGenerator.next();
   1544    }
   1545  };
   1546  yield undefined;
   1547 
   1548  is(
   1549    count,
   1550    weightSort.length,
   1551    "Correct count for no arg to index.openKeyCursor"
   1552  );
   1553 
   1554  count = 0;
   1555 
   1556  index.openKeyCursor(null).onsuccess = function (event) {
   1557    let cursor = event.target.result;
   1558    if (cursor) {
   1559      count++;
   1560      cursor.continue();
   1561    } else {
   1562      testGenerator.next();
   1563    }
   1564  };
   1565  yield undefined;
   1566 
   1567  is(
   1568    count,
   1569    weightSort.length,
   1570    "Correct count for null arg to index.openKeyCursor"
   1571  );
   1572 
   1573  count = 0;
   1574 
   1575  index.openKeyCursor(undefined).onsuccess = function (event) {
   1576    let cursor = event.target.result;
   1577    if (cursor) {
   1578      count++;
   1579      cursor.continue();
   1580    } else {
   1581      testGenerator.next();
   1582    }
   1583  };
   1584  yield undefined;
   1585 
   1586  is(
   1587    count,
   1588    weightSort.length,
   1589    "Correct count for undefined arg to index.openKeyCursor"
   1590  );
   1591 
   1592  count = 0;
   1593 
   1594  index.openKeyCursor(data[weightSort[0]].weight).onsuccess = function (event) {
   1595    let cursor = event.target.result;
   1596    if (cursor) {
   1597      count++;
   1598      cursor.continue();
   1599    } else {
   1600      testGenerator.next();
   1601    }
   1602  };
   1603  yield undefined;
   1604 
   1605  is(count, 1, "Correct count for single key arg to index.openKeyCursor");
   1606 
   1607  count = 0;
   1608 
   1609  index.openKeyCursor("foo").onsuccess = function (event) {
   1610    let cursor = event.target.result;
   1611    if (cursor) {
   1612      count++;
   1613      cursor.continue();
   1614    } else {
   1615      testGenerator.next();
   1616    }
   1617  };
   1618  yield undefined;
   1619 
   1620  is(
   1621    count,
   1622    0,
   1623    "Correct count for non-existent single key arg to index.openKeyCursor"
   1624  );
   1625 
   1626  count = 0;
   1627  keyRange = IDBKeyRange.only(data[weightSort[0]].weight);
   1628 
   1629  index.openKeyCursor(keyRange).onsuccess = function (event) {
   1630    let cursor = event.target.result;
   1631    if (cursor) {
   1632      count++;
   1633      cursor.continue();
   1634    } else {
   1635      testGenerator.next();
   1636    }
   1637  };
   1638  yield undefined;
   1639 
   1640  is(count, 1, "Correct count for only keyRange arg to index.openKeyCursor");
   1641 
   1642  objectStore.mozGetAll(data[1].ssn).onsuccess = grabEventAndContinueHandler;
   1643  event = yield undefined;
   1644 
   1645  is(event.target.result instanceof Array, true, "Got an array");
   1646  is(event.target.result.length, 1, "Got correct length");
   1647  is(event.target.result[0].ssn, data[1].ssn, "Got correct result");
   1648 
   1649  objectStore.mozGetAll(null).onsuccess = grabEventAndContinueHandler;
   1650  event = yield undefined;
   1651 
   1652  is(event.target.result instanceof Array, true, "Got an array");
   1653  is(event.target.result.length, data.length, "Got correct length");
   1654  for (let i in event.target.result) {
   1655    is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
   1656  }
   1657 
   1658  objectStore.mozGetAll(undefined).onsuccess = grabEventAndContinueHandler;
   1659  event = yield undefined;
   1660 
   1661  is(event.target.result instanceof Array, true, "Got an array");
   1662  is(event.target.result.length, data.length, "Got correct length");
   1663  for (let i in event.target.result) {
   1664    is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
   1665  }
   1666 
   1667  objectStore.mozGetAll().onsuccess = grabEventAndContinueHandler;
   1668  event = yield undefined;
   1669 
   1670  is(event.target.result instanceof Array, true, "Got an array");
   1671  is(event.target.result.length, data.length, "Got correct length");
   1672  for (let i in event.target.result) {
   1673    is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
   1674  }
   1675 
   1676  keyRange = IDBKeyRange.lowerBound(0);
   1677 
   1678  objectStore.mozGetAll(keyRange).onsuccess = grabEventAndContinueHandler;
   1679  event = yield undefined;
   1680 
   1681  is(event.target.result instanceof Array, true, "Got an array");
   1682  is(event.target.result.length, data.length, "Got correct length");
   1683  for (let i in event.target.result) {
   1684    is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
   1685  }
   1686 
   1687  index.mozGetAll().onsuccess = grabEventAndContinueHandler;
   1688  event = yield undefined;
   1689 
   1690  is(event.target.result instanceof Array, true, "Got an array");
   1691  is(event.target.result.length, weightSort.length, "Got correct length");
   1692  for (let i in event.target.result) {
   1693    is(
   1694      event.target.result[i].ssn,
   1695      data[weightSort[i]].ssn,
   1696      "Got correct value"
   1697    );
   1698  }
   1699 
   1700  index.mozGetAll(undefined).onsuccess = grabEventAndContinueHandler;
   1701  event = yield undefined;
   1702 
   1703  is(event.target.result instanceof Array, true, "Got an array");
   1704  is(event.target.result.length, weightSort.length, "Got correct length");
   1705  for (let i in event.target.result) {
   1706    is(
   1707      event.target.result[i].ssn,
   1708      data[weightSort[i]].ssn,
   1709      "Got correct value"
   1710    );
   1711  }
   1712 
   1713  index.mozGetAll(null).onsuccess = grabEventAndContinueHandler;
   1714  event = yield undefined;
   1715 
   1716  is(event.target.result instanceof Array, true, "Got an array");
   1717  is(event.target.result.length, weightSort.length, "Got correct length");
   1718  for (let i in event.target.result) {
   1719    is(
   1720      event.target.result[i].ssn,
   1721      data[weightSort[i]].ssn,
   1722      "Got correct value"
   1723    );
   1724  }
   1725 
   1726  index.mozGetAll(data[weightSort[0]].weight).onsuccess =
   1727    grabEventAndContinueHandler;
   1728  event = yield undefined;
   1729 
   1730  is(event.target.result instanceof Array, true, "Got an array");
   1731  is(event.target.result.length, 1, "Got correct length");
   1732  is(event.target.result[0].ssn, data[weightSort[0]].ssn, "Got correct result");
   1733 
   1734  keyRange = IDBKeyRange.lowerBound(0);
   1735 
   1736  index.mozGetAll(keyRange).onsuccess = grabEventAndContinueHandler;
   1737  event = yield undefined;
   1738 
   1739  is(event.target.result instanceof Array, true, "Got an array");
   1740  is(event.target.result.length, weightSort.length, "Got correct length");
   1741  for (let i in event.target.result) {
   1742    is(
   1743      event.target.result[i].ssn,
   1744      data[weightSort[i]].ssn,
   1745      "Got correct value"
   1746    );
   1747  }
   1748 
   1749  index.mozGetAllKeys().onsuccess = grabEventAndContinueHandler;
   1750  event = yield undefined;
   1751 
   1752  is(event.target.result instanceof Array, true, "Got an array");
   1753  is(event.target.result.length, weightSort.length, "Got correct length");
   1754  for (let i in event.target.result) {
   1755    is(event.target.result[i], data[weightSort[i]].ssn, "Got correct value");
   1756  }
   1757 
   1758  index.mozGetAllKeys(undefined).onsuccess = grabEventAndContinueHandler;
   1759  event = yield undefined;
   1760 
   1761  is(event.target.result instanceof Array, true, "Got an array");
   1762  is(event.target.result.length, weightSort.length, "Got correct length");
   1763  for (let i in event.target.result) {
   1764    is(event.target.result[i], data[weightSort[i]].ssn, "Got correct value");
   1765  }
   1766 
   1767  index.mozGetAllKeys(null).onsuccess = grabEventAndContinueHandler;
   1768  event = yield undefined;
   1769 
   1770  is(event.target.result instanceof Array, true, "Got an array");
   1771  is(event.target.result.length, weightSort.length, "Got correct length");
   1772  for (let i in event.target.result) {
   1773    is(event.target.result[i], data[weightSort[i]].ssn, "Got correct value");
   1774  }
   1775 
   1776  index.mozGetAllKeys(data[weightSort[0]].weight).onsuccess =
   1777    grabEventAndContinueHandler;
   1778  event = yield undefined;
   1779 
   1780  is(event.target.result instanceof Array, true, "Got an array");
   1781  is(event.target.result.length, 1, "Got correct length");
   1782  is(event.target.result[0], data[weightSort[0]].ssn, "Got correct result");
   1783 
   1784  keyRange = IDBKeyRange.lowerBound(0);
   1785 
   1786  index.mozGetAllKeys(keyRange).onsuccess = grabEventAndContinueHandler;
   1787  event = yield undefined;
   1788 
   1789  is(event.target.result instanceof Array, true, "Got an array");
   1790  is(event.target.result.length, weightSort.length, "Got correct length");
   1791  for (let i in event.target.result) {
   1792    is(event.target.result[i], data[weightSort[i]].ssn, "Got correct value");
   1793  }
   1794 
   1795  finishTest();
   1796 }