2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
6 var testGenerator = testSteps();
8 function* testSteps() {
9 const name = this.window ? window.location.pathname : "Splendid Test";
11 const objectStoreName = "People";
13 const objectStoreData = [
14 { key: "237-23-7732", value: { name: "Bob", height: 60, weight: 120 } },
15 { key: "237-23-7733", value: { name: "Ann", height: 52, weight: 110 } },
16 { key: "237-23-7734", value: { name: "Ron", height: 73, weight: 180 } },
17 { key: "237-23-7735", value: { name: "Sue", height: 58, weight: 130 } },
18 { key: "237-23-7736", value: { name: "Joe", height: 65, weight: 150 } },
19 { key: "237-23-7737", value: { name: "Pat", height: 65 } },
23 { name: "name", keyPath: "name", options: { unique: true } },
24 { name: "height", keyPath: "height", options: {} },
25 { name: "weight", keyPath: "weight", options: { unique: false } },
28 const objectStoreDataNameSort = [
29 { key: "237-23-7733", value: { name: "Ann", height: 52, weight: 110 } },
30 { key: "237-23-7732", value: { name: "Bob", height: 60, weight: 120 } },
31 { key: "237-23-7736", value: { name: "Joe", height: 65, weight: 150 } },
32 { key: "237-23-7737", value: { name: "Pat", height: 65 } },
33 { key: "237-23-7734", value: { name: "Ron", height: 73, weight: 180 } },
34 { key: "237-23-7735", value: { name: "Sue", height: 58, weight: 130 } },
37 const objectStoreDataWeightSort = [
38 { key: "237-23-7733", value: { name: "Ann", height: 52, weight: 110 } },
39 { key: "237-23-7732", value: { name: "Bob", height: 60, weight: 120 } },
40 { key: "237-23-7735", value: { name: "Sue", height: 58, weight: 130 } },
41 { key: "237-23-7736", value: { name: "Joe", height: 65, weight: 150 } },
42 { key: "237-23-7734", value: { name: "Ron", height: 73, weight: 180 } },
45 const objectStoreDataHeightSort = [
46 { key: "237-23-7733", value: { name: "Ann", height: 52, weight: 110 } },
47 { key: "237-23-7735", value: { name: "Sue", height: 58, weight: 130 } },
48 { key: "237-23-7732", value: { name: "Bob", height: 60, weight: 120 } },
49 { key: "237-23-7736", value: { name: "Joe", height: 65, weight: 150 } },
50 { key: "237-23-7737", value: { name: "Pat", height: 65 } },
51 { key: "237-23-7734", value: { name: "Ron", height: 73, weight: 180 } },
54 let request = indexedDB.open(name, 1);
55 request.onerror = errorHandler;
56 request.onupgradeneeded = grabEventAndContinueHandler;
57 request.onsuccess = grabEventAndContinueHandler;
58 let event = yield undefined;
59 let db = event.target.result;
61 let objectStore = db.createObjectStore(objectStoreName, { keyPath: null });
63 // First, add all our data to the object store.
65 for (let i in objectStoreData) {
66 request = objectStore.add(objectStoreData[i].value, objectStoreData[i].key);
67 request.onerror = errorHandler;
68 request.onsuccess = function(event) {
69 if (++addedData == objectStoreData.length) {
70 testGenerator.next(event);
74 event = yield undefined;
75 // Now create the indexes.
76 for (let i in indexData) {
77 objectStore.createIndex(
83 is(objectStore.indexNames.length, indexData.length, "Good index count");
85 objectStore = db.transaction(objectStoreName).objectStore(objectStoreName);
87 // Check global properties to make sure they are correct.
88 is(objectStore.indexNames.length, indexData.length, "Good index count");
89 for (let i in indexData) {
91 for (let j = 0; j < objectStore.indexNames.length; j++) {
92 if (objectStore.indexNames.item(j) == indexData[i].name) {
97 is(found, true, "objectStore has our index");
98 let index = objectStore.index(indexData[i].name);
99 is(index.name, indexData[i].name, "Correct name");
100 is(index.objectStore.name, objectStore.name, "Correct store name");
101 is(index.keyPath, indexData[i].keyPath, "Correct keyPath");
102 is(index.unique, !!indexData[i].options.unique, "Correct unique value");
105 request = objectStore.index("name").getKey("Bob");
106 request.onerror = errorHandler;
107 request.onsuccess = grabEventAndContinueHandler;
108 event = yield undefined;
110 is(event.target.result, "237-23-7732", "Correct key returned!");
112 request = objectStore.index("name").get("Bob");
113 request.onerror = errorHandler;
114 request.onsuccess = grabEventAndContinueHandler;
115 event = yield undefined;
117 is(event.target.result.name, "Bob", "Correct name returned!");
118 is(event.target.result.height, 60, "Correct height returned!");
119 is(event.target.result.weight, 120, "Correct weight returned!");
121 ok(true, "Test group 1");
125 request = objectStore.index("name").openKeyCursor();
126 request.onerror = errorHandler;
127 request.onsuccess = function(event) {
128 let cursor = event.target.result;
132 objectStoreDataNameSort[keyIndex].value.name,
137 objectStoreDataNameSort[keyIndex].key,
138 "Correct primary key"
140 ok(!("value" in cursor), "No value");
146 objectStoreDataNameSort[keyIndex].value.name,
151 objectStoreDataNameSort[keyIndex].key,
154 ok(!("value" in cursor), "No value");
158 testGenerator.next();
163 is(keyIndex, objectStoreData.length, "Saw all the expected keys");
165 ok(true, "Test group 2");
169 request = objectStore.index("weight").openKeyCursor(null, "next");
170 request.onerror = errorHandler;
171 request.onsuccess = function(event) {
172 let cursor = event.target.result;
176 objectStoreDataWeightSort[keyIndex].value.weight,
181 objectStoreDataWeightSort[keyIndex].key,
189 objectStoreDataWeightSort[keyIndex].value.weight,
194 objectStoreDataWeightSort[keyIndex].key,
200 testGenerator.next();
205 is(keyIndex, objectStoreData.length - 1, "Saw all the expected keys");
207 // Check that the name index enforces its unique constraint.
209 .transaction(objectStoreName, "readwrite")
210 .objectStore(objectStoreName);
211 request = objectStore.add(
212 { name: "Bob", height: 62, weight: 170 },
215 request.addEventListener("error", new ExpectError("ConstraintError", true));
216 request.onsuccess = unexpectedSuccessHandler;
217 event = yield undefined;
219 ok(true, "Test group 3");
221 keyIndex = objectStoreDataNameSort.length - 1;
223 request = objectStore.index("name").openKeyCursor(null, "prev");
224 request.onerror = errorHandler;
225 request.onsuccess = function(event) {
226 let cursor = event.target.result;
230 objectStoreDataNameSort[keyIndex].value.name,
235 objectStoreDataNameSort[keyIndex].key,
243 objectStoreDataNameSort[keyIndex].value.name,
248 objectStoreDataNameSort[keyIndex].key,
254 testGenerator.next();
259 is(keyIndex, -1, "Saw all the expected keys");
261 ok(true, "Test group 4");
264 let keyRange = IDBKeyRange.bound("Bob", "Ron");
266 request = objectStore.index("name").openKeyCursor(keyRange);
267 request.onerror = errorHandler;
268 request.onsuccess = function(event) {
269 let cursor = event.target.result;
273 objectStoreDataNameSort[keyIndex].value.name,
278 objectStoreDataNameSort[keyIndex].key,
285 testGenerator.next();
290 is(keyIndex, 5, "Saw all the expected keys");
292 ok(true, "Test group 5");
295 keyRange = IDBKeyRange.bound("Bob", "Ron", true);
297 request = objectStore.index("name").openKeyCursor(keyRange);
298 request.onerror = errorHandler;
299 request.onsuccess = function(event) {
300 let cursor = event.target.result;
304 objectStoreDataNameSort[keyIndex].value.name,
309 objectStoreDataNameSort[keyIndex].key,
316 testGenerator.next();
321 is(keyIndex, 5, "Saw all the expected keys");
323 ok(true, "Test group 6");
326 keyRange = IDBKeyRange.bound("Bob", "Ron", false, true);
328 request = objectStore.index("name").openKeyCursor(keyRange);
329 request.onerror = errorHandler;
330 request.onsuccess = function(event) {
331 let cursor = event.target.result;
335 objectStoreDataNameSort[keyIndex].value.name,
340 objectStoreDataNameSort[keyIndex].key,
347 testGenerator.next();
352 is(keyIndex, 4, "Saw all the expected keys");
354 ok(true, "Test group 7");
357 keyRange = IDBKeyRange.bound("Bob", "Ron", true, true);
359 request = objectStore.index("name").openKeyCursor(keyRange);
360 request.onerror = errorHandler;
361 request.onsuccess = function(event) {
362 let cursor = event.target.result;
366 objectStoreDataNameSort[keyIndex].value.name,
371 objectStoreDataNameSort[keyIndex].key,
378 testGenerator.next();
383 is(keyIndex, 4, "Saw all the expected keys");
385 ok(true, "Test group 8");
388 keyRange = IDBKeyRange.lowerBound("Bob");
390 request = objectStore.index("name").openKeyCursor(keyRange);
391 request.onerror = errorHandler;
392 request.onsuccess = function(event) {
393 let cursor = event.target.result;
397 objectStoreDataNameSort[keyIndex].value.name,
402 objectStoreDataNameSort[keyIndex].key,
409 testGenerator.next();
414 is(keyIndex, objectStoreDataNameSort.length, "Saw all the expected keys");
416 ok(true, "Test group 9");
419 keyRange = IDBKeyRange.lowerBound("Bob", true);
421 request = objectStore.index("name").openKeyCursor(keyRange);
422 request.onerror = errorHandler;
423 request.onsuccess = function(event) {
424 let cursor = event.target.result;
428 objectStoreDataNameSort[keyIndex].value.name,
433 objectStoreDataNameSort[keyIndex].key,
440 testGenerator.next();
445 is(keyIndex, objectStoreDataNameSort.length, "Saw all the expected keys");
447 ok(true, "Test group 10");
450 keyRange = IDBKeyRange.upperBound("Joe");
452 request = objectStore.index("name").openKeyCursor(keyRange);
453 request.onerror = errorHandler;
454 request.onsuccess = function(event) {
455 let cursor = event.target.result;
459 objectStoreDataNameSort[keyIndex].value.name,
464 objectStoreDataNameSort[keyIndex].key,
471 testGenerator.next();
476 is(keyIndex, 3, "Saw all the expected keys");
478 ok(true, "Test group 11");
481 keyRange = IDBKeyRange.upperBound("Joe", true);
483 request = objectStore.index("name").openKeyCursor(keyRange);
484 request.onerror = errorHandler;
485 request.onsuccess = function(event) {
486 let cursor = event.target.result;
490 objectStoreDataNameSort[keyIndex].value.name,
495 objectStoreDataNameSort[keyIndex].key,
502 testGenerator.next();
507 is(keyIndex, 2, "Saw all the expected keys");
509 ok(true, "Test group 12");
512 keyRange = IDBKeyRange.only("Pat");
514 request = objectStore.index("name").openKeyCursor(keyRange);
515 request.onerror = errorHandler;
516 request.onsuccess = function(event) {
517 let cursor = event.target.result;
521 objectStoreDataNameSort[keyIndex].value.name,
526 objectStoreDataNameSort[keyIndex].key,
533 testGenerator.next();
538 is(keyIndex, 4, "Saw all the expected keys");
540 ok(true, "Test group 13");
544 request = objectStore.index("name").openCursor();
545 request.onerror = errorHandler;
546 request.onsuccess = function(event) {
547 let cursor = event.target.result;
551 objectStoreDataNameSort[keyIndex].value.name,
556 objectStoreDataNameSort[keyIndex].key,
557 "Correct primary key"
561 objectStoreDataNameSort[keyIndex].value.name,
566 objectStoreDataNameSort[keyIndex].value.height,
569 if ("weight" in cursor.value) {
572 objectStoreDataNameSort[keyIndex].value.weight,
581 objectStoreDataNameSort[keyIndex].value.name,
586 objectStoreDataNameSort[keyIndex].key,
587 "Correct primary key"
591 objectStoreDataNameSort[keyIndex].value.name,
596 objectStoreDataNameSort[keyIndex].value.height,
599 if ("weight" in cursor.value) {
602 objectStoreDataNameSort[keyIndex].value.weight,
609 testGenerator.next();
614 is(keyIndex, objectStoreDataNameSort.length, "Saw all the expected keys");
616 ok(true, "Test group 14");
618 keyIndex = objectStoreDataNameSort.length - 1;
620 request = objectStore.index("name").openCursor(null, "prev");
621 request.onerror = errorHandler;
622 request.onsuccess = function(event) {
623 let cursor = event.target.result;
627 objectStoreDataNameSort[keyIndex].value.name,
632 objectStoreDataNameSort[keyIndex].key,
633 "Correct primary key"
637 objectStoreDataNameSort[keyIndex].value.name,
642 objectStoreDataNameSort[keyIndex].value.height,
645 if ("weight" in cursor.value) {
648 objectStoreDataNameSort[keyIndex].value.weight,
657 objectStoreDataNameSort[keyIndex].value.name,
662 objectStoreDataNameSort[keyIndex].key,
663 "Correct primary key"
667 objectStoreDataNameSort[keyIndex].value.name,
672 objectStoreDataNameSort[keyIndex].value.height,
675 if ("weight" in cursor.value) {
678 objectStoreDataNameSort[keyIndex].value.weight,
685 testGenerator.next();
690 is(keyIndex, -1, "Saw all the expected keys");
692 ok(true, "Test group 15");
695 keyRange = IDBKeyRange.bound("Bob", "Ron");
697 request = objectStore.index("name").openCursor(keyRange);
698 request.onerror = errorHandler;
699 request.onsuccess = function(event) {
700 let cursor = event.target.result;
704 objectStoreDataNameSort[keyIndex].value.name,
709 objectStoreDataNameSort[keyIndex].key,
710 "Correct primary key"
714 objectStoreDataNameSort[keyIndex].value.name,
719 objectStoreDataNameSort[keyIndex].value.height,
722 if ("weight" in cursor.value) {
725 objectStoreDataNameSort[keyIndex].value.weight,
734 objectStoreDataNameSort[keyIndex].value.name,
739 objectStoreDataNameSort[keyIndex].key,
740 "Correct primary key"
744 objectStoreDataNameSort[keyIndex].value.name,
749 objectStoreDataNameSort[keyIndex].value.height,
752 if ("weight" in cursor.value) {
755 objectStoreDataNameSort[keyIndex].value.weight,
762 testGenerator.next();
767 is(keyIndex, 5, "Saw all the expected keys");
769 ok(true, "Test group 16");
772 keyRange = IDBKeyRange.bound("Bob", "Ron", true);
774 request = objectStore.index("name").openCursor(keyRange);
775 request.onerror = errorHandler;
776 request.onsuccess = function(event) {
777 let cursor = event.target.result;
781 objectStoreDataNameSort[keyIndex].value.name,
786 objectStoreDataNameSort[keyIndex].key,
787 "Correct primary key"
791 objectStoreDataNameSort[keyIndex].value.name,
796 objectStoreDataNameSort[keyIndex].value.height,
799 if ("weight" in cursor.value) {
802 objectStoreDataNameSort[keyIndex].value.weight,
811 objectStoreDataNameSort[keyIndex].value.name,
816 objectStoreDataNameSort[keyIndex].key,
817 "Correct primary key"
821 objectStoreDataNameSort[keyIndex].value.name,
826 objectStoreDataNameSort[keyIndex].value.height,
829 if ("weight" in cursor.value) {
832 objectStoreDataNameSort[keyIndex].value.weight,
839 testGenerator.next();
844 is(keyIndex, 5, "Saw all the expected keys");
846 ok(true, "Test group 17");
849 keyRange = IDBKeyRange.bound("Bob", "Ron", false, true);
851 request = objectStore.index("name").openCursor(keyRange);
852 request.onerror = errorHandler;
853 request.onsuccess = function(event) {
854 let cursor = event.target.result;
858 objectStoreDataNameSort[keyIndex].value.name,
863 objectStoreDataNameSort[keyIndex].key,
864 "Correct primary key"
868 objectStoreDataNameSort[keyIndex].value.name,
873 objectStoreDataNameSort[keyIndex].value.height,
876 if ("weight" in cursor.value) {
879 objectStoreDataNameSort[keyIndex].value.weight,
888 objectStoreDataNameSort[keyIndex].value.name,
893 objectStoreDataNameSort[keyIndex].key,
894 "Correct primary key"
898 objectStoreDataNameSort[keyIndex].value.name,
903 objectStoreDataNameSort[keyIndex].value.height,
906 if ("weight" in cursor.value) {
909 objectStoreDataNameSort[keyIndex].value.weight,
916 testGenerator.next();
921 is(keyIndex, 4, "Saw all the expected keys");
923 ok(true, "Test group 18");
926 keyRange = IDBKeyRange.bound("Bob", "Ron", true, true);
928 request = objectStore.index("name").openCursor(keyRange);
929 request.onerror = errorHandler;
930 request.onsuccess = function(event) {
931 let cursor = event.target.result;
935 objectStoreDataNameSort[keyIndex].value.name,
940 objectStoreDataNameSort[keyIndex].key,
941 "Correct primary key"
945 objectStoreDataNameSort[keyIndex].value.name,
950 objectStoreDataNameSort[keyIndex].value.height,
953 if ("weight" in cursor.value) {
956 objectStoreDataNameSort[keyIndex].value.weight,
965 objectStoreDataNameSort[keyIndex].value.name,
970 objectStoreDataNameSort[keyIndex].key,
971 "Correct primary key"
975 objectStoreDataNameSort[keyIndex].value.name,
980 objectStoreDataNameSort[keyIndex].value.height,
983 if ("weight" in cursor.value) {
986 objectStoreDataNameSort[keyIndex].value.weight,
993 testGenerator.next();
998 is(keyIndex, 4, "Saw all the expected keys");
1000 ok(true, "Test group 19");
1003 keyRange = IDBKeyRange.bound("Bob", "Ron");
1005 request = objectStore.index("name").openCursor(keyRange, "prev");
1006 request.onerror = errorHandler;
1007 request.onsuccess = function(event) {
1008 let cursor = event.target.result;
1012 objectStoreDataNameSort[keyIndex].value.name,
1017 objectStoreDataNameSort[keyIndex].key,
1018 "Correct primary key"
1022 objectStoreDataNameSort[keyIndex].value.name,
1026 cursor.value.height,
1027 objectStoreDataNameSort[keyIndex].value.height,
1030 if ("weight" in cursor.value) {
1032 cursor.value.weight,
1033 objectStoreDataNameSort[keyIndex].value.weight,
1042 objectStoreDataNameSort[keyIndex].value.name,
1047 objectStoreDataNameSort[keyIndex].key,
1048 "Correct primary key"
1052 objectStoreDataNameSort[keyIndex].value.name,
1056 cursor.value.height,
1057 objectStoreDataNameSort[keyIndex].value.height,
1060 if ("weight" in cursor.value) {
1062 cursor.value.weight,
1063 objectStoreDataNameSort[keyIndex].value.weight,
1070 testGenerator.next();
1075 is(keyIndex, 0, "Saw all the expected keys");
1077 ok(true, "Test group 20");
1079 // Test "nextunique"
1081 keyRange = IDBKeyRange.only(65);
1083 request = objectStore.index("height").openKeyCursor(keyRange, "next");
1084 request.onerror = errorHandler;
1085 request.onsuccess = function(event) {
1086 let cursor = event.target.result;
1090 objectStoreDataHeightSort[keyIndex].value.height,
1095 objectStoreDataHeightSort[keyIndex].key,
1102 testGenerator.next();
1107 is(keyIndex, 5, "Saw all the expected keys");
1109 ok(true, "Test group 21");
1112 keyRange = IDBKeyRange.only(65);
1114 request = objectStore.index("height").openKeyCursor(keyRange, "nextunique");
1115 request.onerror = errorHandler;
1116 request.onsuccess = function(event) {
1117 let cursor = event.target.result;
1121 objectStoreDataHeightSort[keyIndex].value.height,
1126 objectStoreDataHeightSort[keyIndex].key,
1133 testGenerator.next();
1138 is(keyIndex, 4, "Saw all the expected keys");
1140 ok(true, "Test group 21.5");
1144 request = objectStore.index("height").openKeyCursor(null, "prev");
1145 request.onerror = errorHandler;
1146 request.onsuccess = function(event) {
1147 let cursor = event.target.result;
1151 objectStoreDataHeightSort[keyIndex].value.height,
1156 objectStoreDataHeightSort[keyIndex].key,
1163 testGenerator.next();
1168 is(keyIndex, -1, "Saw all the expected keys");
1170 ok(true, "Test group 22");
1174 request = objectStore.index("height").openKeyCursor(null, "prevunique");
1175 request.onerror = errorHandler;
1176 request.onsuccess = function(event) {
1177 let cursor = event.target.result;
1181 objectStoreDataHeightSort[keyIndex].value.height,
1186 objectStoreDataHeightSort[keyIndex].key,
1191 if (keyIndex == 5) {
1196 testGenerator.next();
1201 is(keyIndex, -1, "Saw all the expected keys");
1203 ok(true, "Test group 23");
1206 keyRange = IDBKeyRange.only(65);
1208 request = objectStore.index("height").openCursor(keyRange, "next");
1209 request.onerror = errorHandler;
1210 request.onsuccess = function(event) {
1211 let cursor = event.target.result;
1215 objectStoreDataHeightSort[keyIndex].value.height,
1220 objectStoreDataHeightSort[keyIndex].key,
1221 "Correct primary key"
1225 objectStoreDataHeightSort[keyIndex].value.name,
1229 cursor.value.height,
1230 objectStoreDataHeightSort[keyIndex].value.height,
1233 if ("weight" in cursor.value) {
1235 cursor.value.weight,
1236 objectStoreDataHeightSort[keyIndex].value.weight,
1244 testGenerator.next();
1249 is(keyIndex, 5, "Saw all the expected keys");
1251 ok(true, "Test group 24");
1254 keyRange = IDBKeyRange.only(65);
1256 request = objectStore.index("height").openCursor(keyRange, "nextunique");
1257 request.onerror = errorHandler;
1258 request.onsuccess = function(event) {
1259 let cursor = event.target.result;
1263 objectStoreDataHeightSort[keyIndex].value.height,
1268 objectStoreDataHeightSort[keyIndex].key,
1269 "Correct primary key"
1273 objectStoreDataHeightSort[keyIndex].value.name,
1277 cursor.value.height,
1278 objectStoreDataHeightSort[keyIndex].value.height,
1281 if ("weight" in cursor.value) {
1283 cursor.value.weight,
1284 objectStoreDataHeightSort[keyIndex].value.weight,
1292 testGenerator.next();
1297 is(keyIndex, 4, "Saw all the expected keys");
1299 ok(true, "Test group 24.5");
1303 request = objectStore.index("height").openCursor(null, "prev");
1304 request.onerror = errorHandler;
1305 request.onsuccess = function(event) {
1306 let cursor = event.target.result;
1310 objectStoreDataHeightSort[keyIndex].value.height,
1315 objectStoreDataHeightSort[keyIndex].key,
1316 "Correct primary key"
1320 objectStoreDataHeightSort[keyIndex].value.name,
1324 cursor.value.height,
1325 objectStoreDataHeightSort[keyIndex].value.height,
1328 if ("weight" in cursor.value) {
1330 cursor.value.weight,
1331 objectStoreDataHeightSort[keyIndex].value.weight,
1339 testGenerator.next();
1344 is(keyIndex, -1, "Saw all the expected keys");
1346 ok(true, "Test group 25");
1350 request = objectStore.index("height").openCursor(null, "prevunique");
1351 request.onerror = errorHandler;
1352 request.onsuccess = function(event) {
1353 let cursor = event.target.result;
1357 objectStoreDataHeightSort[keyIndex].value.height,
1362 objectStoreDataHeightSort[keyIndex].key,
1363 "Correct primary key"
1367 objectStoreDataHeightSort[keyIndex].value.name,
1371 cursor.value.height,
1372 objectStoreDataHeightSort[keyIndex].value.height,
1375 if ("weight" in cursor.value) {
1377 cursor.value.weight,
1378 objectStoreDataHeightSort[keyIndex].value.weight,
1384 if (keyIndex == 5) {
1389 testGenerator.next();
1394 is(keyIndex, -1, "Saw all the expected keys");
1396 ok(true, "Test group 26");
1400 request = objectStore.index("name").openKeyCursor();
1401 request.onerror = errorHandler;
1402 request.onsuccess = function(event) {
1403 let cursor = event.target.result;
1407 objectStoreDataNameSort[keyIndex].value.name,
1412 objectStoreDataNameSort[keyIndex].key,
1416 let nextKey = !keyIndex ? "Pat" : undefined;
1418 cursor.continue(nextKey);
1422 objectStoreDataNameSort[keyIndex].value.name,
1427 objectStoreDataNameSort[keyIndex].key,
1437 testGenerator.next();
1442 is(keyIndex, objectStoreData.length, "Saw all the expected keys");
1444 ok(true, "Test group 27");
1448 request = objectStore.index("name").openKeyCursor();
1449 request.onerror = errorHandler;
1450 request.onsuccess = function(event) {
1451 let cursor = event.target.result;
1455 objectStoreDataNameSort[keyIndex].value.name,
1460 objectStoreDataNameSort[keyIndex].key,
1464 let nextKey = !keyIndex ? "Flo" : undefined;
1466 cursor.continue(nextKey);
1470 objectStoreDataNameSort[keyIndex].value.name,
1475 objectStoreDataNameSort[keyIndex].key,
1479 keyIndex += keyIndex ? 1 : 2;
1481 testGenerator.next();
1486 is(keyIndex, objectStoreData.length, "Saw all the expected keys");
1488 ok(true, "Test group 28");
1492 request = objectStore.index("name").openCursor();
1493 request.onerror = errorHandler;
1494 request.onsuccess = function(event) {
1495 let cursor = event.target.result;
1499 objectStoreDataNameSort[keyIndex].value.name,
1504 objectStoreDataNameSort[keyIndex].key,
1505 "Correct primary key"
1509 objectStoreDataNameSort[keyIndex].value.name,
1513 cursor.value.height,
1514 objectStoreDataNameSort[keyIndex].value.height,
1517 if ("weight" in cursor.value) {
1519 cursor.value.weight,
1520 objectStoreDataNameSort[keyIndex].value.weight,
1525 let nextKey = !keyIndex ? "Pat" : undefined;
1527 cursor.continue(nextKey);
1531 objectStoreDataNameSort[keyIndex].value.name,
1536 objectStoreDataNameSort[keyIndex].key,
1537 "Correct primary key"
1541 objectStoreDataNameSort[keyIndex].value.name,
1545 cursor.value.height,
1546 objectStoreDataNameSort[keyIndex].value.height,
1549 if ("weight" in cursor.value) {
1551 cursor.value.weight,
1552 objectStoreDataNameSort[keyIndex].value.weight,
1563 testGenerator.next();
1568 is(keyIndex, objectStoreDataNameSort.length, "Saw all the expected keys");
1570 ok(true, "Test group 29");
1574 request = objectStore.index("name").openCursor();
1575 request.onerror = errorHandler;
1576 request.onsuccess = function(event) {
1577 let cursor = event.target.result;
1581 objectStoreDataNameSort[keyIndex].value.name,
1586 objectStoreDataNameSort[keyIndex].key,
1587 "Correct primary key"
1591 objectStoreDataNameSort[keyIndex].value.name,
1595 cursor.value.height,
1596 objectStoreDataNameSort[keyIndex].value.height,
1599 if ("weight" in cursor.value) {
1601 cursor.value.weight,
1602 objectStoreDataNameSort[keyIndex].value.weight,
1607 let nextKey = !keyIndex ? "Flo" : undefined;
1609 cursor.continue(nextKey);
1613 objectStoreDataNameSort[keyIndex].value.name,
1618 objectStoreDataNameSort[keyIndex].key,
1619 "Correct primary key"
1623 objectStoreDataNameSort[keyIndex].value.name,
1627 cursor.value.height,
1628 objectStoreDataNameSort[keyIndex].value.height,
1631 if ("weight" in cursor.value) {
1633 cursor.value.weight,
1634 objectStoreDataNameSort[keyIndex].value.weight,
1639 keyIndex += keyIndex ? 1 : 2;
1641 testGenerator.next();
1646 is(keyIndex, objectStoreDataNameSort.length, "Saw all the expected keys");