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 osName = "people";
10 const indexName = "weight";
13 { ssn: "237-23-7732", name: "Bob", height: 60, weight: 120 },
14 { ssn: "237-23-7733", name: "Ann", height: 52, weight: 110 },
15 { ssn: "237-23-7734", name: "Ron", height: 73, weight: 180 },
16 { ssn: "237-23-7735", name: "Sue", height: 58, weight: 130 },
17 { ssn: "237-23-7736", name: "Joe", height: 65, weight: 150 },
18 { ssn: "237-23-7737", name: "Pat", height: 65 },
19 { ssn: "237-23-7738", name: "Mel", height: 66, weight: {} },
20 { ssn: "237-23-7739", name: "Tom", height: 62, weight: 130 },
23 const weightSort = [1, 0, 3, 7, 4, 2];
25 let request = indexedDB.open(
26 this.window ? window.location.pathname : "Splendid Test",
29 request.onerror = errorHandler;
30 request.onupgradeneeded = grabEventAndContinueHandler;
31 request.onsuccess = grabEventAndContinueHandler;
32 let event = yield undefined;
34 is(event.type, "upgradeneeded", "Got upgradeneeded event");
36 let db = event.target.result;
37 db.onerror = errorHandler;
39 let objectStore = db.createObjectStore(osName, { keyPath: "ssn" });
40 objectStore.createIndex(indexName, "weight", { unique: false });
46 event = yield undefined;
48 is(event.type, "success", "Got success event");
51 IDBKeyRange.bound(1, -1);
52 ok(false, "Bound keyRange with backwards args should throw!");
54 is(e.name, "DataError", "Threw correct exception");
55 is(e.code, 0, "Threw with correct code");
59 IDBKeyRange.bound(1, 1);
60 ok(true, "Bound keyRange with same arg should be ok");
62 ok(false, "Bound keyRange with same arg should have been ok");
66 IDBKeyRange.bound(1, 1, true);
67 ok(false, "Bound keyRange with same arg and open should throw!");
69 is(e.name, "DataError", "Threw correct exception");
70 is(e.code, 0, "Threw with correct code");
74 IDBKeyRange.bound(1, 1, true, true);
75 ok(false, "Bound keyRange with same arg and open should throw!");
77 is(e.name, "DataError", "Threw correct exception");
78 is(e.code, 0, "Threw with correct code");
81 objectStore = db.transaction(osName).objectStore(osName);
85 ok(false, "Get with unspecified arg should have thrown");
87 ok(true, "Get with unspecified arg should have thrown");
91 objectStore.get(undefined);
92 ok(false, "Get with undefined should have thrown");
94 ok(true, "Get with undefined arg should have thrown");
98 objectStore.get(null);
99 ok(false, "Get with null should have thrown");
101 is(e instanceof DOMException, true, "Got right kind of exception");
102 is(e.name, "DataError", "Correct error.");
103 is(e.code, 0, "Correct code.");
106 objectStore.get(data[2].ssn).onsuccess = grabEventAndContinueHandler;
107 event = yield undefined;
109 is(event.target.result.name, data[2].name, "Correct data");
111 let keyRange = IDBKeyRange.only(data[2].ssn);
113 objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
114 event = yield undefined;
116 is(event.target.result.name, data[2].name, "Correct data");
118 keyRange = IDBKeyRange.lowerBound(data[2].ssn);
120 objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
121 event = yield undefined;
123 is(event.target.result.name, data[2].name, "Correct data");
125 keyRange = IDBKeyRange.lowerBound(data[2].ssn, true);
127 objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
128 event = yield undefined;
130 is(event.target.result.name, data[3].name, "Correct data");
132 keyRange = IDBKeyRange.upperBound(data[2].ssn);
134 objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
135 event = yield undefined;
137 is(event.target.result.name, data[0].name, "Correct data");
139 keyRange = IDBKeyRange.bound(data[2].ssn, data[4].ssn);
141 objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
142 event = yield undefined;
144 is(event.target.result.name, data[2].name, "Correct data");
146 keyRange = IDBKeyRange.bound(data[2].ssn, data[4].ssn, true);
148 objectStore.get(keyRange).onsuccess = grabEventAndContinueHandler;
149 event = yield undefined;
151 is(event.target.result.name, data[3].name, "Correct data");
153 objectStore = db.transaction(osName, "readwrite").objectStore(osName);
156 objectStore.delete();
157 ok(false, "Delete with unspecified arg should have thrown");
159 ok(true, "Delete with unspecified arg should have thrown");
163 objectStore.delete(undefined);
164 ok(false, "Delete with undefined should have thrown");
166 ok(true, "Delete with undefined arg should have thrown");
170 objectStore.delete(null);
171 ok(false, "Delete with null should have thrown");
173 is(e instanceof DOMException, true, "Got right kind of exception");
174 is(e.name, "DataError", "Correct error.");
175 is(e.code, 0, "Correct code.");
178 objectStore.count().onsuccess = grabEventAndContinueHandler;
179 event = yield undefined;
181 is(event.target.result, data.length, "Correct count");
183 objectStore.delete(data[2].ssn).onsuccess = grabEventAndContinueHandler;
184 event = yield undefined;
186 ok(event.target.result === undefined, "Correct result");
188 objectStore.count().onsuccess = grabEventAndContinueHandler;
189 event = yield undefined;
191 is(event.target.result, data.length - 1, "Correct count");
193 keyRange = IDBKeyRange.bound(data[3].ssn, data[5].ssn);
195 objectStore.delete(keyRange).onsuccess = grabEventAndContinueHandler;
196 event = yield undefined;
198 ok(event.target.result === undefined, "Correct result");
200 objectStore.count().onsuccess = grabEventAndContinueHandler;
201 event = yield undefined;
203 is(event.target.result, data.length - 4, "Correct count");
205 keyRange = IDBKeyRange.lowerBound(10);
207 objectStore.delete(keyRange).onsuccess = grabEventAndContinueHandler;
208 event = yield undefined;
210 ok(event.target.result === undefined, "Correct result");
212 objectStore.count().onsuccess = grabEventAndContinueHandler;
213 event = yield undefined;
215 is(event.target.result, 0, "Correct count");
217 event.target.transaction.oncomplete = grabEventAndContinueHandler;
219 for (let i of data) {
225 objectStore = db.transaction(osName).objectStore(osName);
227 objectStore.count().onsuccess = grabEventAndContinueHandler;
228 event = yield undefined;
230 is(event.target.result, data.length, "Correct count");
234 objectStore.openCursor().onsuccess = function(event) {
235 let cursor = event.target.result;
240 testGenerator.next();
245 is(count, data.length, "Correct count for no arg to openCursor");
249 objectStore.openCursor(null).onsuccess = function(event) {
250 let cursor = event.target.result;
255 testGenerator.next();
260 is(count, data.length, "Correct count for null arg to openCursor");
264 objectStore.openCursor(undefined).onsuccess = function(event) {
265 let cursor = event.target.result;
270 testGenerator.next();
275 is(count, data.length, "Correct count for undefined arg to openCursor");
279 objectStore.openCursor(data[2].ssn).onsuccess = function(event) {
280 let cursor = event.target.result;
285 testGenerator.next();
290 is(count, 1, "Correct count for single key arg to openCursor");
294 objectStore.openCursor("foo").onsuccess = function(event) {
295 let cursor = event.target.result;
300 testGenerator.next();
305 is(count, 0, "Correct count for non-existent single key arg to openCursor");
308 keyRange = IDBKeyRange.only(data[2].ssn);
310 objectStore.openCursor(keyRange).onsuccess = function(event) {
311 let cursor = event.target.result;
316 testGenerator.next();
321 is(count, 1, "Correct count for only keyRange arg to openCursor");
324 keyRange = IDBKeyRange.lowerBound(data[2].ssn);
326 objectStore.openCursor(keyRange).onsuccess = function(event) {
327 let cursor = event.target.result;
332 testGenerator.next();
337 is(count, data.length - 2, "Correct count for lowerBound arg to openCursor");
340 keyRange = IDBKeyRange.lowerBound(data[2].ssn, true);
342 objectStore.openCursor(keyRange).onsuccess = function(event) {
343 let cursor = event.target.result;
348 testGenerator.next();
353 is(count, data.length - 3, "Correct count for lowerBound arg to openCursor");
356 keyRange = IDBKeyRange.lowerBound("foo");
358 objectStore.openCursor(keyRange).onsuccess = function(event) {
359 let cursor = event.target.result;
364 testGenerator.next();
369 is(count, 0, "Correct count for non-existent lowerBound arg to openCursor");
372 keyRange = IDBKeyRange.bound(data[2].ssn, data[3].ssn);
374 objectStore.openCursor(keyRange).onsuccess = function(event) {
375 let cursor = event.target.result;
380 testGenerator.next();
385 is(count, 2, "Correct count for bound arg to openCursor");
388 keyRange = IDBKeyRange.bound(data[2].ssn, data[3].ssn, true);
390 objectStore.openCursor(keyRange).onsuccess = function(event) {
391 let cursor = event.target.result;
396 testGenerator.next();
401 is(count, 1, "Correct count for bound arg to openCursor");
404 keyRange = IDBKeyRange.bound(data[2].ssn, data[3].ssn, true, true);
406 objectStore.openCursor(keyRange).onsuccess = function(event) {
407 let cursor = event.target.result;
412 testGenerator.next();
417 is(count, 0, "Correct count for bound arg to openCursor");
419 let index = objectStore.index(indexName);
423 index.openKeyCursor().onsuccess = function(event) {
424 let cursor = event.target.result;
429 testGenerator.next();
437 "Correct count for unspecified arg to index.openKeyCursor"
442 index.openKeyCursor(null).onsuccess = function(event) {
443 let cursor = event.target.result;
448 testGenerator.next();
456 "Correct count for null arg to index.openKeyCursor"
461 index.openKeyCursor(undefined).onsuccess = function(event) {
462 let cursor = event.target.result;
467 testGenerator.next();
475 "Correct count for undefined arg to index.openKeyCursor"
480 index.openKeyCursor(data[0].weight).onsuccess = function(event) {
481 let cursor = event.target.result;
486 testGenerator.next();
491 is(count, 1, "Correct count for single key arg to index.openKeyCursor");
495 index.openKeyCursor("foo").onsuccess = function(event) {
496 let cursor = event.target.result;
501 testGenerator.next();
506 is(count, 0, "Correct count for non-existent key arg to index.openKeyCursor");
509 keyRange = IDBKeyRange.only("foo");
511 index.openKeyCursor(keyRange).onsuccess = function(event) {
512 let cursor = event.target.result;
517 testGenerator.next();
525 "Correct count for non-existent keyRange arg to index.openKeyCursor"
529 keyRange = IDBKeyRange.only(data[0].weight);
531 index.openKeyCursor(keyRange).onsuccess = function(event) {
532 let cursor = event.target.result;
537 testGenerator.next();
542 is(count, 1, "Correct count for only keyRange arg to index.openKeyCursor");
545 keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
547 index.openKeyCursor(keyRange).onsuccess = function(event) {
548 let cursor = event.target.result;
553 testGenerator.next();
561 "Correct count for lowerBound keyRange arg to index.openKeyCursor"
565 keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
567 index.openKeyCursor(keyRange).onsuccess = function(event) {
568 let cursor = event.target.result;
573 testGenerator.next();
580 weightSort.length - 1,
581 "Correct count for lowerBound keyRange arg to index.openKeyCursor"
585 keyRange = IDBKeyRange.lowerBound("foo");
587 index.openKeyCursor(keyRange).onsuccess = function(event) {
588 let cursor = event.target.result;
593 testGenerator.next();
601 "Correct count for lowerBound keyRange arg to index.openKeyCursor"
605 keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight);
607 index.openKeyCursor(keyRange).onsuccess = function(event) {
608 let cursor = event.target.result;
613 testGenerator.next();
621 "Correct count for upperBound keyRange arg to index.openKeyCursor"
625 keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
627 index.openKeyCursor(keyRange).onsuccess = function(event) {
628 let cursor = event.target.result;
633 testGenerator.next();
641 "Correct count for upperBound keyRange arg to index.openKeyCursor"
645 keyRange = IDBKeyRange.upperBound(
646 data[weightSort[weightSort.length - 1]].weight
649 index.openKeyCursor(keyRange).onsuccess = function(event) {
650 let cursor = event.target.result;
655 testGenerator.next();
663 "Correct count for upperBound keyRange arg to index.openKeyCursor"
667 keyRange = IDBKeyRange.upperBound(
668 data[weightSort[weightSort.length - 1]].weight,
672 index.openKeyCursor(keyRange).onsuccess = function(event) {
673 let cursor = event.target.result;
678 testGenerator.next();
685 weightSort.length - 1,
686 "Correct count for upperBound keyRange arg to index.openKeyCursor"
690 keyRange = IDBKeyRange.upperBound("foo");
692 index.openKeyCursor(keyRange).onsuccess = function(event) {
693 let cursor = event.target.result;
698 testGenerator.next();
706 "Correct count for upperBound keyRange arg to index.openKeyCursor"
710 keyRange = IDBKeyRange.upperBound(0);
712 index.openKeyCursor(keyRange).onsuccess = function(event) {
713 let cursor = event.target.result;
718 testGenerator.next();
726 "Correct count for upperBound keyRange arg to index.openKeyCursor"
730 keyRange = IDBKeyRange.bound(
731 data[weightSort[0]].weight,
732 data[weightSort[weightSort.length - 1]].weight
735 index.openKeyCursor(keyRange).onsuccess = function(event) {
736 let cursor = event.target.result;
741 testGenerator.next();
749 "Correct count for bound keyRange arg to index.openKeyCursor"
753 keyRange = IDBKeyRange.bound(
754 data[weightSort[0]].weight,
755 data[weightSort[weightSort.length - 1]].weight,
759 index.openKeyCursor(keyRange).onsuccess = function(event) {
760 let cursor = event.target.result;
765 testGenerator.next();
772 weightSort.length - 1,
773 "Correct count for bound keyRange arg to index.openKeyCursor"
777 keyRange = IDBKeyRange.bound(
778 data[weightSort[0]].weight,
779 data[weightSort[weightSort.length - 1]].weight,
784 index.openKeyCursor(keyRange).onsuccess = function(event) {
785 let cursor = event.target.result;
790 testGenerator.next();
797 weightSort.length - 2,
798 "Correct count for bound keyRange arg to index.openKeyCursor"
802 keyRange = IDBKeyRange.bound(
803 data[weightSort[0]].weight - 1,
804 data[weightSort[weightSort.length - 1]].weight + 1
807 index.openKeyCursor(keyRange).onsuccess = function(event) {
808 let cursor = event.target.result;
813 testGenerator.next();
821 "Correct count for bound keyRange arg to index.openKeyCursor"
825 keyRange = IDBKeyRange.bound(
826 data[weightSort[0]].weight - 2,
827 data[weightSort[0]].weight - 1
830 index.openKeyCursor(keyRange).onsuccess = function(event) {
831 let cursor = event.target.result;
836 testGenerator.next();
841 is(count, 0, "Correct count for bound keyRange arg to index.openKeyCursor");
844 keyRange = IDBKeyRange.bound(
845 data[weightSort[1]].weight,
846 data[weightSort[2]].weight
849 index.openKeyCursor(keyRange).onsuccess = function(event) {
850 let cursor = event.target.result;
855 testGenerator.next();
860 is(count, 3, "Correct count for bound keyRange arg to index.openKeyCursor");
864 index.openCursor().onsuccess = function(event) {
865 let cursor = event.target.result;
870 testGenerator.next();
878 "Correct count for unspecified arg to index.openCursor"
883 index.openCursor(null).onsuccess = function(event) {
884 let cursor = event.target.result;
889 testGenerator.next();
897 "Correct count for null arg to index.openCursor"
902 index.openCursor(undefined).onsuccess = function(event) {
903 let cursor = event.target.result;
908 testGenerator.next();
916 "Correct count for undefined arg to index.openCursor"
921 index.openCursor(data[0].weight).onsuccess = function(event) {
922 let cursor = event.target.result;
927 testGenerator.next();
932 is(count, 1, "Correct count for single key arg to index.openCursor");
936 index.openCursor("foo").onsuccess = function(event) {
937 let cursor = event.target.result;
942 testGenerator.next();
947 is(count, 0, "Correct count for non-existent key arg to index.openCursor");
950 keyRange = IDBKeyRange.only("foo");
952 index.openCursor(keyRange).onsuccess = function(event) {
953 let cursor = event.target.result;
958 testGenerator.next();
966 "Correct count for non-existent keyRange arg to index.openCursor"
970 keyRange = IDBKeyRange.only(data[0].weight);
972 index.openCursor(keyRange).onsuccess = function(event) {
973 let cursor = event.target.result;
978 testGenerator.next();
983 is(count, 1, "Correct count for only keyRange arg to index.openCursor");
986 keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
988 index.openCursor(keyRange).onsuccess = function(event) {
989 let cursor = event.target.result;
994 testGenerator.next();
1002 "Correct count for lowerBound keyRange arg to index.openCursor"
1006 keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
1008 index.openCursor(keyRange).onsuccess = function(event) {
1009 let cursor = event.target.result;
1014 testGenerator.next();
1021 weightSort.length - 1,
1022 "Correct count for lowerBound keyRange arg to index.openCursor"
1026 keyRange = IDBKeyRange.lowerBound("foo");
1028 index.openCursor(keyRange).onsuccess = function(event) {
1029 let cursor = event.target.result;
1034 testGenerator.next();
1039 is(count, 0, "Correct count for lowerBound keyRange arg to index.openCursor");
1042 keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight);
1044 index.openCursor(keyRange).onsuccess = function(event) {
1045 let cursor = event.target.result;
1050 testGenerator.next();
1055 is(count, 1, "Correct count for upperBound keyRange arg to index.openCursor");
1058 keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
1060 index.openCursor(keyRange).onsuccess = function(event) {
1061 let cursor = event.target.result;
1066 testGenerator.next();
1071 is(count, 0, "Correct count for upperBound keyRange arg to index.openCursor");
1074 keyRange = IDBKeyRange.upperBound(
1075 data[weightSort[weightSort.length - 1]].weight
1078 index.openCursor(keyRange).onsuccess = function(event) {
1079 let cursor = event.target.result;
1084 testGenerator.next();
1092 "Correct count for upperBound keyRange arg to index.openCursor"
1096 keyRange = IDBKeyRange.upperBound(
1097 data[weightSort[weightSort.length - 1]].weight,
1101 index.openCursor(keyRange).onsuccess = function(event) {
1102 let cursor = event.target.result;
1107 testGenerator.next();
1114 weightSort.length - 1,
1115 "Correct count for upperBound keyRange arg to index.openCursor"
1119 keyRange = IDBKeyRange.upperBound("foo");
1121 index.openCursor(keyRange).onsuccess = function(event) {
1122 let cursor = event.target.result;
1127 testGenerator.next();
1135 "Correct count for upperBound keyRange arg to index.openCursor"
1139 keyRange = IDBKeyRange.upperBound(0);
1141 index.openCursor(keyRange).onsuccess = function(event) {
1142 let cursor = event.target.result;
1147 testGenerator.next();
1152 is(count, 0, "Correct count for upperBound keyRange arg to index.openCursor");
1155 keyRange = IDBKeyRange.bound(
1156 data[weightSort[0]].weight,
1157 data[weightSort[weightSort.length - 1]].weight
1160 index.openCursor(keyRange).onsuccess = function(event) {
1161 let cursor = event.target.result;
1166 testGenerator.next();
1174 "Correct count for bound keyRange arg to index.openCursor"
1178 keyRange = IDBKeyRange.bound(
1179 data[weightSort[0]].weight,
1180 data[weightSort[weightSort.length - 1]].weight,
1184 index.openCursor(keyRange).onsuccess = function(event) {
1185 let cursor = event.target.result;
1190 testGenerator.next();
1197 weightSort.length - 1,
1198 "Correct count for bound keyRange arg to index.openCursor"
1202 keyRange = IDBKeyRange.bound(
1203 data[weightSort[0]].weight,
1204 data[weightSort[weightSort.length - 1]].weight,
1209 index.openCursor(keyRange).onsuccess = function(event) {
1210 let cursor = event.target.result;
1215 testGenerator.next();
1222 weightSort.length - 2,
1223 "Correct count for bound keyRange arg to index.openCursor"
1227 keyRange = IDBKeyRange.bound(
1228 data[weightSort[0]].weight - 1,
1229 data[weightSort[weightSort.length - 1]].weight + 1
1232 index.openCursor(keyRange).onsuccess = function(event) {
1233 let cursor = event.target.result;
1238 testGenerator.next();
1246 "Correct count for bound keyRange arg to index.openCursor"
1250 keyRange = IDBKeyRange.bound(
1251 data[weightSort[0]].weight - 2,
1252 data[weightSort[0]].weight - 1
1255 index.openCursor(keyRange).onsuccess = function(event) {
1256 let cursor = event.target.result;
1261 testGenerator.next();
1266 is(count, 0, "Correct count for bound keyRange arg to index.openCursor");
1269 keyRange = IDBKeyRange.bound(
1270 data[weightSort[1]].weight,
1271 data[weightSort[2]].weight
1274 index.openCursor(keyRange).onsuccess = function(event) {
1275 let cursor = event.target.result;
1280 testGenerator.next();
1285 is(count, 3, "Correct count for bound keyRange arg to index.openCursor");
1289 ok(false, "Get with unspecified arg should have thrown");
1291 ok(true, "Get with unspecified arg should have thrown");
1295 index.get(undefined);
1296 ok(false, "Get with undefined should have thrown");
1298 ok(true, "Get with undefined arg should have thrown");
1303 ok(false, "Get with null should have thrown");
1305 is(e instanceof DOMException, true, "Got right kind of exception");
1306 is(e.name, "DataError", "Correct error.");
1307 is(e.code, 0, "Correct code.");
1310 index.get(data[0].weight).onsuccess = grabEventAndContinueHandler;
1311 event = yield undefined;
1313 is(event.target.result.weight, data[0].weight, "Got correct result");
1315 keyRange = IDBKeyRange.only(data[0].weight);
1317 index.get(keyRange).onsuccess = grabEventAndContinueHandler;
1318 event = yield undefined;
1320 is(event.target.result.weight, data[0].weight, "Got correct result");
1322 keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
1324 index.get(keyRange).onsuccess = grabEventAndContinueHandler;
1325 event = yield undefined;
1328 event.target.result.weight,
1329 data[weightSort[0]].weight,
1330 "Got correct result"
1333 keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight - 1);
1335 index.get(keyRange).onsuccess = grabEventAndContinueHandler;
1336 event = yield undefined;
1339 event.target.result.weight,
1340 data[weightSort[0]].weight,
1341 "Got correct result"
1344 keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight + 1);
1346 index.get(keyRange).onsuccess = grabEventAndContinueHandler;
1347 event = yield undefined;
1350 event.target.result.weight,
1351 data[weightSort[1]].weight,
1352 "Got correct result"
1355 keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
1357 index.get(keyRange).onsuccess = grabEventAndContinueHandler;
1358 event = yield undefined;
1361 event.target.result.weight,
1362 data[weightSort[1]].weight,
1363 "Got correct result"
1366 keyRange = IDBKeyRange.bound(
1367 data[weightSort[0]].weight,
1368 data[weightSort[1]].weight
1371 index.get(keyRange).onsuccess = grabEventAndContinueHandler;
1372 event = yield undefined;
1375 event.target.result.weight,
1376 data[weightSort[0]].weight,
1377 "Got correct result"
1380 keyRange = IDBKeyRange.bound(
1381 data[weightSort[0]].weight,
1382 data[weightSort[1]].weight,
1386 index.get(keyRange).onsuccess = grabEventAndContinueHandler;
1387 event = yield undefined;
1390 event.target.result.weight,
1391 data[weightSort[1]].weight,
1392 "Got correct result"
1395 keyRange = IDBKeyRange.bound(
1396 data[weightSort[0]].weight,
1397 data[weightSort[1]].weight,
1402 index.get(keyRange).onsuccess = grabEventAndContinueHandler;
1403 event = yield undefined;
1405 is(event.target.result, undefined, "Got correct result");
1407 keyRange = IDBKeyRange.upperBound(data[weightSort[5]].weight);
1409 index.get(keyRange).onsuccess = grabEventAndContinueHandler;
1410 event = yield undefined;
1413 event.target.result.weight,
1414 data[weightSort[0]].weight,
1415 "Got correct result"
1418 keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
1420 index.get(keyRange).onsuccess = grabEventAndContinueHandler;
1421 event = yield undefined;
1423 is(event.target.result, undefined, "Got correct result");
1427 ok(false, "Get with unspecified arg should have thrown");
1429 ok(true, "Get with unspecified arg should have thrown");
1433 index.getKey(undefined);
1434 ok(false, "Get with undefined should have thrown");
1436 ok(true, "Get with undefined arg should have thrown");
1441 ok(false, "Get with null should have thrown");
1443 is(e instanceof DOMException, true, "Got right kind of exception");
1444 is(e.name, "DataError", "Correct error.");
1445 is(e.code, 0, "Correct code.");
1448 index.getKey(data[0].weight).onsuccess = grabEventAndContinueHandler;
1449 event = yield undefined;
1451 is(event.target.result, data[0].ssn, "Got correct result");
1453 keyRange = IDBKeyRange.only(data[0].weight);
1455 index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
1456 event = yield undefined;
1458 is(event.target.result, data[0].ssn, "Got correct result");
1460 keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight);
1462 index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
1463 event = yield undefined;
1465 is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
1467 keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight - 1);
1469 index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
1470 event = yield undefined;
1472 is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
1474 keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight + 1);
1476 index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
1477 event = yield undefined;
1479 is(event.target.result, data[weightSort[1]].ssn, "Got correct result");
1481 keyRange = IDBKeyRange.lowerBound(data[weightSort[0]].weight, true);
1483 index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
1484 event = yield undefined;
1486 is(event.target.result, data[weightSort[1]].ssn, "Got correct result");
1488 keyRange = IDBKeyRange.bound(
1489 data[weightSort[0]].weight,
1490 data[weightSort[1]].weight
1493 index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
1494 event = yield undefined;
1496 is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
1498 keyRange = IDBKeyRange.bound(
1499 data[weightSort[0]].weight,
1500 data[weightSort[1]].weight,
1504 index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
1505 event = yield undefined;
1507 is(event.target.result, data[weightSort[1]].ssn, "Got correct result");
1509 keyRange = IDBKeyRange.bound(
1510 data[weightSort[0]].weight,
1511 data[weightSort[1]].weight,
1516 index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
1517 event = yield undefined;
1519 is(event.target.result, undefined, "Got correct result");
1521 keyRange = IDBKeyRange.upperBound(data[weightSort[5]].weight);
1523 index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
1524 event = yield undefined;
1526 is(event.target.result, data[weightSort[0]].ssn, "Got correct result");
1528 keyRange = IDBKeyRange.upperBound(data[weightSort[0]].weight, true);
1530 index.getKey(keyRange).onsuccess = grabEventAndContinueHandler;
1531 event = yield undefined;
1533 is(event.target.result, undefined, "Got correct result");
1537 index.openKeyCursor().onsuccess = function(event) {
1538 let cursor = event.target.result;
1543 testGenerator.next();
1551 "Correct count for no arg to index.openKeyCursor"
1556 index.openKeyCursor(null).onsuccess = function(event) {
1557 let cursor = event.target.result;
1562 testGenerator.next();
1570 "Correct count for null arg to index.openKeyCursor"
1575 index.openKeyCursor(undefined).onsuccess = function(event) {
1576 let cursor = event.target.result;
1581 testGenerator.next();
1589 "Correct count for undefined arg to index.openKeyCursor"
1594 index.openKeyCursor(data[weightSort[0]].weight).onsuccess = function(event) {
1595 let cursor = event.target.result;
1600 testGenerator.next();
1605 is(count, 1, "Correct count for single key arg to index.openKeyCursor");
1609 index.openKeyCursor("foo").onsuccess = function(event) {
1610 let cursor = event.target.result;
1615 testGenerator.next();
1623 "Correct count for non-existent single key arg to index.openKeyCursor"
1627 keyRange = IDBKeyRange.only(data[weightSort[0]].weight);
1629 index.openKeyCursor(keyRange).onsuccess = function(event) {
1630 let cursor = event.target.result;
1635 testGenerator.next();
1640 is(count, 1, "Correct count for only keyRange arg to index.openKeyCursor");
1642 objectStore.mozGetAll(data[1].ssn).onsuccess = grabEventAndContinueHandler;
1643 event = yield undefined;
1645 is(event.target.result instanceof Array, true, "Got an array");
1646 is(event.target.result.length, 1, "Got correct length");
1647 is(event.target.result[0].ssn, data[1].ssn, "Got correct result");
1649 objectStore.mozGetAll(null).onsuccess = grabEventAndContinueHandler;
1650 event = yield undefined;
1652 is(event.target.result instanceof Array, true, "Got an array");
1653 is(event.target.result.length, data.length, "Got correct length");
1654 for (let i in event.target.result) {
1655 is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
1658 objectStore.mozGetAll(undefined).onsuccess = grabEventAndContinueHandler;
1659 event = yield undefined;
1661 is(event.target.result instanceof Array, true, "Got an array");
1662 is(event.target.result.length, data.length, "Got correct length");
1663 for (let i in event.target.result) {
1664 is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
1667 objectStore.mozGetAll().onsuccess = grabEventAndContinueHandler;
1668 event = yield undefined;
1670 is(event.target.result instanceof Array, true, "Got an array");
1671 is(event.target.result.length, data.length, "Got correct length");
1672 for (let i in event.target.result) {
1673 is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
1676 keyRange = IDBKeyRange.lowerBound(0);
1678 objectStore.mozGetAll(keyRange).onsuccess = grabEventAndContinueHandler;
1679 event = yield undefined;
1681 is(event.target.result instanceof Array, true, "Got an array");
1682 is(event.target.result.length, data.length, "Got correct length");
1683 for (let i in event.target.result) {
1684 is(event.target.result[i].ssn, data[i].ssn, "Got correct value");
1687 index.mozGetAll().onsuccess = grabEventAndContinueHandler;
1688 event = yield undefined;
1690 is(event.target.result instanceof Array, true, "Got an array");
1691 is(event.target.result.length, weightSort.length, "Got correct length");
1692 for (let i in event.target.result) {
1694 event.target.result[i].ssn,
1695 data[weightSort[i]].ssn,
1700 index.mozGetAll(undefined).onsuccess = grabEventAndContinueHandler;
1701 event = yield undefined;
1703 is(event.target.result instanceof Array, true, "Got an array");
1704 is(event.target.result.length, weightSort.length, "Got correct length");
1705 for (let i in event.target.result) {
1707 event.target.result[i].ssn,
1708 data[weightSort[i]].ssn,
1713 index.mozGetAll(null).onsuccess = grabEventAndContinueHandler;
1714 event = yield undefined;
1716 is(event.target.result instanceof Array, true, "Got an array");
1717 is(event.target.result.length, weightSort.length, "Got correct length");
1718 for (let i in event.target.result) {
1720 event.target.result[i].ssn,
1721 data[weightSort[i]].ssn,
1727 data[weightSort[0]].weight
1728 ).onsuccess = grabEventAndContinueHandler;
1729 event = yield undefined;
1731 is(event.target.result instanceof Array, true, "Got an array");
1732 is(event.target.result.length, 1, "Got correct length");
1733 is(event.target.result[0].ssn, data[weightSort[0]].ssn, "Got correct result");
1735 keyRange = IDBKeyRange.lowerBound(0);
1737 index.mozGetAll(keyRange).onsuccess = grabEventAndContinueHandler;
1738 event = yield undefined;
1740 is(event.target.result instanceof Array, true, "Got an array");
1741 is(event.target.result.length, weightSort.length, "Got correct length");
1742 for (let i in event.target.result) {
1744 event.target.result[i].ssn,
1745 data[weightSort[i]].ssn,
1750 index.mozGetAllKeys().onsuccess = grabEventAndContinueHandler;
1751 event = yield undefined;
1753 is(event.target.result instanceof Array, true, "Got an array");
1754 is(event.target.result.length, weightSort.length, "Got correct length");
1755 for (let i in event.target.result) {
1756 is(event.target.result[i], data[weightSort[i]].ssn, "Got correct value");
1759 index.mozGetAllKeys(undefined).onsuccess = grabEventAndContinueHandler;
1760 event = yield undefined;
1762 is(event.target.result instanceof Array, true, "Got an array");
1763 is(event.target.result.length, weightSort.length, "Got correct length");
1764 for (let i in event.target.result) {
1765 is(event.target.result[i], data[weightSort[i]].ssn, "Got correct value");
1768 index.mozGetAllKeys(null).onsuccess = grabEventAndContinueHandler;
1769 event = yield undefined;
1771 is(event.target.result instanceof Array, true, "Got an array");
1772 is(event.target.result.length, weightSort.length, "Got correct length");
1773 for (let i in event.target.result) {
1774 is(event.target.result[i], data[weightSort[i]].ssn, "Got correct value");
1777 index.mozGetAllKeys(
1778 data[weightSort[0]].weight
1779 ).onsuccess = grabEventAndContinueHandler;
1780 event = yield undefined;
1782 is(event.target.result instanceof Array, true, "Got an array");
1783 is(event.target.result.length, 1, "Got correct length");
1784 is(event.target.result[0], data[weightSort[0]].ssn, "Got correct result");
1786 keyRange = IDBKeyRange.lowerBound(0);
1788 index.mozGetAllKeys(keyRange).onsuccess = grabEventAndContinueHandler;
1789 event = yield undefined;
1791 is(event.target.result instanceof Array, true, "Got an array");
1792 is(event.target.result.length, weightSort.length, "Got correct length");
1793 for (let i in event.target.result) {
1794 is(event.target.result[i], data[weightSort[i]].ssn, "Got correct value");