dom/indexedDB/test/unit/test_optionalArguments.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/indexedDB/test/unit/test_optionalArguments.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1711 @@
     1.4 +/**
     1.5 + * Any copyright is dedicated to the Public Domain.
     1.6 + * http://creativecommons.org/publicdomain/zero/1.0/
     1.7 + */
     1.8 +
     1.9 +var testGenerator = testSteps();
    1.10 +
    1.11 +function testSteps()
    1.12 +{
    1.13 +  const osName = "people";
    1.14 +  const indexName = "weight";
    1.15 +
    1.16 +  const data = [
    1.17 +    { ssn: "237-23-7732", name: "Bob", height: 60, weight: 120 },
    1.18 +    { ssn: "237-23-7733", name: "Ann", height: 52, weight: 110 },
    1.19 +    { ssn: "237-23-7734", name: "Ron", height: 73, weight: 180 },
    1.20 +    { ssn: "237-23-7735", name: "Sue", height: 58, weight: 130 },
    1.21 +    { ssn: "237-23-7736", name: "Joe", height: 65, weight: 150 },
    1.22 +    { ssn: "237-23-7737", name: "Pat", height: 65 },
    1.23 +    { ssn: "237-23-7738", name: "Mel", height: 66, weight: {} },
    1.24 +    { ssn: "237-23-7739", name: "Tom", height: 62, weight: 130 }
    1.25 +  ];
    1.26 +
    1.27 +  const weightSort = [1, 0, 3, 7, 4, 2];
    1.28 +
    1.29 +  let request = indexedDB.open(this.window ? window.location.pathname : "Splendid Test", 1);
    1.30 +  request.onerror = errorHandler;
    1.31 +  request.onupgradeneeded = grabEventAndContinueHandler;
    1.32 +  request.onsuccess = grabEventAndContinueHandler;
    1.33 +  let event = yield undefined;
    1.34 +
    1.35 +  is(event.type, "upgradeneeded", "Got upgradeneeded event");
    1.36 +
    1.37 +  let db = event.target.result;
    1.38 +  db.onerror = errorHandler;
    1.39 +
    1.40 +  let objectStore = db.createObjectStore(osName, { keyPath: "ssn" });
    1.41 +  objectStore.createIndex(indexName, "weight", { unique: false });
    1.42 +
    1.43 +  for each (let i in data) {
    1.44 +    objectStore.add(i);
    1.45 +  }
    1.46 +
    1.47 +  event = yield undefined;
    1.48 +
    1.49 +  is(event.type, "success", "Got success event");
    1.50 +
    1.51 +  try {
    1.52 +    IDBKeyRange.bound(1, -1);
    1.53 +    ok(false, "Bound keyRange with backwards args should throw!");
    1.54 +  }
    1.55 +  catch (e) {
    1.56 +    is(e.name, "DataError", "Threw correct exception");
    1.57 +    is(e.code, 0, "Threw with correct code");
    1.58 +  }
    1.59 +
    1.60 +  try {
    1.61 +    IDBKeyRange.bound(1, 1);
    1.62 +    ok(true, "Bound keyRange with same arg should be ok");
    1.63 +  }
    1.64 +  catch (e) {
    1.65 +    ok(false, "Bound keyRange with same arg should have been ok");
    1.66 +  }
    1.67 +
    1.68 +  try {
    1.69 +    IDBKeyRange.bound(1, 1, true);
    1.70 +    ok(false, "Bound keyRange with same arg and open should throw!");
    1.71 +  }
    1.72 +  catch (e) {
    1.73 +    is(e.name, "DataError", "Threw correct exception");
    1.74 +    is(e.code, 0, "Threw with correct code");
    1.75 +  }
    1.76 +
    1.77 +  try {
    1.78 +    IDBKeyRange.bound(1, 1, true, true);
    1.79 +    ok(false, "Bound keyRange with same arg and open should throw!");
    1.80 +  }
    1.81 +  catch (e) {
    1.82 +    is(e.name, "DataError", "Threw correct exception");
    1.83 +    is(e.code, 0, "Threw with correct code");
    1.84 +  }
    1.85 +
    1.86 +  objectStore = db.transaction(osName).objectStore(osName);
    1.87 +
    1.88 +  try {
    1.89 +    objectStore.get();
    1.90 +    ok(false, "Get with unspecified arg should have thrown");
    1.91 +  }
    1.92 +  catch(e) {
    1.93 +    ok(true, "Get with unspecified arg should have thrown");
    1.94 +  }
    1.95 +
    1.96 +  try {
    1.97 +    objectStore.get(undefined);
    1.98 +    ok(false, "Get with undefined should have thrown");
    1.99 +  }
   1.100 +  catch(e) {
   1.101 +    ok(true, "Get with undefined arg should have thrown");
   1.102 +  }
   1.103 +
   1.104 +  try {
   1.105 +    objectStore.get(null);
   1.106 +    ok(false, "Get with null should have thrown");
   1.107 +  }
   1.108 +  catch(e) {
   1.109 +    is(e instanceof DOMException, true,
   1.110 +       "Got right kind of exception");
   1.111 +    is(e.name, "DataError", "Correct error.");
   1.112 +    is(e.code, 0, "Correct code.");
   1.113 +  }
   1.114 +
   1.115 +  objectStore.get(data[2].ssn).onsuccess = grabEventAndContinueHandler;
   1.116 +  event = yield undefined;
   1.117 +
   1.118 +  is(event.target.result.name, data[2].name, "Correct data");
   1.119 +
   1.120 +  let keyRange = IDBKeyRange.only(data[2].ssn);
   1.121 +
   1.122 +  objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1.123 +  event = yield undefined;
   1.124 +
   1.125 +  is(event.target.result.name, data[2].name, "Correct data");
   1.126 +
   1.127 +  keyRange = IDBKeyRange.lowerBound(data[2].ssn);
   1.128 +
   1.129 +  objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1.130 +  event = yield undefined;
   1.131 +
   1.132 +  is(event.target.result.name, data[2].name, "Correct data");
   1.133 +
   1.134 +  keyRange = IDBKeyRange.lowerBound(data[2].ssn, true);
   1.135 +
   1.136 +  objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1.137 +  event = yield undefined;
   1.138 +
   1.139 +  is(event.target.result.name, data[3].name, "Correct data");
   1.140 +
   1.141 +  keyRange = IDBKeyRange.upperBound(data[2].ssn);
   1.142 +
   1.143 +  objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1.144 +  event = yield undefined;
   1.145 +
   1.146 +  is(event.target.result.name, data[0].name, "Correct data");
   1.147 +
   1.148 +  keyRange = IDBKeyRange.bound(data[2].ssn, data[4].ssn);
   1.149 +
   1.150 +  objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1.151 +  event = yield undefined;
   1.152 +
   1.153 +  is(event.target.result.name, data[2].name, "Correct data");
   1.154 +
   1.155 +  keyRange = IDBKeyRange.bound(data[2].ssn, data[4].ssn, true);
   1.156 +
   1.157 +  objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
   1.158 +  event = yield undefined;
   1.159 +
   1.160 +  is(event.target.result.name, data[3].name, "Correct data");
   1.161 +
   1.162 +  objectStore = db.transaction(osName, "readwrite")
   1.163 +                  .objectStore(osName);
   1.164 +
   1.165 +  try {
   1.166 +    objectStore.delete();
   1.167 +    ok(false, "Delete with unspecified arg should have thrown");
   1.168 +  }
   1.169 +  catch(e) {
   1.170 +    ok(true, "Delete with unspecified arg should have thrown");
   1.171 +  }
   1.172 +
   1.173 +  try {
   1.174 +    objectStore.delete(undefined);
   1.175 +    ok(false, "Delete with undefined should have thrown");
   1.176 +  }
   1.177 +  catch(e) {
   1.178 +    ok(true, "Delete with undefined arg should have thrown");
   1.179 +  }
   1.180 +
   1.181 +  try {
   1.182 +    objectStore.delete(null);
   1.183 +    ok(false, "Delete with null should have thrown");
   1.184 +  }
   1.185 +  catch(e) {
   1.186 +    is(e instanceof DOMException, true,
   1.187 +       "Got right kind of exception");
   1.188 +    is(e.name, "DataError", "Correct error.");
   1.189 +    is(e.code, 0, "Correct code.");
   1.190 +  }
   1.191 +
   1.192 +  objectStore.count().onsuccess = grabEventAndContinueHandler;
   1.193 +  event = yield undefined;
   1.194 +
   1.195 +  is(event.target.result, data.length, "Correct count");
   1.196 +
   1.197 +  objectStore.delete(data[2].ssn).onsuccess = grabEventAndContinueHandler;
   1.198 +  event = yield undefined;
   1.199 +
   1.200 +  ok(event.target.result === undefined, "Correct result");
   1.201 +
   1.202 +  objectStore.count().onsuccess = grabEventAndContinueHandler;
   1.203 +  event = yield undefined;
   1.204 +
   1.205 +  is(event.target.result, data.length - 1, "Correct count");
   1.206 +
   1.207 +  keyRange = IDBKeyRange.bound(data[3].ssn, data[5].ssn);
   1.208 +
   1.209 +  objectStore.delete(keyRange).onsuccess = grabEventAndContinueHandler;
   1.210 +  event = yield undefined;
   1.211 +
   1.212 +  ok(event.target.result === undefined, "Correct result");
   1.213 +
   1.214 +  objectStore.count().onsuccess = grabEventAndContinueHandler;
   1.215 +  event = yield undefined;
   1.216 +
   1.217 +  is(event.target.result, data.length - 4, "Correct count");
   1.218 +
   1.219 +  keyRange = IDBKeyRange.lowerBound(10);
   1.220 +
   1.221 +  objectStore.delete(keyRange).onsuccess = grabEventAndContinueHandler;
   1.222 +  event = yield undefined;
   1.223 +
   1.224 +  ok(event.target.result === undefined, "Correct result");
   1.225 +
   1.226 +  objectStore.count().onsuccess = grabEventAndContinueHandler;
   1.227 +  event = yield undefined;
   1.228 +
   1.229 +  is(event.target.result, 0, "Correct count");
   1.230 +
   1.231 +  event.target.transaction.oncomplete = grabEventAndContinueHandler;
   1.232 +
   1.233 +  for each (let i in data) {
   1.234 +    objectStore.add(i);
   1.235 +  }
   1.236 +
   1.237 +  yield undefined;
   1.238 +
   1.239 +  objectStore = db.transaction(osName).objectStore(osName);
   1.240 +
   1.241 +  objectStore.count().onsuccess = grabEventAndContinueHandler;
   1.242 +  event = yield undefined;
   1.243 +
   1.244 +  is(event.target.result, data.length, "Correct count");
   1.245 +
   1.246 +  let count = 0;
   1.247 +
   1.248 +  objectStore.openCursor().onsuccess = function(event) {
   1.249 +    let cursor = event.target.result;
   1.250 +    if (cursor) {
   1.251 +      count++;
   1.252 +      cursor.continue();
   1.253 +    }
   1.254 +    else {
   1.255 +      testGenerator.next();
   1.256 +    }
   1.257 +  }
   1.258 +  yield undefined;
   1.259 +
   1.260 +  is(count, data.length, "Correct count for no arg to openCursor");
   1.261 +
   1.262 +  count = 0;
   1.263 +
   1.264 +  objectStore.openCursor(null).onsuccess = function(event) {
   1.265 +    let cursor = event.target.result;
   1.266 +    if (cursor) {
   1.267 +      count++;
   1.268 +      cursor.continue();
   1.269 +    }
   1.270 +    else {
   1.271 +      testGenerator.next();
   1.272 +    }
   1.273 +  }
   1.274 +  yield undefined;
   1.275 +
   1.276 +  is(count, data.length, "Correct count for null arg to openCursor");
   1.277 +
   1.278 +  count = 0;
   1.279 +
   1.280 +  objectStore.openCursor(undefined).onsuccess = function(event) {
   1.281 +    let cursor = event.target.result;
   1.282 +    if (cursor) {
   1.283 +      count++;
   1.284 +      cursor.continue();
   1.285 +    }
   1.286 +    else {
   1.287 +      testGenerator.next();
   1.288 +    }
   1.289 +  }
   1.290 +  yield undefined;
   1.291 +
   1.292 +  is(count, data.length, "Correct count for undefined arg to openCursor");
   1.293 +
   1.294 +  count = 0;
   1.295 +
   1.296 +  objectStore.openCursor(data[2].ssn).onsuccess = function(event) {
   1.297 +    let cursor = event.target.result;
   1.298 +    if (cursor) {
   1.299 +      count++;
   1.300 +      cursor.continue();
   1.301 +    }
   1.302 +    else {
   1.303 +      testGenerator.next();
   1.304 +    }
   1.305 +  }
   1.306 +  yield undefined;
   1.307 +
   1.308 +  is(count, 1, "Correct count for single key arg to openCursor");
   1.309 +
   1.310 +  count = 0;
   1.311 +
   1.312 +  objectStore.openCursor("foo").onsuccess = function(event) {
   1.313 +    let cursor = event.target.result;
   1.314 +    if (cursor) {
   1.315 +      count++;
   1.316 +      cursor.continue();
   1.317 +    }
   1.318 +    else {
   1.319 +      testGenerator.next();
   1.320 +    }
   1.321 +  }
   1.322 +  yield undefined;
   1.323 +
   1.324 +  is(count, 0,
   1.325 +     "Correct count for non-existent single key arg to openCursor");
   1.326 +
   1.327 +  count = 0;
   1.328 +  keyRange = IDBKeyRange.only(data[2].ssn);
   1.329 +
   1.330 +  objectStore.openCursor(keyRange).onsuccess = function(event) {
   1.331 +    let cursor = event.target.result;
   1.332 +    if (cursor) {
   1.333 +      count++;
   1.334 +      cursor.continue();
   1.335 +    }
   1.336 +    else {
   1.337 +      testGenerator.next();
   1.338 +    }
   1.339 +  }
   1.340 +  yield undefined;
   1.341 +
   1.342 +  is(count, 1, "Correct count for only keyRange arg to openCursor");
   1.343 +
   1.344 +  count = 0;
   1.345 +  keyRange = IDBKeyRange.lowerBound(data[2].ssn);
   1.346 +
   1.347 +  objectStore.openCursor(keyRange).onsuccess = function(event) {
   1.348 +    let cursor = event.target.result;
   1.349 +    if (cursor) {
   1.350 +      count++;
   1.351 +      cursor.continue();
   1.352 +    }
   1.353 +    else {
   1.354 +      testGenerator.next();
   1.355 +    }
   1.356 +  }
   1.357 +  yield undefined;
   1.358 +
   1.359 +  is(count, data.length - 2,
   1.360 +     "Correct count for lowerBound arg to openCursor");
   1.361 +
   1.362 +  count = 0;
   1.363 +  keyRange = IDBKeyRange.lowerBound(data[2].ssn, true);
   1.364 +
   1.365 +  objectStore.openCursor(keyRange).onsuccess = function(event) {
   1.366 +    let cursor = event.target.result;
   1.367 +    if (cursor) {
   1.368 +      count++;
   1.369 +      cursor.continue();
   1.370 +    }
   1.371 +    else {
   1.372 +      testGenerator.next();
   1.373 +    }
   1.374 +  }
   1.375 +  yield undefined;
   1.376 +
   1.377 +  is(count, data.length - 3,
   1.378 +     "Correct count for lowerBound arg to openCursor");
   1.379 +
   1.380 +  count = 0;
   1.381 +  keyRange = IDBKeyRange.lowerBound("foo");
   1.382 +
   1.383 +  objectStore.openCursor(keyRange).onsuccess = function(event) {
   1.384 +    let cursor = event.target.result;
   1.385 +    if (cursor) {
   1.386 +      count++;
   1.387 +      cursor.continue();
   1.388 +    }
   1.389 +    else {
   1.390 +      testGenerator.next();
   1.391 +    }
   1.392 +  }
   1.393 +  yield undefined;
   1.394 +
   1.395 +  is(count, 0,
   1.396 +     "Correct count for non-existent lowerBound arg to openCursor");
   1.397 +
   1.398 +  count = 0;
   1.399 +  keyRange = IDBKeyRange.bound(data[2].ssn, data[3].ssn);
   1.400 +
   1.401 +  objectStore.openCursor(keyRange).onsuccess = function(event) {
   1.402 +    let cursor = event.target.result;
   1.403 +    if (cursor) {
   1.404 +      count++;
   1.405 +      cursor.continue();
   1.406 +    }
   1.407 +    else {
   1.408 +      testGenerator.next();
   1.409 +    }
   1.410 +  }
   1.411 +  yield undefined;
   1.412 +
   1.413 +  is(count, 2, "Correct count for bound arg to openCursor");
   1.414 +
   1.415 +  count = 0;
   1.416 +  keyRange = IDBKeyRange.bound(data[2].ssn, data[3].ssn, true);
   1.417 +
   1.418 +  objectStore.openCursor(keyRange).onsuccess = function(event) {
   1.419 +    let cursor = event.target.result;
   1.420 +    if (cursor) {
   1.421 +      count++;
   1.422 +      cursor.continue();
   1.423 +    }
   1.424 +    else {
   1.425 +      testGenerator.next();
   1.426 +    }
   1.427 +  }
   1.428 +  yield undefined;
   1.429 +
   1.430 +  is(count, 1, "Correct count for bound arg to openCursor");
   1.431 +
   1.432 +  count = 0;
   1.433 +  keyRange = IDBKeyRange.bound(data[2].ssn, data[3].ssn, true, true);
   1.434 +
   1.435 +  objectStore.openCursor(keyRange).onsuccess = function(event) {
   1.436 +    let cursor = event.target.result;
   1.437 +    if (cursor) {
   1.438 +      count++;
   1.439 +      cursor.continue();
   1.440 +    }
   1.441 +    else {
   1.442 +      testGenerator.next();
   1.443 +    }
   1.444 +  }
   1.445 +  yield undefined;
   1.446 +
   1.447 +  is(count, 0, "Correct count for bound arg to openCursor");
   1.448 +
   1.449 +  let index = objectStore.index(indexName);
   1.450 +
   1.451 +  count = 0;
   1.452 +
   1.453 +  index.openKeyCursor().onsuccess = function(event) {
   1.454 +    let cursor = event.target.result;
   1.455 +    if (cursor) {
   1.456 +      count++;
   1.457 +      cursor.continue();
   1.458 +    }
   1.459 +    else {
   1.460 +      testGenerator.next();
   1.461 +    }
   1.462 +  }
   1.463 +  yield undefined;
   1.464 +
   1.465 +  is(count, weightSort.length,
   1.466 +     "Correct count for unspecified arg to index.openKeyCursor");
   1.467 +
   1.468 +  count = 0;
   1.469 +
   1.470 +  index.openKeyCursor(null).onsuccess = function(event) {
   1.471 +    let cursor = event.target.result;
   1.472 +    if (cursor) {
   1.473 +      count++;
   1.474 +      cursor.continue();
   1.475 +    }
   1.476 +    else {
   1.477 +      testGenerator.next();
   1.478 +    }
   1.479 +  }
   1.480 +  yield undefined;
   1.481 +
   1.482 +  is(count, weightSort.length,
   1.483 +     "Correct count for null arg to index.openKeyCursor");
   1.484 +
   1.485 +  count = 0;
   1.486 +
   1.487 +  index.openKeyCursor(undefined).onsuccess = function(event) {
   1.488 +    let cursor = event.target.result;
   1.489 +    if (cursor) {
   1.490 +      count++;
   1.491 +      cursor.continue();
   1.492 +    }
   1.493 +    else {
   1.494 +      testGenerator.next();
   1.495 +    }
   1.496 +  }
   1.497 +  yield undefined;
   1.498 +
   1.499 +  is(count, weightSort.length,
   1.500 +     "Correct count for undefined arg to index.openKeyCursor");
   1.501 +
   1.502 +  count = 0;
   1.503 +
   1.504 +  index.openKeyCursor(data[0].weight).onsuccess = function(event) {
   1.505 +    let cursor = event.target.result;
   1.506 +    if (cursor) {
   1.507 +      count++;
   1.508 +      cursor.continue();
   1.509 +    }
   1.510 +    else {
   1.511 +      testGenerator.next();
   1.512 +    }
   1.513 +  }
   1.514 +  yield undefined;
   1.515 +
   1.516 +  is(count, 1, "Correct count for single key arg to index.openKeyCursor");
   1.517 +
   1.518 +  count = 0;
   1.519 +
   1.520 +  index.openKeyCursor("foo").onsuccess = function(event) {
   1.521 +    let cursor = event.target.result;
   1.522 +    if (cursor) {
   1.523 +      count++;
   1.524 +      cursor.continue();
   1.525 +    }
   1.526 +    else {
   1.527 +      testGenerator.next();
   1.528 +    }
   1.529 +  }
   1.530 +  yield undefined;
   1.531 +
   1.532 +  is(count, 0,
   1.533 +     "Correct count for non-existent key arg to index.openKeyCursor");
   1.534 +
   1.535 +  count = 0;
   1.536 +  keyRange = IDBKeyRange.only("foo");
   1.537 +
   1.538 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.539 +    let cursor = event.target.result;
   1.540 +    if (cursor) {
   1.541 +      count++;
   1.542 +      cursor.continue();
   1.543 +    }
   1.544 +    else {
   1.545 +      testGenerator.next();
   1.546 +    }
   1.547 +  }
   1.548 +  yield undefined;
   1.549 +
   1.550 +  is(count, 0,
   1.551 +     "Correct count for non-existent keyRange arg to index.openKeyCursor");
   1.552 +
   1.553 +  count = 0;
   1.554 +  keyRange = IDBKeyRange.only(data[0].weight);
   1.555 +
   1.556 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.557 +    let cursor = event.target.result;
   1.558 +    if (cursor) {
   1.559 +      count++;
   1.560 +      cursor.continue();
   1.561 +    }
   1.562 +    else {
   1.563 +      testGenerator.next();
   1.564 +    }
   1.565 +  }
   1.566 +  yield undefined;
   1.567 +
   1.568 +  is(count, 1,
   1.569 +     "Correct count for only keyRange arg to index.openKeyCursor");
   1.570 +
   1.571 +  count = 0;
   1.572 +  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
   1.573 +
   1.574 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.575 +    let cursor = event.target.result;
   1.576 +    if (cursor) {
   1.577 +      count++;
   1.578 +      cursor.continue();
   1.579 +    }
   1.580 +    else {
   1.581 +      testGenerator.next();
   1.582 +    }
   1.583 +  }
   1.584 +  yield undefined;
   1.585 +
   1.586 +  is(count, weightSort.length,
   1.587 +     "Correct count for lowerBound keyRange arg to index.openKeyCursor");
   1.588 +
   1.589 +  count = 0;
   1.590 +  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
   1.591 +
   1.592 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.593 +    let cursor = event.target.result;
   1.594 +    if (cursor) {
   1.595 +      count++;
   1.596 +      cursor.continue();
   1.597 +    }
   1.598 +    else {
   1.599 +      testGenerator.next();
   1.600 +    }
   1.601 +  }
   1.602 +  yield undefined;
   1.603 +
   1.604 +  is(count, weightSort.length - 1,
   1.605 +     "Correct count for lowerBound keyRange arg to index.openKeyCursor");
   1.606 +
   1.607 +  count = 0;
   1.608 +  keyRange = IDBKeyRange.lowerBound("foo");
   1.609 +
   1.610 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.611 +    let cursor = event.target.result;
   1.612 +    if (cursor) {
   1.613 +      count++;
   1.614 +      cursor.continue();
   1.615 +    }
   1.616 +    else {
   1.617 +      testGenerator.next();
   1.618 +    }
   1.619 +  }
   1.620 +  yield undefined;
   1.621 +
   1.622 +  is(count, 0,
   1.623 +     "Correct count for lowerBound keyRange arg to index.openKeyCursor");
   1.624 +
   1.625 +  count = 0;
   1.626 +  keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight);
   1.627 +
   1.628 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.629 +    let cursor = event.target.result;
   1.630 +    if (cursor) {
   1.631 +      count++;
   1.632 +      cursor.continue();
   1.633 +    }
   1.634 +    else {
   1.635 +      testGenerator.next();
   1.636 +    }
   1.637 +  }
   1.638 +  yield undefined;
   1.639 +
   1.640 +  is(count, 1,
   1.641 +     "Correct count for upperBound keyRange arg to index.openKeyCursor");
   1.642 +
   1.643 +  count = 0;
   1.644 +  keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
   1.645 +
   1.646 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.647 +    let cursor = event.target.result;
   1.648 +    if (cursor) {
   1.649 +      count++;
   1.650 +      cursor.continue();
   1.651 +    }
   1.652 +    else {
   1.653 +      testGenerator.next();
   1.654 +    }
   1.655 +  }
   1.656 +  yield undefined;
   1.657 +
   1.658 +  is(count, 0,
   1.659 +     "Correct count for upperBound keyRange arg to index.openKeyCursor");
   1.660 +
   1.661 +  count = 0;
   1.662 +  keyRange = IDBKeyRange.upperBound(data[weightSort[weightSort.length - 1]].weight);
   1.663 +
   1.664 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.665 +    let cursor = event.target.result;
   1.666 +    if (cursor) {
   1.667 +      count++;
   1.668 +      cursor.continue();
   1.669 +    }
   1.670 +    else {
   1.671 +      testGenerator.next();
   1.672 +    }
   1.673 +  }
   1.674 +  yield undefined;
   1.675 +
   1.676 +  is(count, weightSort.length,
   1.677 +     "Correct count for upperBound keyRange arg to index.openKeyCursor");
   1.678 +
   1.679 +  count = 0;
   1.680 +  keyRange = IDBKeyRange.upperBound(data[weightSort[weightSort.length - 1]].weight,
   1.681 +                                    true);
   1.682 +
   1.683 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.684 +    let cursor = event.target.result;
   1.685 +    if (cursor) {
   1.686 +      count++;
   1.687 +      cursor.continue();
   1.688 +    }
   1.689 +    else {
   1.690 +      testGenerator.next();
   1.691 +    }
   1.692 +  }
   1.693 +  yield undefined;
   1.694 +
   1.695 +  is(count, weightSort.length - 1,
   1.696 +     "Correct count for upperBound keyRange arg to index.openKeyCursor");
   1.697 +
   1.698 +  count = 0;
   1.699 +  keyRange = IDBKeyRange.upperBound("foo");
   1.700 +
   1.701 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.702 +    let cursor = event.target.result;
   1.703 +    if (cursor) {
   1.704 +      count++;
   1.705 +      cursor.continue();
   1.706 +    }
   1.707 +    else {
   1.708 +      testGenerator.next();
   1.709 +    }
   1.710 +  }
   1.711 +  yield undefined;
   1.712 +
   1.713 +  is(count, weightSort.length,
   1.714 +     "Correct count for upperBound keyRange arg to index.openKeyCursor");
   1.715 +
   1.716 +  count = 0;
   1.717 +  keyRange = IDBKeyRange.upperBound(0);
   1.718 +
   1.719 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.720 +    let cursor = event.target.result;
   1.721 +    if (cursor) {
   1.722 +      count++;
   1.723 +      cursor.continue();
   1.724 +    }
   1.725 +    else {
   1.726 +      testGenerator.next();
   1.727 +    }
   1.728 +  }
   1.729 +  yield undefined;
   1.730 +
   1.731 +  is(count, 0,
   1.732 +     "Correct count for upperBound keyRange arg to index.openKeyCursor");
   1.733 +
   1.734 +  count = 0;
   1.735 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
   1.736 +                               data[weightSort[weightSort.length - 1]].weight);
   1.737 +
   1.738 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.739 +    let cursor = event.target.result;
   1.740 +    if (cursor) {
   1.741 +      count++;
   1.742 +      cursor.continue();
   1.743 +    }
   1.744 +    else {
   1.745 +      testGenerator.next();
   1.746 +    }
   1.747 +  }
   1.748 +  yield undefined;
   1.749 +
   1.750 +  is(count, weightSort.length,
   1.751 +     "Correct count for bound keyRange arg to index.openKeyCursor");
   1.752 +
   1.753 +  count = 0;
   1.754 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
   1.755 +                               data[weightSort[weightSort.length - 1]].weight,
   1.756 +                               true);
   1.757 +
   1.758 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.759 +    let cursor = event.target.result;
   1.760 +    if (cursor) {
   1.761 +      count++;
   1.762 +      cursor.continue();
   1.763 +    }
   1.764 +    else {
   1.765 +      testGenerator.next();
   1.766 +    }
   1.767 +  }
   1.768 +  yield undefined;
   1.769 +
   1.770 +  is(count, weightSort.length - 1,
   1.771 +     "Correct count for bound keyRange arg to index.openKeyCursor");
   1.772 +
   1.773 +  count = 0;
   1.774 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
   1.775 +                               data[weightSort[weightSort.length - 1]].weight,
   1.776 +                               true, true);
   1.777 +
   1.778 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.779 +    let cursor = event.target.result;
   1.780 +    if (cursor) {
   1.781 +      count++;
   1.782 +      cursor.continue();
   1.783 +    }
   1.784 +    else {
   1.785 +      testGenerator.next();
   1.786 +    }
   1.787 +  }
   1.788 +  yield undefined;
   1.789 +
   1.790 +  is(count, weightSort.length - 2,
   1.791 +     "Correct count for bound keyRange arg to index.openKeyCursor");
   1.792 +
   1.793 +  count = 0;
   1.794 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight - 1,
   1.795 +                               data[weightSort[weightSort.length - 1]].weight + 1);
   1.796 +
   1.797 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.798 +    let cursor = event.target.result;
   1.799 +    if (cursor) {
   1.800 +      count++;
   1.801 +      cursor.continue();
   1.802 +    }
   1.803 +    else {
   1.804 +      testGenerator.next();
   1.805 +    }
   1.806 +  }
   1.807 +  yield undefined;
   1.808 +
   1.809 +  is(count, weightSort.length,
   1.810 +     "Correct count for bound keyRange arg to index.openKeyCursor");
   1.811 +
   1.812 +  count = 0;
   1.813 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight - 2,
   1.814 +                               data[weightSort[0]].weight - 1);
   1.815 +
   1.816 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.817 +    let cursor = event.target.result;
   1.818 +    if (cursor) {
   1.819 +      count++;
   1.820 +      cursor.continue();
   1.821 +    }
   1.822 +    else {
   1.823 +      testGenerator.next();
   1.824 +    }
   1.825 +  }
   1.826 +  yield undefined;
   1.827 +
   1.828 +  is(count, 0,
   1.829 +     "Correct count for bound keyRange arg to index.openKeyCursor");
   1.830 +
   1.831 +  count = 0;
   1.832 +  keyRange = IDBKeyRange.bound(data[weightSort[1]].weight,
   1.833 +                               data[weightSort[2]].weight);
   1.834 +
   1.835 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
   1.836 +    let cursor = event.target.result;
   1.837 +    if (cursor) {
   1.838 +      count++;
   1.839 +      cursor.continue();
   1.840 +    }
   1.841 +    else {
   1.842 +      testGenerator.next();
   1.843 +    }
   1.844 +  }
   1.845 +  yield undefined;
   1.846 +
   1.847 +  is(count, 3,
   1.848 +     "Correct count for bound keyRange arg to index.openKeyCursor");
   1.849 +
   1.850 +  count = 0;
   1.851 +
   1.852 +  index.openCursor().onsuccess = function(event) {
   1.853 +    let cursor = event.target.result;
   1.854 +    if (cursor) {
   1.855 +      count++;
   1.856 +      cursor.continue();
   1.857 +    }
   1.858 +    else {
   1.859 +      testGenerator.next();
   1.860 +    }
   1.861 +  }
   1.862 +  yield undefined;
   1.863 +
   1.864 +  is(count, weightSort.length,
   1.865 +     "Correct count for unspecified arg to index.openCursor");
   1.866 +
   1.867 +  count = 0;
   1.868 +
   1.869 +  index.openCursor(null).onsuccess = function(event) {
   1.870 +    let cursor = event.target.result;
   1.871 +    if (cursor) {
   1.872 +      count++;
   1.873 +      cursor.continue();
   1.874 +    }
   1.875 +    else {
   1.876 +      testGenerator.next();
   1.877 +    }
   1.878 +  }
   1.879 +  yield undefined;
   1.880 +
   1.881 +  is(count, weightSort.length,
   1.882 +     "Correct count for null arg to index.openCursor");
   1.883 +
   1.884 +  count = 0;
   1.885 +
   1.886 +  index.openCursor(undefined).onsuccess = function(event) {
   1.887 +    let cursor = event.target.result;
   1.888 +    if (cursor) {
   1.889 +      count++;
   1.890 +      cursor.continue();
   1.891 +    }
   1.892 +    else {
   1.893 +      testGenerator.next();
   1.894 +    }
   1.895 +  }
   1.896 +  yield undefined;
   1.897 +
   1.898 +  is(count, weightSort.length,
   1.899 +     "Correct count for undefined arg to index.openCursor");
   1.900 +
   1.901 +  count = 0;
   1.902 +
   1.903 +  index.openCursor(data[0].weight).onsuccess = function(event) {
   1.904 +    let cursor = event.target.result;
   1.905 +    if (cursor) {
   1.906 +      count++;
   1.907 +      cursor.continue();
   1.908 +    }
   1.909 +    else {
   1.910 +      testGenerator.next();
   1.911 +    }
   1.912 +  }
   1.913 +  yield undefined;
   1.914 +
   1.915 +  is(count, 1, "Correct count for single key arg to index.openCursor");
   1.916 +
   1.917 +  count = 0;
   1.918 +
   1.919 +  index.openCursor("foo").onsuccess = function(event) {
   1.920 +    let cursor = event.target.result;
   1.921 +    if (cursor) {
   1.922 +      count++;
   1.923 +      cursor.continue();
   1.924 +    }
   1.925 +    else {
   1.926 +      testGenerator.next();
   1.927 +    }
   1.928 +  }
   1.929 +  yield undefined;
   1.930 +
   1.931 +  is(count, 0,
   1.932 +     "Correct count for non-existent key arg to index.openCursor");
   1.933 +
   1.934 +  count = 0;
   1.935 +  keyRange = IDBKeyRange.only("foo");
   1.936 +
   1.937 +  index.openCursor(keyRange).onsuccess = function(event) {
   1.938 +    let cursor = event.target.result;
   1.939 +    if (cursor) {
   1.940 +      count++;
   1.941 +      cursor.continue();
   1.942 +    }
   1.943 +    else {
   1.944 +      testGenerator.next();
   1.945 +    }
   1.946 +  }
   1.947 +  yield undefined;
   1.948 +
   1.949 +  is(count, 0,
   1.950 +     "Correct count for non-existent keyRange arg to index.openCursor");
   1.951 +
   1.952 +  count = 0;
   1.953 +  keyRange = IDBKeyRange.only(data[0].weight);
   1.954 +
   1.955 +  index.openCursor(keyRange).onsuccess = function(event) {
   1.956 +    let cursor = event.target.result;
   1.957 +    if (cursor) {
   1.958 +      count++;
   1.959 +      cursor.continue();
   1.960 +    }
   1.961 +    else {
   1.962 +      testGenerator.next();
   1.963 +    }
   1.964 +  }
   1.965 +  yield undefined;
   1.966 +
   1.967 +  is(count, 1,
   1.968 +     "Correct count for only keyRange arg to index.openCursor");
   1.969 +
   1.970 +  count = 0;
   1.971 +  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
   1.972 +
   1.973 +  index.openCursor(keyRange).onsuccess = function(event) {
   1.974 +    let cursor = event.target.result;
   1.975 +    if (cursor) {
   1.976 +      count++;
   1.977 +      cursor.continue();
   1.978 +    }
   1.979 +    else {
   1.980 +      testGenerator.next();
   1.981 +    }
   1.982 +  }
   1.983 +  yield undefined;
   1.984 +
   1.985 +  is(count, weightSort.length,
   1.986 +     "Correct count for lowerBound keyRange arg to index.openCursor");
   1.987 +
   1.988 +  count = 0;
   1.989 +  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
   1.990 +
   1.991 +  index.openCursor(keyRange).onsuccess = function(event) {
   1.992 +    let cursor = event.target.result;
   1.993 +    if (cursor) {
   1.994 +      count++;
   1.995 +      cursor.continue();
   1.996 +    }
   1.997 +    else {
   1.998 +      testGenerator.next();
   1.999 +    }
  1.1000 +  }
  1.1001 +  yield undefined;
  1.1002 +
  1.1003 +  is(count, weightSort.length - 1,
  1.1004 +     "Correct count for lowerBound keyRange arg to index.openCursor");
  1.1005 +
  1.1006 +  count = 0;
  1.1007 +  keyRange = IDBKeyRange.lowerBound("foo");
  1.1008 +
  1.1009 +  index.openCursor(keyRange).onsuccess = function(event) {
  1.1010 +    let cursor = event.target.result;
  1.1011 +    if (cursor) {
  1.1012 +      count++;
  1.1013 +      cursor.continue();
  1.1014 +    }
  1.1015 +    else {
  1.1016 +      testGenerator.next();
  1.1017 +    }
  1.1018 +  }
  1.1019 +  yield undefined;
  1.1020 +
  1.1021 +  is(count, 0,
  1.1022 +     "Correct count for lowerBound keyRange arg to index.openCursor");
  1.1023 +
  1.1024 +  count = 0;
  1.1025 +  keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight);
  1.1026 +
  1.1027 +  index.openCursor(keyRange).onsuccess = function(event) {
  1.1028 +    let cursor = event.target.result;
  1.1029 +    if (cursor) {
  1.1030 +      count++;
  1.1031 +      cursor.continue();
  1.1032 +    }
  1.1033 +    else {
  1.1034 +      testGenerator.next();
  1.1035 +    }
  1.1036 +  }
  1.1037 +  yield undefined;
  1.1038 +
  1.1039 +  is(count, 1,
  1.1040 +     "Correct count for upperBound keyRange arg to index.openCursor");
  1.1041 +
  1.1042 +  count = 0;
  1.1043 +  keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
  1.1044 +
  1.1045 +  index.openCursor(keyRange).onsuccess = function(event) {
  1.1046 +    let cursor = event.target.result;
  1.1047 +    if (cursor) {
  1.1048 +      count++;
  1.1049 +      cursor.continue();
  1.1050 +    }
  1.1051 +    else {
  1.1052 +      testGenerator.next();
  1.1053 +    }
  1.1054 +  }
  1.1055 +  yield undefined;
  1.1056 +
  1.1057 +  is(count, 0,
  1.1058 +     "Correct count for upperBound keyRange arg to index.openCursor");
  1.1059 +
  1.1060 +  count = 0;
  1.1061 +  keyRange = IDBKeyRange.upperBound(data[weightSort[weightSort.length - 1]].weight);
  1.1062 +
  1.1063 +  index.openCursor(keyRange).onsuccess = function(event) {
  1.1064 +    let cursor = event.target.result;
  1.1065 +    if (cursor) {
  1.1066 +      count++;
  1.1067 +      cursor.continue();
  1.1068 +    }
  1.1069 +    else {
  1.1070 +      testGenerator.next();
  1.1071 +    }
  1.1072 +  }
  1.1073 +  yield undefined;
  1.1074 +
  1.1075 +  is(count, weightSort.length,
  1.1076 +     "Correct count for upperBound keyRange arg to index.openCursor");
  1.1077 +
  1.1078 +  count = 0;
  1.1079 +  keyRange = IDBKeyRange.upperBound(data[weightSort[weightSort.length - 1]].weight,
  1.1080 +                                    true);
  1.1081 +
  1.1082 +  index.openCursor(keyRange).onsuccess = function(event) {
  1.1083 +    let cursor = event.target.result;
  1.1084 +    if (cursor) {
  1.1085 +      count++;
  1.1086 +      cursor.continue();
  1.1087 +    }
  1.1088 +    else {
  1.1089 +      testGenerator.next();
  1.1090 +    }
  1.1091 +  }
  1.1092 +  yield undefined;
  1.1093 +
  1.1094 +  is(count, weightSort.length - 1,
  1.1095 +     "Correct count for upperBound keyRange arg to index.openCursor");
  1.1096 +
  1.1097 +  count = 0;
  1.1098 +  keyRange = IDBKeyRange.upperBound("foo");
  1.1099 +
  1.1100 +  index.openCursor(keyRange).onsuccess = function(event) {
  1.1101 +    let cursor = event.target.result;
  1.1102 +    if (cursor) {
  1.1103 +      count++;
  1.1104 +      cursor.continue();
  1.1105 +    }
  1.1106 +    else {
  1.1107 +      testGenerator.next();
  1.1108 +    }
  1.1109 +  }
  1.1110 +  yield undefined;
  1.1111 +
  1.1112 +  is(count, weightSort.length,
  1.1113 +     "Correct count for upperBound keyRange arg to index.openCursor");
  1.1114 +
  1.1115 +  count = 0;
  1.1116 +  keyRange = IDBKeyRange.upperBound(0);
  1.1117 +
  1.1118 +  index.openCursor(keyRange).onsuccess = function(event) {
  1.1119 +    let cursor = event.target.result;
  1.1120 +    if (cursor) {
  1.1121 +      count++;
  1.1122 +      cursor.continue();
  1.1123 +    }
  1.1124 +    else {
  1.1125 +      testGenerator.next();
  1.1126 +    }
  1.1127 +  }
  1.1128 +  yield undefined;
  1.1129 +
  1.1130 +  is(count, 0,
  1.1131 +     "Correct count for upperBound keyRange arg to index.openCursor");
  1.1132 +
  1.1133 +  count = 0;
  1.1134 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1.1135 +                               data[weightSort[weightSort.length - 1]].weight);
  1.1136 +
  1.1137 +  index.openCursor(keyRange).onsuccess = function(event) {
  1.1138 +    let cursor = event.target.result;
  1.1139 +    if (cursor) {
  1.1140 +      count++;
  1.1141 +      cursor.continue();
  1.1142 +    }
  1.1143 +    else {
  1.1144 +      testGenerator.next();
  1.1145 +    }
  1.1146 +  }
  1.1147 +  yield undefined;
  1.1148 +
  1.1149 +  is(count, weightSort.length,
  1.1150 +     "Correct count for bound keyRange arg to index.openCursor");
  1.1151 +
  1.1152 +  count = 0;
  1.1153 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1.1154 +                               data[weightSort[weightSort.length - 1]].weight,
  1.1155 +                               true);
  1.1156 +
  1.1157 +  index.openCursor(keyRange).onsuccess = function(event) {
  1.1158 +    let cursor = event.target.result;
  1.1159 +    if (cursor) {
  1.1160 +      count++;
  1.1161 +      cursor.continue();
  1.1162 +    }
  1.1163 +    else {
  1.1164 +      testGenerator.next();
  1.1165 +    }
  1.1166 +  }
  1.1167 +  yield undefined;
  1.1168 +
  1.1169 +  is(count, weightSort.length - 1,
  1.1170 +     "Correct count for bound keyRange arg to index.openCursor");
  1.1171 +
  1.1172 +  count = 0;
  1.1173 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1.1174 +                               data[weightSort[weightSort.length - 1]].weight,
  1.1175 +                               true, true);
  1.1176 +
  1.1177 +  index.openCursor(keyRange).onsuccess = function(event) {
  1.1178 +    let cursor = event.target.result;
  1.1179 +    if (cursor) {
  1.1180 +      count++;
  1.1181 +      cursor.continue();
  1.1182 +    }
  1.1183 +    else {
  1.1184 +      testGenerator.next();
  1.1185 +    }
  1.1186 +  }
  1.1187 +  yield undefined;
  1.1188 +
  1.1189 +  is(count, weightSort.length - 2,
  1.1190 +     "Correct count for bound keyRange arg to index.openCursor");
  1.1191 +
  1.1192 +  count = 0;
  1.1193 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight - 1,
  1.1194 +                               data[weightSort[weightSort.length - 1]].weight + 1);
  1.1195 +
  1.1196 +  index.openCursor(keyRange).onsuccess = function(event) {
  1.1197 +    let cursor = event.target.result;
  1.1198 +    if (cursor) {
  1.1199 +      count++;
  1.1200 +      cursor.continue();
  1.1201 +    }
  1.1202 +    else {
  1.1203 +      testGenerator.next();
  1.1204 +    }
  1.1205 +  }
  1.1206 +  yield undefined;
  1.1207 +
  1.1208 +  is(count, weightSort.length,
  1.1209 +     "Correct count for bound keyRange arg to index.openCursor");
  1.1210 +
  1.1211 +  count = 0;
  1.1212 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight - 2,
  1.1213 +                               data[weightSort[0]].weight - 1);
  1.1214 +
  1.1215 +  index.openCursor(keyRange).onsuccess = function(event) {
  1.1216 +    let cursor = event.target.result;
  1.1217 +    if (cursor) {
  1.1218 +      count++;
  1.1219 +      cursor.continue();
  1.1220 +    }
  1.1221 +    else {
  1.1222 +      testGenerator.next();
  1.1223 +    }
  1.1224 +  }
  1.1225 +  yield undefined;
  1.1226 +
  1.1227 +  is(count, 0,
  1.1228 +     "Correct count for bound keyRange arg to index.openCursor");
  1.1229 +
  1.1230 +  count = 0;
  1.1231 +  keyRange = IDBKeyRange.bound(data[weightSort[1]].weight,
  1.1232 +                               data[weightSort[2]].weight);
  1.1233 +
  1.1234 +  index.openCursor(keyRange).onsuccess = function(event) {
  1.1235 +    let cursor = event.target.result;
  1.1236 +    if (cursor) {
  1.1237 +      count++;
  1.1238 +      cursor.continue();
  1.1239 +    }
  1.1240 +    else {
  1.1241 +      testGenerator.next();
  1.1242 +    }
  1.1243 +  }
  1.1244 +  yield undefined;
  1.1245 +
  1.1246 +  is(count, 3,
  1.1247 +     "Correct count for bound keyRange arg to index.openCursor");
  1.1248 +
  1.1249 +  try {
  1.1250 +    index.get();
  1.1251 +    ok(false, "Get with unspecified arg should have thrown");
  1.1252 +  }
  1.1253 +  catch(e) {
  1.1254 +    ok(true, "Get with unspecified arg should have thrown");
  1.1255 +  }
  1.1256 +
  1.1257 +  try {
  1.1258 +    index.get(undefined);
  1.1259 +    ok(false, "Get with undefined should have thrown");
  1.1260 +  }
  1.1261 +  catch(e) {
  1.1262 +    ok(true, "Get with undefined arg should have thrown");
  1.1263 +  }
  1.1264 +
  1.1265 +  try {
  1.1266 +    index.get(null);
  1.1267 +    ok(false, "Get with null should have thrown");
  1.1268 +  }
  1.1269 +  catch(e) {
  1.1270 +    is(e instanceof DOMException, true,
  1.1271 +       "Got right kind of exception");
  1.1272 +    is(e.name, "DataError", "Correct error.");
  1.1273 +    is(e.code, 0, "Correct code.");
  1.1274 +  }
  1.1275 +
  1.1276 +  index.get(data[0].weight).onsuccess = grabEventAndContinueHandler;
  1.1277 +  event = yield undefined;
  1.1278 +
  1.1279 +  is(event.target.result.weight, data[0].weight, "Got correct result");
  1.1280 +
  1.1281 +  keyRange = IDBKeyRange.only(data[0].weight);
  1.1282 +
  1.1283 +  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1284 +  event = yield undefined;
  1.1285 +
  1.1286 +  is(event.target.result.weight, data[0].weight, "Got correct result");
  1.1287 +
  1.1288 +  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
  1.1289 +
  1.1290 +  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1291 +  event = yield undefined;
  1.1292 +
  1.1293 +  is(event.target.result.weight, data[weightSort[0]].weight,
  1.1294 +     "Got correct result");
  1.1295 +
  1.1296 +  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight - 1);
  1.1297 +
  1.1298 +  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1299 +  event = yield undefined;
  1.1300 +
  1.1301 +  is(event.target.result.weight, data[weightSort[0]].weight,
  1.1302 +     "Got correct result");
  1.1303 +
  1.1304 +  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight + 1);
  1.1305 +
  1.1306 +  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1307 +  event = yield undefined;
  1.1308 +
  1.1309 +  is(event.target.result.weight, data[weightSort[1]].weight,
  1.1310 +     "Got correct result");
  1.1311 +
  1.1312 +  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
  1.1313 +
  1.1314 +  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1315 +  event = yield undefined;
  1.1316 +
  1.1317 +  is(event.target.result.weight, data[weightSort[1]].weight,
  1.1318 +     "Got correct result");
  1.1319 +
  1.1320 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1.1321 +                               data[weightSort[1]].weight);
  1.1322 +
  1.1323 +  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1324 +  event = yield undefined;
  1.1325 +
  1.1326 +  is(event.target.result.weight, data[weightSort[0]].weight,
  1.1327 +     "Got correct result");
  1.1328 +
  1.1329 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1.1330 +                               data[weightSort[1]].weight, true);
  1.1331 +
  1.1332 +  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1333 +  event = yield undefined;
  1.1334 +
  1.1335 +  is(event.target.result.weight, data[weightSort[1]].weight,
  1.1336 +     "Got correct result");
  1.1337 +
  1.1338 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1.1339 +                               data[weightSort[1]].weight, true, true);
  1.1340 +
  1.1341 +  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1342 +  event = yield undefined;
  1.1343 +
  1.1344 +  is(event.target.result, undefined, "Got correct result");
  1.1345 +
  1.1346 +  keyRange = IDBKeyRange.upperBound(data[weightSort[5]].weight);
  1.1347 +
  1.1348 +  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1349 +  event = yield undefined;
  1.1350 +
  1.1351 +  is(event.target.result.weight, data[weightSort[0]].weight,
  1.1352 +     "Got correct result");
  1.1353 +
  1.1354 +  keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
  1.1355 +
  1.1356 +  index.get(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1357 +  event = yield undefined;
  1.1358 +
  1.1359 +  is(event.target.result, undefined, "Got correct result");
  1.1360 +
  1.1361 +  try {
  1.1362 +    index.getKey();
  1.1363 +    ok(false, "Get with unspecified arg should have thrown");
  1.1364 +  }
  1.1365 +  catch(e) {
  1.1366 +    ok(true, "Get with unspecified arg should have thrown");
  1.1367 +  }
  1.1368 +
  1.1369 +  try {
  1.1370 +    index.getKey(undefined);
  1.1371 +    ok(false, "Get with undefined should have thrown");
  1.1372 +  }
  1.1373 +  catch(e) {
  1.1374 +    ok(true, "Get with undefined arg should have thrown");
  1.1375 +  }
  1.1376 +
  1.1377 +  try {
  1.1378 +    index.getKey(null);
  1.1379 +    ok(false, "Get with null should have thrown");
  1.1380 +  }
  1.1381 +  catch(e) {
  1.1382 +    is(e instanceof DOMException, true,
  1.1383 +       "Got right kind of exception");
  1.1384 +    is(e.name, "DataError", "Correct error.");
  1.1385 +    is(e.code, 0, "Correct code.");
  1.1386 +  }
  1.1387 +
  1.1388 +  index.getKey(data[0].weight).onsuccess = grabEventAndContinueHandler;
  1.1389 +  event = yield undefined;
  1.1390 +
  1.1391 +  is(event.target.result, data[0].ssn, "Got correct result");
  1.1392 +
  1.1393 +  keyRange = IDBKeyRange.only(data[0].weight);
  1.1394 +
  1.1395 +  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1396 +  event = yield undefined;
  1.1397 +
  1.1398 +  is(event.target.result, data[0].ssn, "Got correct result");
  1.1399 +
  1.1400 +  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
  1.1401 +
  1.1402 +  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1403 +  event = yield undefined;
  1.1404 +
  1.1405 +  is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
  1.1406 +
  1.1407 +  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight - 1);
  1.1408 +
  1.1409 +  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1410 +  event = yield undefined;
  1.1411 +
  1.1412 +  is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
  1.1413 +
  1.1414 +  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight + 1);
  1.1415 +
  1.1416 +  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1417 +  event = yield undefined;
  1.1418 +
  1.1419 +  is(event.target.result, data[weightSort[1]].ssn, "Got correct result");
  1.1420 +
  1.1421 +  keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
  1.1422 +
  1.1423 +  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1424 +  event = yield undefined;
  1.1425 +
  1.1426 +  is(event.target.result, data[weightSort[1]].ssn, "Got correct result");
  1.1427 +
  1.1428 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1.1429 +                               data[weightSort[1]].weight);
  1.1430 +
  1.1431 +  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1432 +  event = yield undefined;
  1.1433 +
  1.1434 +  is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
  1.1435 +
  1.1436 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1.1437 +                               data[weightSort[1]].weight, true);
  1.1438 +
  1.1439 +  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1440 +  event = yield undefined;
  1.1441 +
  1.1442 +  is(event.target.result, data[weightSort[1]].ssn, "Got correct result");
  1.1443 +
  1.1444 +  keyRange = IDBKeyRange.bound(data[weightSort[0]].weight,
  1.1445 +                               data[weightSort[1]].weight, true, true);
  1.1446 +
  1.1447 +  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1448 +  event = yield undefined;
  1.1449 +
  1.1450 +  is(event.target.result, undefined, "Got correct result");
  1.1451 +
  1.1452 +  keyRange = IDBKeyRange.upperBound(data[weightSort[5]].weight);
  1.1453 +
  1.1454 +  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1455 +  event = yield undefined;
  1.1456 +
  1.1457 +  is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
  1.1458 +
  1.1459 +  keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
  1.1460 +
  1.1461 +  index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1462 +  event = yield undefined;
  1.1463 +
  1.1464 +  is(event.target.result, undefined, "Got correct result");
  1.1465 +
  1.1466 +  count = 0;
  1.1467 +
  1.1468 +  index.openKeyCursor().onsuccess = function(event) {
  1.1469 +    let cursor = event.target.result;
  1.1470 +    if (cursor) {
  1.1471 +      count++;
  1.1472 +      cursor.continue();
  1.1473 +    }
  1.1474 +    else {
  1.1475 +      testGenerator.next();
  1.1476 +    }
  1.1477 +  }
  1.1478 +  yield undefined;
  1.1479 +
  1.1480 +  is(count, weightSort.length,
  1.1481 +     "Correct count for no arg to index.openKeyCursor");
  1.1482 +
  1.1483 +  count = 0;
  1.1484 +
  1.1485 +  index.openKeyCursor(null).onsuccess = function(event) {
  1.1486 +    let cursor = event.target.result;
  1.1487 +    if (cursor) {
  1.1488 +      count++;
  1.1489 +      cursor.continue();
  1.1490 +    }
  1.1491 +    else {
  1.1492 +      testGenerator.next();
  1.1493 +    }
  1.1494 +  }
  1.1495 +  yield undefined;
  1.1496 +
  1.1497 +  is(count, weightSort.length,
  1.1498 +     "Correct count for null arg to index.openKeyCursor");
  1.1499 +
  1.1500 +  count = 0;
  1.1501 +
  1.1502 +  index.openKeyCursor(undefined).onsuccess = function(event) {
  1.1503 +    let cursor = event.target.result;
  1.1504 +    if (cursor) {
  1.1505 +      count++;
  1.1506 +      cursor.continue();
  1.1507 +    }
  1.1508 +    else {
  1.1509 +      testGenerator.next();
  1.1510 +    }
  1.1511 +  }
  1.1512 +  yield undefined;
  1.1513 +
  1.1514 +  is(count, weightSort.length,
  1.1515 +     "Correct count for undefined arg to index.openKeyCursor");
  1.1516 +
  1.1517 +  count = 0;
  1.1518 +
  1.1519 +  index.openKeyCursor(data[weightSort[0]].weight).onsuccess = function(event) {
  1.1520 +    let cursor = event.target.result;
  1.1521 +    if (cursor) {
  1.1522 +      count++;
  1.1523 +      cursor.continue();
  1.1524 +    }
  1.1525 +    else {
  1.1526 +      testGenerator.next();
  1.1527 +    }
  1.1528 +  }
  1.1529 +  yield undefined;
  1.1530 +
  1.1531 +  is(count, 1, "Correct count for single key arg to index.openKeyCursor");
  1.1532 +
  1.1533 +  count = 0;
  1.1534 +
  1.1535 +  index.openKeyCursor("foo").onsuccess = function(event) {
  1.1536 +    let cursor = event.target.result;
  1.1537 +    if (cursor) {
  1.1538 +      count++;
  1.1539 +      cursor.continue();
  1.1540 +    }
  1.1541 +    else {
  1.1542 +      testGenerator.next();
  1.1543 +    }
  1.1544 +  }
  1.1545 +  yield undefined;
  1.1546 +
  1.1547 +  is(count, 0,
  1.1548 +     "Correct count for non-existent single key arg to index.openKeyCursor");
  1.1549 +
  1.1550 +  count = 0;
  1.1551 +  keyRange = IDBKeyRange.only(data[weightSort[0]].weight);
  1.1552 +
  1.1553 +  index.openKeyCursor(keyRange).onsuccess = function(event) {
  1.1554 +    let cursor = event.target.result;
  1.1555 +    if (cursor) {
  1.1556 +      count++;
  1.1557 +      cursor.continue();
  1.1558 +    }
  1.1559 +    else {
  1.1560 +      testGenerator.next();
  1.1561 +    }
  1.1562 +  }
  1.1563 +  yield undefined;
  1.1564 +
  1.1565 +  is(count, 1,
  1.1566 +     "Correct count for only keyRange arg to index.openKeyCursor");
  1.1567 +
  1.1568 +  objectStore.mozGetAll(data[1].ssn).onsuccess = grabEventAndContinueHandler;
  1.1569 +  event = yield undefined;
  1.1570 +
  1.1571 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1572 +  is(event.target.result.length, 1, "Got correct length");
  1.1573 +  is(event.target.result[0].ssn, data[1].ssn, "Got correct result");
  1.1574 +
  1.1575 +  objectStore.mozGetAll(null).onsuccess = grabEventAndContinueHandler;
  1.1576 +  event = yield undefined;
  1.1577 +
  1.1578 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1579 +  is(event.target.result.length, data.length, "Got correct length");
  1.1580 +  for (let i in event.target.result) {
  1.1581 +    is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
  1.1582 +  }
  1.1583 +
  1.1584 +  objectStore.mozGetAll(undefined).onsuccess = grabEventAndContinueHandler;
  1.1585 +  event = yield undefined;
  1.1586 +
  1.1587 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1588 +  is(event.target.result.length, data.length, "Got correct length");
  1.1589 +  for (let i in event.target.result) {
  1.1590 +    is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
  1.1591 +  }
  1.1592 +
  1.1593 +  objectStore.mozGetAll().onsuccess = grabEventAndContinueHandler;
  1.1594 +  event = yield undefined;
  1.1595 +
  1.1596 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1597 +  is(event.target.result.length, data.length, "Got correct length");
  1.1598 +  for (let i in event.target.result) {
  1.1599 +    is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
  1.1600 +  }
  1.1601 +
  1.1602 +  keyRange = IDBKeyRange.lowerBound(0);
  1.1603 +
  1.1604 +  objectStore.mozGetAll(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1605 +  event = yield undefined;
  1.1606 +
  1.1607 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1608 +  is(event.target.result.length, data.length, "Got correct length");
  1.1609 +  for (let i in event.target.result) {
  1.1610 +    is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
  1.1611 +  }
  1.1612 +
  1.1613 +  index.mozGetAll().onsuccess = grabEventAndContinueHandler;
  1.1614 +  event = yield undefined;
  1.1615 +
  1.1616 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1617 +  is(event.target.result.length, weightSort.length, "Got correct length");
  1.1618 +  for (let i in event.target.result) {
  1.1619 +    is(event.target.result[i].ssn, data[weightSort[i]].ssn,
  1.1620 +       "Got correct value");
  1.1621 +  }
  1.1622 +
  1.1623 +  index.mozGetAll(undefined).onsuccess = grabEventAndContinueHandler;
  1.1624 +  event = yield undefined;
  1.1625 +
  1.1626 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1627 +  is(event.target.result.length, weightSort.length, "Got correct length");
  1.1628 +  for (let i in event.target.result) {
  1.1629 +    is(event.target.result[i].ssn, data[weightSort[i]].ssn,
  1.1630 +       "Got correct value");
  1.1631 +  }
  1.1632 +
  1.1633 +  index.mozGetAll(null).onsuccess = grabEventAndContinueHandler;
  1.1634 +  event = yield undefined;
  1.1635 +
  1.1636 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1637 +  is(event.target.result.length, weightSort.length, "Got correct length");
  1.1638 +  for (let i in event.target.result) {
  1.1639 +    is(event.target.result[i].ssn, data[weightSort[i]].ssn,
  1.1640 +       "Got correct value");
  1.1641 +  }
  1.1642 +
  1.1643 +  index.mozGetAll(data[weightSort[0]].weight).onsuccess = grabEventAndContinueHandler;
  1.1644 +  event = yield undefined;
  1.1645 +
  1.1646 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1647 +  is(event.target.result.length, 1, "Got correct length");
  1.1648 +  is(event.target.result[0].ssn, data[weightSort[0]].ssn, "Got correct result");
  1.1649 +
  1.1650 +  keyRange = IDBKeyRange.lowerBound(0);
  1.1651 +
  1.1652 +  index.mozGetAll(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1653 +  event = yield undefined;
  1.1654 +
  1.1655 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1656 +  is(event.target.result.length, weightSort.length, "Got correct length");
  1.1657 +  for (let i in event.target.result) {
  1.1658 +    is(event.target.result[i].ssn, data[weightSort[i]].ssn,
  1.1659 +       "Got correct value");
  1.1660 +  }
  1.1661 +
  1.1662 +  index.mozGetAllKeys().onsuccess = grabEventAndContinueHandler;
  1.1663 +  event = yield undefined;
  1.1664 +
  1.1665 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1666 +  is(event.target.result.length, weightSort.length, "Got correct length");
  1.1667 +  for (let i in event.target.result) {
  1.1668 +    is(event.target.result[i], data[weightSort[i]].ssn,
  1.1669 +       "Got correct value");
  1.1670 +  }
  1.1671 +
  1.1672 +  index.mozGetAllKeys(undefined).onsuccess = grabEventAndContinueHandler;
  1.1673 +  event = yield undefined;
  1.1674 +
  1.1675 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1676 +  is(event.target.result.length, weightSort.length, "Got correct length");
  1.1677 +  for (let i in event.target.result) {
  1.1678 +    is(event.target.result[i], data[weightSort[i]].ssn,
  1.1679 +       "Got correct value");
  1.1680 +  }
  1.1681 +
  1.1682 +  index.mozGetAllKeys(null).onsuccess = grabEventAndContinueHandler;
  1.1683 +  event = yield undefined;
  1.1684 +
  1.1685 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1686 +  is(event.target.result.length, weightSort.length, "Got correct length");
  1.1687 +  for (let i in event.target.result) {
  1.1688 +    is(event.target.result[i], data[weightSort[i]].ssn,
  1.1689 +       "Got correct value");
  1.1690 +  }
  1.1691 +
  1.1692 +  index.mozGetAllKeys(data[weightSort[0]].weight).onsuccess = grabEventAndContinueHandler;
  1.1693 +  event = yield undefined;
  1.1694 +
  1.1695 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1696 +  is(event.target.result.length, 1, "Got correct length");
  1.1697 +  is(event.target.result[0], data[weightSort[0]].ssn, "Got correct result");
  1.1698 +
  1.1699 +  keyRange = IDBKeyRange.lowerBound(0);
  1.1700 +
  1.1701 +  index.mozGetAllKeys(keyRange).onsuccess = grabEventAndContinueHandler;
  1.1702 +  event = yield undefined;
  1.1703 +
  1.1704 +  is(event.target.result instanceof Array, true, "Got an array");
  1.1705 +  is(event.target.result.length, weightSort.length, "Got correct length");
  1.1706 +  for (let i in event.target.result) {
  1.1707 +    is(event.target.result[i], data[weightSort[i]].ssn,
  1.1708 +       "Got correct value");
  1.1709 +  }
  1.1710 +
  1.1711 +  finishTest();
  1.1712 +  yield undefined;
  1.1713 +}
  1.1714 +

mercurial