dom/indexedDB/test/unit/test_indexes.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/indexedDB/test/unit/test_indexes.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1261 @@
     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 name = this.window ? window.location.pathname : "Splendid Test";
    1.14 +
    1.15 +  const objectStoreName = "People";
    1.16 +
    1.17 +  const objectStoreData = [
    1.18 +    { key: "237-23-7732", value: { name: "Bob", height: 60, weight: 120 } },
    1.19 +    { key: "237-23-7733", value: { name: "Ann", height: 52, weight: 110 } },
    1.20 +    { key: "237-23-7734", value: { name: "Ron", height: 73, weight: 180 } },
    1.21 +    { key: "237-23-7735", value: { name: "Sue", height: 58, weight: 130 } },
    1.22 +    { key: "237-23-7736", value: { name: "Joe", height: 65, weight: 150 } },
    1.23 +    { key: "237-23-7737", value: { name: "Pat", height: 65 } }
    1.24 +  ];
    1.25 +
    1.26 +  const indexData = [
    1.27 +    { name: "name", keyPath: "name", options: { unique: true } },
    1.28 +    { name: "height", keyPath: "height", options: { } },
    1.29 +    { name: "weight", keyPath: "weight", options: { unique: false } }
    1.30 +  ];
    1.31 +
    1.32 +  const objectStoreDataNameSort = [
    1.33 +    { key: "237-23-7733", value: { name: "Ann", height: 52, weight: 110 } },
    1.34 +    { key: "237-23-7732", value: { name: "Bob", height: 60, weight: 120 } },
    1.35 +    { key: "237-23-7736", value: { name: "Joe", height: 65, weight: 150 } },
    1.36 +    { key: "237-23-7737", value: { name: "Pat", height: 65 } },
    1.37 +    { key: "237-23-7734", value: { name: "Ron", height: 73, weight: 180 } },
    1.38 +    { key: "237-23-7735", value: { name: "Sue", height: 58, weight: 130 } }
    1.39 +  ];
    1.40 +
    1.41 +  const objectStoreDataWeightSort = [
    1.42 +    { key: "237-23-7733", value: { name: "Ann", height: 52, weight: 110 } },
    1.43 +    { key: "237-23-7732", value: { name: "Bob", height: 60, weight: 120 } },
    1.44 +    { key: "237-23-7735", value: { name: "Sue", height: 58, weight: 130 } },
    1.45 +    { key: "237-23-7736", value: { name: "Joe", height: 65, weight: 150 } },
    1.46 +    { key: "237-23-7734", value: { name: "Ron", height: 73, weight: 180 } }
    1.47 +  ];
    1.48 +
    1.49 +  const objectStoreDataHeightSort = [
    1.50 +    { key: "237-23-7733", value: { name: "Ann", height: 52, weight: 110 } },
    1.51 +    { key: "237-23-7735", value: { name: "Sue", height: 58, weight: 130 } },
    1.52 +    { key: "237-23-7732", value: { name: "Bob", height: 60, weight: 120 } },
    1.53 +    { key: "237-23-7736", value: { name: "Joe", height: 65, weight: 150 } },
    1.54 +    { key: "237-23-7737", value: { name: "Pat", height: 65 } },
    1.55 +    { key: "237-23-7734", value: { name: "Ron", height: 73, weight: 180 } }
    1.56 +  ];
    1.57 +
    1.58 +  let request = indexedDB.open(name, 1);
    1.59 +  request.onerror = errorHandler;
    1.60 +  request.onupgradeneeded = grabEventAndContinueHandler;
    1.61 +  request.onsuccess = grabEventAndContinueHandler;
    1.62 +  let event = yield undefined;
    1.63 +  let db = event.target.result;
    1.64 +
    1.65 +  let objectStore = db.createObjectStore(objectStoreName, { keyPath: null });
    1.66 +
    1.67 +  // First, add all our data to the object store.
    1.68 +  let addedData = 0;
    1.69 +  for (let i in objectStoreData) {
    1.70 +    request = objectStore.add(objectStoreData[i].value,
    1.71 +                              objectStoreData[i].key);
    1.72 +    request.onerror = errorHandler;
    1.73 +    request.onsuccess = function(event) {
    1.74 +      if (++addedData == objectStoreData.length) {
    1.75 +        testGenerator.send(event);
    1.76 +      }
    1.77 +    }
    1.78 +  }
    1.79 +  event = yield undefined;
    1.80 +  // Now create the indexes.
    1.81 +  for (let i in indexData) {
    1.82 +    objectStore.createIndex(indexData[i].name, indexData[i].keyPath,
    1.83 +                            indexData[i].options);
    1.84 +  }
    1.85 +  is(objectStore.indexNames.length, indexData.length, "Good index count");
    1.86 +  yield undefined;
    1.87 +  objectStore = db.transaction(objectStoreName)
    1.88 +                  .objectStore(objectStoreName);
    1.89 +
    1.90 +  // Check global properties to make sure they are correct.
    1.91 +  is(objectStore.indexNames.length, indexData.length, "Good index count");
    1.92 +  for (let i in indexData) {
    1.93 +    let found = false;
    1.94 +    for (let j = 0; j < objectStore.indexNames.length; j++) {
    1.95 +      if (objectStore.indexNames.item(j) == indexData[i].name) {
    1.96 +        found = true;
    1.97 +        break;
    1.98 +      }
    1.99 +    }
   1.100 +    is(found, true, "objectStore has our index");
   1.101 +    let index = objectStore.index(indexData[i].name);
   1.102 +    is(index.name, indexData[i].name, "Correct name");
   1.103 +    is(index.storeName, objectStore.name, "Correct store name");
   1.104 +    is(index.keyPath, indexData[i].keyPath, "Correct keyPath");
   1.105 +    is(index.unique, indexData[i].options.unique ? true : false,
   1.106 +       "Correct unique value");
   1.107 +  }
   1.108 +
   1.109 +  request = objectStore.index("name").getKey("Bob");
   1.110 +  request.onerror = errorHandler;
   1.111 +  request.onsuccess = grabEventAndContinueHandler;
   1.112 +  event = yield undefined;
   1.113 +
   1.114 +  is(event.target.result, "237-23-7732", "Correct key returned!");
   1.115 +
   1.116 +  request = objectStore.index("name").get("Bob");
   1.117 +  request.onerror = errorHandler;
   1.118 +  request.onsuccess = grabEventAndContinueHandler;
   1.119 +  event = yield undefined;
   1.120 +
   1.121 +  is(event.target.result.name, "Bob", "Correct name returned!");
   1.122 +  is(event.target.result.height, 60, "Correct height returned!");
   1.123 +  is(event.target.result.weight, 120, "Correct weight returned!");
   1.124 +
   1.125 +  ok(true, "Test group 1");
   1.126 +
   1.127 +  let keyIndex = 0;
   1.128 +
   1.129 +  request = objectStore.index("name").openKeyCursor();
   1.130 +  request.onerror = errorHandler;
   1.131 +  request.onsuccess = function (event) {
   1.132 +    let cursor = event.target.result;
   1.133 +    if (cursor) {
   1.134 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.135 +         "Correct key");
   1.136 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.137 +         "Correct primary key");
   1.138 +      ok(!("value" in cursor), "No value");
   1.139 +
   1.140 +      cursor.continue();
   1.141 +
   1.142 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.143 +         "Correct key");
   1.144 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.145 +         "Correct value");
   1.146 +      ok(!("value" in cursor), "No value");
   1.147 +
   1.148 +      keyIndex++;
   1.149 +    }
   1.150 +    else {
   1.151 +      testGenerator.next();
   1.152 +    }
   1.153 +  }
   1.154 +  yield undefined;
   1.155 +
   1.156 +  is(keyIndex, objectStoreData.length, "Saw all the expected keys");
   1.157 +
   1.158 +  ok(true, "Test group 2");
   1.159 +
   1.160 +  keyIndex = 0;
   1.161 +
   1.162 +  request = objectStore.index("weight").openKeyCursor(null, "next");
   1.163 +  request.onerror = errorHandler;
   1.164 +  request.onsuccess = function (event) {
   1.165 +    let cursor = event.target.result;
   1.166 +    if (cursor) {
   1.167 +      is(cursor.key, objectStoreDataWeightSort[keyIndex].value.weight,
   1.168 +         "Correct key");
   1.169 +      is(cursor.primaryKey, objectStoreDataWeightSort[keyIndex].key,
   1.170 +         "Correct value");
   1.171 +
   1.172 +      cursor.continue();
   1.173 +
   1.174 +      is(cursor.key, objectStoreDataWeightSort[keyIndex].value.weight,
   1.175 +         "Correct key");
   1.176 +      is(cursor.primaryKey, objectStoreDataWeightSort[keyIndex].key,
   1.177 +         "Correct value");
   1.178 +
   1.179 +      keyIndex++;
   1.180 +    }
   1.181 +    else {
   1.182 +      testGenerator.next();
   1.183 +    }
   1.184 +  }
   1.185 +  yield undefined;
   1.186 +
   1.187 +  is(keyIndex, objectStoreData.length - 1, "Saw all the expected keys");
   1.188 +
   1.189 +  // Check that the name index enforces its unique constraint.
   1.190 +  objectStore = db.transaction(objectStoreName, "readwrite")
   1.191 +                  .objectStore(objectStoreName);
   1.192 +  request = objectStore.add({ name: "Bob", height: 62, weight: 170 },
   1.193 +                            "237-23-7738");
   1.194 +  request.addEventListener("error", new ExpectError("ConstraintError", true));
   1.195 +  request.onsuccess = unexpectedSuccessHandler;
   1.196 +  event = yield undefined;
   1.197 +
   1.198 +  ok(true, "Test group 3");
   1.199 +
   1.200 +  keyIndex = objectStoreDataNameSort.length - 1;
   1.201 +
   1.202 +  request = objectStore.index("name").openKeyCursor(null, "prev");
   1.203 +  request.onerror = errorHandler;
   1.204 +  request.onsuccess = function (event) {
   1.205 +    let cursor = event.target.result;
   1.206 +    if (cursor) {
   1.207 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.208 +         "Correct key");
   1.209 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.210 +         "Correct value");
   1.211 +
   1.212 +      cursor.continue();
   1.213 +
   1.214 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.215 +         "Correct key");
   1.216 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.217 +         "Correct value");
   1.218 +
   1.219 +      keyIndex--;
   1.220 +    }
   1.221 +    else {
   1.222 +      testGenerator.next();
   1.223 +    }
   1.224 +  }
   1.225 +  yield undefined;
   1.226 +
   1.227 +  is(keyIndex, -1, "Saw all the expected keys");
   1.228 +
   1.229 +  ok(true, "Test group 4");
   1.230 +
   1.231 +  keyIndex = 1;
   1.232 +  let keyRange = IDBKeyRange.bound("Bob", "Ron");
   1.233 +
   1.234 +  request = objectStore.index("name").openKeyCursor(keyRange);
   1.235 +  request.onerror = errorHandler;
   1.236 +  request.onsuccess = function (event) {
   1.237 +    let cursor = event.target.result;
   1.238 +    if (cursor) {
   1.239 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.240 +         "Correct key");
   1.241 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.242 +         "Correct value");
   1.243 +
   1.244 +      cursor.continue();
   1.245 +      keyIndex++;
   1.246 +    }
   1.247 +    else {
   1.248 +      testGenerator.next();
   1.249 +    }
   1.250 +  }
   1.251 +  yield undefined;
   1.252 +
   1.253 +  is(keyIndex, 5, "Saw all the expected keys");
   1.254 +
   1.255 +  ok(true, "Test group 5");
   1.256 +
   1.257 +  keyIndex = 2;
   1.258 +  let keyRange = IDBKeyRange.bound("Bob", "Ron", true);
   1.259 +
   1.260 +  request = objectStore.index("name").openKeyCursor(keyRange);
   1.261 +  request.onerror = errorHandler;
   1.262 +  request.onsuccess = function (event) {
   1.263 +    let cursor = event.target.result;
   1.264 +    if (cursor) {
   1.265 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.266 +         "Correct key");
   1.267 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.268 +         "Correct value");
   1.269 +
   1.270 +      cursor.continue();
   1.271 +      keyIndex++;
   1.272 +    }
   1.273 +    else {
   1.274 +      testGenerator.next();
   1.275 +    }
   1.276 +  }
   1.277 +  yield undefined;
   1.278 +
   1.279 +  is(keyIndex, 5, "Saw all the expected keys");
   1.280 +
   1.281 +  ok(true, "Test group 6");
   1.282 +
   1.283 +  keyIndex = 1;
   1.284 +  let keyRange = IDBKeyRange.bound("Bob", "Ron", false, true);
   1.285 +
   1.286 +  request = objectStore.index("name").openKeyCursor(keyRange);
   1.287 +  request.onerror = errorHandler;
   1.288 +  request.onsuccess = function (event) {
   1.289 +    let cursor = event.target.result;
   1.290 +    if (cursor) {
   1.291 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.292 +         "Correct key");
   1.293 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.294 +         "Correct value");
   1.295 +
   1.296 +      cursor.continue();
   1.297 +      keyIndex++;
   1.298 +    }
   1.299 +    else {
   1.300 +      testGenerator.next();
   1.301 +    }
   1.302 +  }
   1.303 +  yield undefined;
   1.304 +
   1.305 +  is(keyIndex, 4, "Saw all the expected keys");
   1.306 +
   1.307 +  ok(true, "Test group 7");
   1.308 +
   1.309 +  keyIndex = 2;
   1.310 +  keyRange = IDBKeyRange.bound("Bob", "Ron", true, true);
   1.311 +
   1.312 +  request = objectStore.index("name").openKeyCursor(keyRange);
   1.313 +  request.onerror = errorHandler;
   1.314 +  request.onsuccess = function (event) {
   1.315 +    let cursor = event.target.result;
   1.316 +    if (cursor) {
   1.317 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.318 +         "Correct key");
   1.319 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.320 +         "Correct value");
   1.321 +
   1.322 +      cursor.continue();
   1.323 +      keyIndex++;
   1.324 +    }
   1.325 +    else {
   1.326 +      testGenerator.next();
   1.327 +    }
   1.328 +  }
   1.329 +  yield undefined;
   1.330 +
   1.331 +  is(keyIndex, 4, "Saw all the expected keys");
   1.332 +
   1.333 +  ok(true, "Test group 8");
   1.334 +
   1.335 +  keyIndex = 1;
   1.336 +  keyRange = IDBKeyRange.lowerBound("Bob");
   1.337 +
   1.338 +  request = objectStore.index("name").openKeyCursor(keyRange);
   1.339 +  request.onerror = errorHandler;
   1.340 +  request.onsuccess = function (event) {
   1.341 +    let cursor = event.target.result;
   1.342 +    if (cursor) {
   1.343 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.344 +         "Correct key");
   1.345 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.346 +         "Correct value");
   1.347 +
   1.348 +      cursor.continue();
   1.349 +      keyIndex++;
   1.350 +    }
   1.351 +    else {
   1.352 +      testGenerator.next();
   1.353 +    }
   1.354 +  }
   1.355 +  yield undefined;
   1.356 +
   1.357 +  is(keyIndex, objectStoreDataNameSort.length, "Saw all the expected keys");
   1.358 +
   1.359 +  ok(true, "Test group 9");
   1.360 +
   1.361 +  keyIndex = 2;
   1.362 +  keyRange = IDBKeyRange.lowerBound("Bob", true);
   1.363 +
   1.364 +  request = objectStore.index("name").openKeyCursor(keyRange);
   1.365 +  request.onerror = errorHandler;
   1.366 +  request.onsuccess = function (event) {
   1.367 +    let cursor = event.target.result;
   1.368 +    if (cursor) {
   1.369 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.370 +         "Correct key");
   1.371 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.372 +         "Correct value");
   1.373 +
   1.374 +      cursor.continue();
   1.375 +      keyIndex++;
   1.376 +    }
   1.377 +    else {
   1.378 +      testGenerator.next();
   1.379 +    }
   1.380 +  }
   1.381 +  yield undefined;
   1.382 +
   1.383 +  is(keyIndex, objectStoreDataNameSort.length, "Saw all the expected keys");
   1.384 +
   1.385 +  ok(true, "Test group 10");
   1.386 +
   1.387 +  keyIndex = 0;
   1.388 +  keyRange = IDBKeyRange.upperBound("Joe");
   1.389 +
   1.390 +  request = objectStore.index("name").openKeyCursor(keyRange);
   1.391 +  request.onerror = errorHandler;
   1.392 +  request.onsuccess = function (event) {
   1.393 +    let cursor = event.target.result;
   1.394 +    if (cursor) {
   1.395 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.396 +         "Correct key");
   1.397 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.398 +         "Correct value");
   1.399 +
   1.400 +      cursor.continue();
   1.401 +      keyIndex++;
   1.402 +    }
   1.403 +    else {
   1.404 +      testGenerator.next();
   1.405 +    }
   1.406 +  }
   1.407 +  yield undefined;
   1.408 +
   1.409 +  is(keyIndex, 3, "Saw all the expected keys");
   1.410 +
   1.411 +  ok(true, "Test group 11");
   1.412 +
   1.413 +  keyIndex = 0;
   1.414 +  keyRange = IDBKeyRange.upperBound("Joe", true);
   1.415 +
   1.416 +  request = objectStore.index("name").openKeyCursor(keyRange);
   1.417 +  request.onerror = errorHandler;
   1.418 +  request.onsuccess = function (event) {
   1.419 +    let cursor = event.target.result;
   1.420 +    if (cursor) {
   1.421 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.422 +         "Correct key");
   1.423 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.424 +         "Correct value");
   1.425 +
   1.426 +      cursor.continue();
   1.427 +      keyIndex++;
   1.428 +    }
   1.429 +    else {
   1.430 +      testGenerator.next();
   1.431 +    }
   1.432 +  }
   1.433 +  yield undefined;
   1.434 +
   1.435 +  is(keyIndex, 2, "Saw all the expected keys");
   1.436 +
   1.437 +  ok(true, "Test group 12");
   1.438 +
   1.439 +  keyIndex = 3;
   1.440 +  keyRange = IDBKeyRange.only("Pat");
   1.441 +
   1.442 +  request = objectStore.index("name").openKeyCursor(keyRange);
   1.443 +  request.onerror = errorHandler;
   1.444 +  request.onsuccess = function (event) {
   1.445 +    let cursor = event.target.result;
   1.446 +    if (cursor) {
   1.447 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.448 +         "Correct key");
   1.449 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.450 +         "Correct value");
   1.451 +
   1.452 +      cursor.continue();
   1.453 +      keyIndex++;
   1.454 +    }
   1.455 +    else {
   1.456 +      testGenerator.next();
   1.457 +    }
   1.458 +  }
   1.459 +  yield undefined;
   1.460 +
   1.461 +  is(keyIndex, 4, "Saw all the expected keys");
   1.462 +
   1.463 +  ok(true, "Test group 13");
   1.464 +
   1.465 +  keyIndex = 0;
   1.466 +
   1.467 +  request = objectStore.index("name").openCursor();
   1.468 +  request.onerror = errorHandler;
   1.469 +  request.onsuccess = function (event) {
   1.470 +    let cursor = event.target.result;
   1.471 +    if (cursor) {
   1.472 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.473 +         "Correct key");
   1.474 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.475 +         "Correct primary key");
   1.476 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.477 +         "Correct name");
   1.478 +      is(cursor.value.height,
   1.479 +         objectStoreDataNameSort[keyIndex].value.height,
   1.480 +         "Correct height");
   1.481 +      if ("weight" in cursor.value) {
   1.482 +        is(cursor.value.weight,
   1.483 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.484 +           "Correct weight");
   1.485 +      }
   1.486 +
   1.487 +      cursor.continue();
   1.488 +
   1.489 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.490 +         "Correct key");
   1.491 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.492 +         "Correct primary key");
   1.493 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.494 +         "Correct name");
   1.495 +      is(cursor.value.height,
   1.496 +         objectStoreDataNameSort[keyIndex].value.height,
   1.497 +         "Correct height");
   1.498 +      if ("weight" in cursor.value) {
   1.499 +        is(cursor.value.weight,
   1.500 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.501 +           "Correct weight");
   1.502 +      }
   1.503 +
   1.504 +      keyIndex++;
   1.505 +    }
   1.506 +    else {
   1.507 +      testGenerator.next();
   1.508 +    }
   1.509 +  }
   1.510 +  yield undefined;
   1.511 +
   1.512 +  is(keyIndex, objectStoreDataNameSort.length, "Saw all the expected keys");
   1.513 +
   1.514 +  ok(true, "Test group 14");
   1.515 +
   1.516 +  keyIndex = objectStoreDataNameSort.length - 1;
   1.517 +
   1.518 +  request = objectStore.index("name").openCursor(null, "prev");
   1.519 +  request.onerror = errorHandler;
   1.520 +  request.onsuccess = function (event) {
   1.521 +    let cursor = event.target.result;
   1.522 +    if (cursor) {
   1.523 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.524 +         "Correct key");
   1.525 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.526 +         "Correct primary key");
   1.527 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.528 +         "Correct name");
   1.529 +      is(cursor.value.height,
   1.530 +         objectStoreDataNameSort[keyIndex].value.height,
   1.531 +         "Correct height");
   1.532 +      if ("weight" in cursor.value) {
   1.533 +        is(cursor.value.weight,
   1.534 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.535 +           "Correct weight");
   1.536 +      }
   1.537 +
   1.538 +      cursor.continue();
   1.539 +
   1.540 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.541 +         "Correct key");
   1.542 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.543 +         "Correct primary key");
   1.544 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.545 +         "Correct name");
   1.546 +      is(cursor.value.height,
   1.547 +         objectStoreDataNameSort[keyIndex].value.height,
   1.548 +         "Correct height");
   1.549 +      if ("weight" in cursor.value) {
   1.550 +        is(cursor.value.weight,
   1.551 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.552 +           "Correct weight");
   1.553 +      }
   1.554 +
   1.555 +      keyIndex--;
   1.556 +    }
   1.557 +    else {
   1.558 +      testGenerator.next();
   1.559 +    }
   1.560 +  }
   1.561 +  yield undefined;
   1.562 +
   1.563 +  is(keyIndex, -1, "Saw all the expected keys");
   1.564 +
   1.565 +  ok(true, "Test group 15");
   1.566 +
   1.567 +  keyIndex = 1;
   1.568 +  keyRange = IDBKeyRange.bound("Bob", "Ron");
   1.569 +
   1.570 +  request = objectStore.index("name").openCursor(keyRange);
   1.571 +  request.onerror = errorHandler;
   1.572 +  request.onsuccess = function (event) {
   1.573 +    let cursor = event.target.result;
   1.574 +    if (cursor) {
   1.575 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.576 +         "Correct key");
   1.577 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.578 +         "Correct primary key");
   1.579 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.580 +         "Correct name");
   1.581 +      is(cursor.value.height,
   1.582 +         objectStoreDataNameSort[keyIndex].value.height,
   1.583 +         "Correct height");
   1.584 +      if ("weight" in cursor.value) {
   1.585 +        is(cursor.value.weight,
   1.586 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.587 +           "Correct weight");
   1.588 +      }
   1.589 +
   1.590 +      cursor.continue();
   1.591 +
   1.592 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.593 +         "Correct key");
   1.594 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.595 +         "Correct primary key");
   1.596 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.597 +         "Correct name");
   1.598 +      is(cursor.value.height,
   1.599 +         objectStoreDataNameSort[keyIndex].value.height,
   1.600 +         "Correct height");
   1.601 +      if ("weight" in cursor.value) {
   1.602 +        is(cursor.value.weight,
   1.603 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.604 +           "Correct weight");
   1.605 +      }
   1.606 +
   1.607 +      keyIndex++;
   1.608 +    }
   1.609 +    else {
   1.610 +      testGenerator.next();
   1.611 +    }
   1.612 +  }
   1.613 +  yield undefined;
   1.614 +
   1.615 +  is(keyIndex, 5, "Saw all the expected keys");
   1.616 +
   1.617 +  ok(true, "Test group 16");
   1.618 +
   1.619 +  keyIndex = 2;
   1.620 +  keyRange = IDBKeyRange.bound("Bob", "Ron", true);
   1.621 +
   1.622 +  request = objectStore.index("name").openCursor(keyRange);
   1.623 +  request.onerror = errorHandler;
   1.624 +  request.onsuccess = function (event) {
   1.625 +    let cursor = event.target.result;
   1.626 +    if (cursor) {
   1.627 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.628 +         "Correct key");
   1.629 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.630 +         "Correct primary key");
   1.631 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.632 +         "Correct name");
   1.633 +      is(cursor.value.height,
   1.634 +         objectStoreDataNameSort[keyIndex].value.height,
   1.635 +         "Correct height");
   1.636 +      if ("weight" in cursor.value) {
   1.637 +        is(cursor.value.weight,
   1.638 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.639 +           "Correct weight");
   1.640 +      }
   1.641 +
   1.642 +      cursor.continue();
   1.643 +
   1.644 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.645 +         "Correct key");
   1.646 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.647 +         "Correct primary key");
   1.648 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.649 +         "Correct name");
   1.650 +      is(cursor.value.height,
   1.651 +         objectStoreDataNameSort[keyIndex].value.height,
   1.652 +         "Correct height");
   1.653 +      if ("weight" in cursor.value) {
   1.654 +        is(cursor.value.weight,
   1.655 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.656 +           "Correct weight");
   1.657 +      }
   1.658 +
   1.659 +      keyIndex++;
   1.660 +    }
   1.661 +    else {
   1.662 +      testGenerator.next();
   1.663 +    }
   1.664 +  }
   1.665 +  yield undefined;
   1.666 +
   1.667 +  is(keyIndex, 5, "Saw all the expected keys");
   1.668 +
   1.669 +  ok(true, "Test group 17");
   1.670 +
   1.671 +  keyIndex = 1;
   1.672 +  keyRange = IDBKeyRange.bound("Bob", "Ron", false, true);
   1.673 +
   1.674 +  request = objectStore.index("name").openCursor(keyRange);
   1.675 +  request.onerror = errorHandler;
   1.676 +  request.onsuccess = function (event) {
   1.677 +    let cursor = event.target.result;
   1.678 +    if (cursor) {
   1.679 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.680 +         "Correct key");
   1.681 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.682 +         "Correct primary key");
   1.683 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.684 +         "Correct name");
   1.685 +      is(cursor.value.height,
   1.686 +         objectStoreDataNameSort[keyIndex].value.height,
   1.687 +         "Correct height");
   1.688 +      if ("weight" in cursor.value) {
   1.689 +        is(cursor.value.weight,
   1.690 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.691 +           "Correct weight");
   1.692 +      }
   1.693 +
   1.694 +      cursor.continue();
   1.695 +
   1.696 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.697 +         "Correct key");
   1.698 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.699 +         "Correct primary key");
   1.700 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.701 +         "Correct name");
   1.702 +      is(cursor.value.height,
   1.703 +         objectStoreDataNameSort[keyIndex].value.height,
   1.704 +         "Correct height");
   1.705 +      if ("weight" in cursor.value) {
   1.706 +        is(cursor.value.weight,
   1.707 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.708 +           "Correct weight");
   1.709 +      }
   1.710 +
   1.711 +      keyIndex++;
   1.712 +    }
   1.713 +    else {
   1.714 +      testGenerator.next();
   1.715 +    }
   1.716 +  }
   1.717 +  yield undefined;
   1.718 +
   1.719 +  is(keyIndex, 4, "Saw all the expected keys");
   1.720 +
   1.721 +  ok(true, "Test group 18");
   1.722 +
   1.723 +  keyIndex = 2;
   1.724 +  keyRange = IDBKeyRange.bound("Bob", "Ron", true, true);
   1.725 +
   1.726 +  request = objectStore.index("name").openCursor(keyRange);
   1.727 +  request.onerror = errorHandler;
   1.728 +  request.onsuccess = function (event) {
   1.729 +    let cursor = event.target.result;
   1.730 +    if (cursor) {
   1.731 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.732 +         "Correct key");
   1.733 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.734 +         "Correct primary key");
   1.735 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.736 +         "Correct name");
   1.737 +      is(cursor.value.height,
   1.738 +         objectStoreDataNameSort[keyIndex].value.height,
   1.739 +         "Correct height");
   1.740 +      if ("weight" in cursor.value) {
   1.741 +        is(cursor.value.weight,
   1.742 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.743 +           "Correct weight");
   1.744 +      }
   1.745 +
   1.746 +      cursor.continue();
   1.747 +
   1.748 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.749 +         "Correct key");
   1.750 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.751 +         "Correct primary key");
   1.752 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.753 +         "Correct name");
   1.754 +      is(cursor.value.height,
   1.755 +         objectStoreDataNameSort[keyIndex].value.height,
   1.756 +         "Correct height");
   1.757 +      if ("weight" in cursor.value) {
   1.758 +        is(cursor.value.weight,
   1.759 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.760 +           "Correct weight");
   1.761 +      }
   1.762 +
   1.763 +      keyIndex++;
   1.764 +    }
   1.765 +    else {
   1.766 +      testGenerator.next();
   1.767 +    }
   1.768 +  }
   1.769 +  yield undefined;
   1.770 +
   1.771 +  is(keyIndex, 4, "Saw all the expected keys");
   1.772 +
   1.773 +  ok(true, "Test group 19");
   1.774 +
   1.775 +  keyIndex = 4;
   1.776 +  keyRange = IDBKeyRange.bound("Bob", "Ron");
   1.777 +
   1.778 +  request = objectStore.index("name").openCursor(keyRange, "prev");
   1.779 +  request.onerror = errorHandler;
   1.780 +  request.onsuccess = function (event) {
   1.781 +    let cursor = event.target.result;
   1.782 +    if (cursor) {
   1.783 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.784 +         "Correct key");
   1.785 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.786 +         "Correct primary key");
   1.787 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.788 +         "Correct name");
   1.789 +      is(cursor.value.height,
   1.790 +         objectStoreDataNameSort[keyIndex].value.height,
   1.791 +         "Correct height");
   1.792 +      if ("weight" in cursor.value) {
   1.793 +        is(cursor.value.weight,
   1.794 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.795 +           "Correct weight");
   1.796 +      }
   1.797 +
   1.798 +      cursor.continue();
   1.799 +
   1.800 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
   1.801 +         "Correct key");
   1.802 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
   1.803 +         "Correct primary key");
   1.804 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
   1.805 +         "Correct name");
   1.806 +      is(cursor.value.height,
   1.807 +         objectStoreDataNameSort[keyIndex].value.height,
   1.808 +         "Correct height");
   1.809 +      if ("weight" in cursor.value) {
   1.810 +        is(cursor.value.weight,
   1.811 +           objectStoreDataNameSort[keyIndex].value.weight,
   1.812 +           "Correct weight");
   1.813 +      }
   1.814 +
   1.815 +      keyIndex--;
   1.816 +    }
   1.817 +    else {
   1.818 +      testGenerator.next();
   1.819 +    }
   1.820 +  }
   1.821 +  yield undefined;
   1.822 +
   1.823 +  is(keyIndex, 0, "Saw all the expected keys");
   1.824 +
   1.825 +  ok(true, "Test group 20");
   1.826 +
   1.827 +  // Test "nextunique"
   1.828 +  keyIndex = 3;
   1.829 +  keyRange = IDBKeyRange.only(65);
   1.830 +
   1.831 +  request = objectStore.index("height").openKeyCursor(keyRange, "next");
   1.832 +  request.onerror = errorHandler;
   1.833 +  request.onsuccess = function (event) {
   1.834 +    let cursor = event.target.result;
   1.835 +    if (cursor) {
   1.836 +      is(cursor.key, objectStoreDataHeightSort[keyIndex].value.height,
   1.837 +         "Correct key");
   1.838 +      is(cursor.primaryKey, objectStoreDataHeightSort[keyIndex].key,
   1.839 +         "Correct value");
   1.840 +
   1.841 +      cursor.continue();
   1.842 +      keyIndex++;
   1.843 +    }
   1.844 +    else {
   1.845 +      testGenerator.next();
   1.846 +    }
   1.847 +  }
   1.848 +  yield undefined;
   1.849 +
   1.850 +  is(keyIndex, 5, "Saw all the expected keys");
   1.851 +
   1.852 +  ok(true, "Test group 21");
   1.853 +
   1.854 +  keyIndex = 3;
   1.855 +  keyRange = IDBKeyRange.only(65);
   1.856 +
   1.857 +  request = objectStore.index("height").openKeyCursor(keyRange,
   1.858 +                                                      "nextunique");
   1.859 +  request.onerror = errorHandler;
   1.860 +  request.onsuccess = function (event) {
   1.861 +    let cursor = event.target.result;
   1.862 +    if (cursor) {
   1.863 +      is(cursor.key, objectStoreDataHeightSort[keyIndex].value.height,
   1.864 +         "Correct key");
   1.865 +      is(cursor.primaryKey, objectStoreDataHeightSort[keyIndex].key,
   1.866 +         "Correct value");
   1.867 +
   1.868 +      cursor.continue();
   1.869 +      keyIndex++;
   1.870 +    }
   1.871 +    else {
   1.872 +      testGenerator.next();
   1.873 +    }
   1.874 +  }
   1.875 +  yield undefined;
   1.876 +
   1.877 +  is(keyIndex, 4, "Saw all the expected keys");
   1.878 +
   1.879 +  ok(true, "Test group 21.5");
   1.880 +
   1.881 +  keyIndex = 5;
   1.882 +
   1.883 +  request = objectStore.index("height").openKeyCursor(null, "prev");
   1.884 +  request.onerror = errorHandler;
   1.885 +  request.onsuccess = function (event) {
   1.886 +    let cursor = event.target.result;
   1.887 +    if (cursor) {
   1.888 +      is(cursor.key, objectStoreDataHeightSort[keyIndex].value.height,
   1.889 +         "Correct key");
   1.890 +      is(cursor.primaryKey, objectStoreDataHeightSort[keyIndex].key,
   1.891 +         "Correct value");
   1.892 +
   1.893 +      cursor.continue();
   1.894 +      keyIndex--;
   1.895 +    }
   1.896 +    else {
   1.897 +      testGenerator.next();
   1.898 +    }
   1.899 +  }
   1.900 +  yield undefined;
   1.901 +
   1.902 +  is(keyIndex, -1, "Saw all the expected keys");
   1.903 +
   1.904 +  ok(true, "Test group 22");
   1.905 +
   1.906 +  keyIndex = 5;
   1.907 +
   1.908 +  request = objectStore.index("height").openKeyCursor(null,
   1.909 +                                                      "prevunique");
   1.910 +  request.onerror = errorHandler;
   1.911 +  request.onsuccess = function (event) {
   1.912 +    let cursor = event.target.result;
   1.913 +    if (cursor) {
   1.914 +      is(cursor.key, objectStoreDataHeightSort[keyIndex].value.height,
   1.915 +         "Correct key");
   1.916 +      is(cursor.primaryKey, objectStoreDataHeightSort[keyIndex].key,
   1.917 +         "Correct value");
   1.918 +
   1.919 +      cursor.continue();
   1.920 +      if (keyIndex == 5) {
   1.921 +        keyIndex--;
   1.922 +      }
   1.923 +      keyIndex--;
   1.924 +    }
   1.925 +    else {
   1.926 +      testGenerator.next();
   1.927 +    }
   1.928 +  }
   1.929 +  yield undefined;
   1.930 +
   1.931 +  is(keyIndex, -1, "Saw all the expected keys");
   1.932 +
   1.933 +  ok(true, "Test group 23");
   1.934 +
   1.935 +  keyIndex = 3;
   1.936 +  keyRange = IDBKeyRange.only(65);
   1.937 +
   1.938 +  request = objectStore.index("height").openCursor(keyRange, "next");
   1.939 +  request.onerror = errorHandler;
   1.940 +  request.onsuccess = function (event) {
   1.941 +    let cursor = event.target.result;
   1.942 +    if (cursor) {
   1.943 +      is(cursor.key, objectStoreDataHeightSort[keyIndex].value.height,
   1.944 +         "Correct key");
   1.945 +      is(cursor.primaryKey, objectStoreDataHeightSort[keyIndex].key,
   1.946 +         "Correct primary key");
   1.947 +      is(cursor.value.name, objectStoreDataHeightSort[keyIndex].value.name,
   1.948 +         "Correct name");
   1.949 +      is(cursor.value.height,
   1.950 +         objectStoreDataHeightSort[keyIndex].value.height,
   1.951 +         "Correct height");
   1.952 +      if ("weight" in cursor.value) {
   1.953 +        is(cursor.value.weight,
   1.954 +           objectStoreDataHeightSort[keyIndex].value.weight,
   1.955 +           "Correct weight");
   1.956 +      }
   1.957 +
   1.958 +      cursor.continue();
   1.959 +      keyIndex++;
   1.960 +    }
   1.961 +    else {
   1.962 +      testGenerator.next();
   1.963 +    }
   1.964 +  }
   1.965 +  yield undefined;
   1.966 +
   1.967 +  is(keyIndex, 5, "Saw all the expected keys");
   1.968 +
   1.969 +  ok(true, "Test group 24");
   1.970 +
   1.971 +  keyIndex = 3;
   1.972 +  keyRange = IDBKeyRange.only(65);
   1.973 +
   1.974 +  request = objectStore.index("height").openCursor(keyRange,
   1.975 +                                                   "nextunique");
   1.976 +  request.onerror = errorHandler;
   1.977 +  request.onsuccess = function (event) {
   1.978 +    let cursor = event.target.result;
   1.979 +    if (cursor) {
   1.980 +      is(cursor.key, objectStoreDataHeightSort[keyIndex].value.height,
   1.981 +         "Correct key");
   1.982 +      is(cursor.primaryKey, objectStoreDataHeightSort[keyIndex].key,
   1.983 +         "Correct primary key");
   1.984 +      is(cursor.value.name, objectStoreDataHeightSort[keyIndex].value.name,
   1.985 +         "Correct name");
   1.986 +      is(cursor.value.height,
   1.987 +         objectStoreDataHeightSort[keyIndex].value.height,
   1.988 +         "Correct height");
   1.989 +      if ("weight" in cursor.value) {
   1.990 +        is(cursor.value.weight,
   1.991 +           objectStoreDataHeightSort[keyIndex].value.weight,
   1.992 +           "Correct weight");
   1.993 +      }
   1.994 +
   1.995 +      cursor.continue();
   1.996 +      keyIndex++;
   1.997 +    }
   1.998 +    else {
   1.999 +      testGenerator.next();
  1.1000 +    }
  1.1001 +  }
  1.1002 +  yield undefined;
  1.1003 +
  1.1004 +  is(keyIndex, 4, "Saw all the expected keys");
  1.1005 +
  1.1006 +  ok(true, "Test group 24.5");
  1.1007 +
  1.1008 +  keyIndex = 5;
  1.1009 +
  1.1010 +  request = objectStore.index("height").openCursor(null, "prev");
  1.1011 +  request.onerror = errorHandler;
  1.1012 +  request.onsuccess = function (event) {
  1.1013 +    let cursor = event.target.result;
  1.1014 +    if (cursor) {
  1.1015 +      is(cursor.key, objectStoreDataHeightSort[keyIndex].value.height,
  1.1016 +         "Correct key");
  1.1017 +      is(cursor.primaryKey, objectStoreDataHeightSort[keyIndex].key,
  1.1018 +         "Correct primary key");
  1.1019 +      is(cursor.value.name, objectStoreDataHeightSort[keyIndex].value.name,
  1.1020 +         "Correct name");
  1.1021 +      is(cursor.value.height,
  1.1022 +         objectStoreDataHeightSort[keyIndex].value.height,
  1.1023 +         "Correct height");
  1.1024 +      if ("weight" in cursor.value) {
  1.1025 +        is(cursor.value.weight,
  1.1026 +           objectStoreDataHeightSort[keyIndex].value.weight,
  1.1027 +           "Correct weight");
  1.1028 +      }
  1.1029 +
  1.1030 +      cursor.continue();
  1.1031 +      keyIndex--;
  1.1032 +    }
  1.1033 +    else {
  1.1034 +      testGenerator.next();
  1.1035 +    }
  1.1036 +  }
  1.1037 +  yield undefined;
  1.1038 +
  1.1039 +  is(keyIndex, -1, "Saw all the expected keys");
  1.1040 +
  1.1041 +  ok(true, "Test group 25");
  1.1042 +
  1.1043 +  keyIndex = 5;
  1.1044 +
  1.1045 +  request = objectStore.index("height").openCursor(null,
  1.1046 +                                                   "prevunique");
  1.1047 +  request.onerror = errorHandler;
  1.1048 +  request.onsuccess = function (event) {
  1.1049 +    let cursor = event.target.result;
  1.1050 +    if (cursor) {
  1.1051 +      is(cursor.key, objectStoreDataHeightSort[keyIndex].value.height,
  1.1052 +         "Correct key");
  1.1053 +      is(cursor.primaryKey, objectStoreDataHeightSort[keyIndex].key,
  1.1054 +         "Correct primary key");
  1.1055 +      is(cursor.value.name, objectStoreDataHeightSort[keyIndex].value.name,
  1.1056 +         "Correct name");
  1.1057 +      is(cursor.value.height,
  1.1058 +         objectStoreDataHeightSort[keyIndex].value.height,
  1.1059 +         "Correct height");
  1.1060 +      if ("weight" in cursor.value) {
  1.1061 +        is(cursor.value.weight,
  1.1062 +           objectStoreDataHeightSort[keyIndex].value.weight,
  1.1063 +           "Correct weight");
  1.1064 +      }
  1.1065 +
  1.1066 +      cursor.continue();
  1.1067 +      if (keyIndex == 5) {
  1.1068 +        keyIndex--;
  1.1069 +      }
  1.1070 +      keyIndex--;
  1.1071 +    }
  1.1072 +    else {
  1.1073 +      testGenerator.next();
  1.1074 +    }
  1.1075 +  }
  1.1076 +  yield undefined;
  1.1077 +
  1.1078 +  is(keyIndex, -1, "Saw all the expected keys");
  1.1079 +
  1.1080 +  ok(true, "Test group 26");
  1.1081 +
  1.1082 +  keyIndex = 0;
  1.1083 +
  1.1084 +  request = objectStore.index("name").openKeyCursor();
  1.1085 +  request.onerror = errorHandler;
  1.1086 +  request.onsuccess = function (event) {
  1.1087 +    let cursor = event.target.result;
  1.1088 +    if (cursor) {
  1.1089 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
  1.1090 +         "Correct key");
  1.1091 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
  1.1092 +         "Correct value");
  1.1093 +
  1.1094 +      let nextKey = !keyIndex ? "Pat" : undefined;
  1.1095 +
  1.1096 +      cursor.continue(nextKey);
  1.1097 +
  1.1098 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
  1.1099 +         "Correct key");
  1.1100 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
  1.1101 +         "Correct value");
  1.1102 +
  1.1103 +      if (!keyIndex) {
  1.1104 +        keyIndex = 3;
  1.1105 +      }
  1.1106 +      else {
  1.1107 +        keyIndex++;
  1.1108 +      }
  1.1109 +    }
  1.1110 +    else {
  1.1111 +      testGenerator.next();
  1.1112 +    }
  1.1113 +  }
  1.1114 +  yield undefined;
  1.1115 +
  1.1116 +  is(keyIndex, objectStoreData.length, "Saw all the expected keys");
  1.1117 +
  1.1118 +  ok(true, "Test group 27");
  1.1119 +
  1.1120 +  keyIndex = 0;
  1.1121 +
  1.1122 +  request = objectStore.index("name").openKeyCursor();
  1.1123 +  request.onerror = errorHandler;
  1.1124 +  request.onsuccess = function (event) {
  1.1125 +    let cursor = event.target.result;
  1.1126 +    if (cursor) {
  1.1127 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
  1.1128 +         "Correct key");
  1.1129 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
  1.1130 +         "Correct value");
  1.1131 +
  1.1132 +      let nextKey = !keyIndex ? "Flo" : undefined;
  1.1133 +
  1.1134 +      cursor.continue(nextKey);
  1.1135 +
  1.1136 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
  1.1137 +         "Correct key");
  1.1138 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
  1.1139 +         "Correct value");
  1.1140 +
  1.1141 +      keyIndex += keyIndex ? 1 : 2;
  1.1142 +    }
  1.1143 +    else {
  1.1144 +      testGenerator.next();
  1.1145 +    }
  1.1146 +  }
  1.1147 +  yield undefined;
  1.1148 +
  1.1149 +  is(keyIndex, objectStoreData.length, "Saw all the expected keys");
  1.1150 +
  1.1151 +  ok(true, "Test group 28");
  1.1152 +
  1.1153 +  keyIndex = 0;
  1.1154 +
  1.1155 +  request = objectStore.index("name").openCursor();
  1.1156 +  request.onerror = errorHandler;
  1.1157 +  request.onsuccess = function (event) {
  1.1158 +    let cursor = event.target.result;
  1.1159 +    if (cursor) {
  1.1160 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
  1.1161 +         "Correct key");
  1.1162 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
  1.1163 +         "Correct primary key");
  1.1164 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
  1.1165 +         "Correct name");
  1.1166 +      is(cursor.value.height,
  1.1167 +         objectStoreDataNameSort[keyIndex].value.height,
  1.1168 +         "Correct height");
  1.1169 +      if ("weight" in cursor.value) {
  1.1170 +        is(cursor.value.weight,
  1.1171 +           objectStoreDataNameSort[keyIndex].value.weight,
  1.1172 +           "Correct weight");
  1.1173 +      }
  1.1174 +
  1.1175 +      let nextKey = !keyIndex ? "Pat" : undefined;
  1.1176 +
  1.1177 +      cursor.continue(nextKey);
  1.1178 +
  1.1179 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
  1.1180 +         "Correct key");
  1.1181 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
  1.1182 +         "Correct primary key");
  1.1183 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
  1.1184 +         "Correct name");
  1.1185 +      is(cursor.value.height,
  1.1186 +         objectStoreDataNameSort[keyIndex].value.height,
  1.1187 +         "Correct height");
  1.1188 +      if ("weight" in cursor.value) {
  1.1189 +        is(cursor.value.weight,
  1.1190 +           objectStoreDataNameSort[keyIndex].value.weight,
  1.1191 +           "Correct weight");
  1.1192 +      }
  1.1193 +
  1.1194 +      if (!keyIndex) {
  1.1195 +        keyIndex = 3;
  1.1196 +      }
  1.1197 +      else {
  1.1198 +        keyIndex++;
  1.1199 +      }
  1.1200 +    }
  1.1201 +    else {
  1.1202 +      testGenerator.next();
  1.1203 +    }
  1.1204 +  }
  1.1205 +  yield undefined;
  1.1206 +
  1.1207 +  is(keyIndex, objectStoreDataNameSort.length, "Saw all the expected keys");
  1.1208 +
  1.1209 +  ok(true, "Test group 29");
  1.1210 +
  1.1211 +  keyIndex = 0;
  1.1212 +
  1.1213 +  request = objectStore.index("name").openCursor();
  1.1214 +  request.onerror = errorHandler;
  1.1215 +  request.onsuccess = function (event) {
  1.1216 +    let cursor = event.target.result;
  1.1217 +    if (cursor) {
  1.1218 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
  1.1219 +         "Correct key");
  1.1220 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
  1.1221 +         "Correct primary key");
  1.1222 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
  1.1223 +         "Correct name");
  1.1224 +      is(cursor.value.height,
  1.1225 +         objectStoreDataNameSort[keyIndex].value.height,
  1.1226 +         "Correct height");
  1.1227 +      if ("weight" in cursor.value) {
  1.1228 +        is(cursor.value.weight,
  1.1229 +           objectStoreDataNameSort[keyIndex].value.weight,
  1.1230 +           "Correct weight");
  1.1231 +      }
  1.1232 +
  1.1233 +      let nextKey = !keyIndex ? "Flo" : undefined;
  1.1234 +
  1.1235 +      cursor.continue(nextKey);
  1.1236 +
  1.1237 +      is(cursor.key, objectStoreDataNameSort[keyIndex].value.name,
  1.1238 +         "Correct key");
  1.1239 +      is(cursor.primaryKey, objectStoreDataNameSort[keyIndex].key,
  1.1240 +         "Correct primary key");
  1.1241 +      is(cursor.value.name, objectStoreDataNameSort[keyIndex].value.name,
  1.1242 +         "Correct name");
  1.1243 +      is(cursor.value.height,
  1.1244 +         objectStoreDataNameSort[keyIndex].value.height,
  1.1245 +         "Correct height");
  1.1246 +      if ("weight" in cursor.value) {
  1.1247 +        is(cursor.value.weight,
  1.1248 +           objectStoreDataNameSort[keyIndex].value.weight,
  1.1249 +           "Correct weight");
  1.1250 +      }
  1.1251 +
  1.1252 +      keyIndex += keyIndex ? 1 : 2;
  1.1253 +    }
  1.1254 +    else {
  1.1255 +      testGenerator.next();
  1.1256 +    }
  1.1257 +  }
  1.1258 +  yield undefined;
  1.1259 +
  1.1260 +  is(keyIndex, objectStoreDataNameSort.length, "Saw all the expected keys");
  1.1261 +
  1.1262 +  finishTest();
  1.1263 +  yield undefined;
  1.1264 +}

mercurial