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 objectStores = [
12 { name: "a", autoIncrement: false },
13 { name: "b", autoIncrement: true },
17 { name: "a", options: {} },
18 { name: "b", options: { unique: true } },
22 for (let i in objectStores) {
23 let request = indexedDB.open(name, ++j);
24 request.onerror = errorHandler;
25 request.onupgradeneeded = grabEventAndContinueHandler;
26 let event = yield undefined;
28 let db = event.target.result;
29 db.onversionchange = function(event) {
33 let objectStore = db.createObjectStore(objectStores[i].name, {
35 autoIncrement: objectStores[i].autoIncrement,
38 for (let j in indexes) {
39 objectStore.createIndex(indexes[j].name, "name", indexes[j].options);
42 let data = { name: "Ben" };
43 if (!objectStores[i].autoIncrement) {
47 request = objectStore.add(data);
48 request.onerror = errorHandler;
49 request.onsuccess = grabEventAndContinueHandler;
50 event = yield undefined;
52 ok(event.target.result == 1 || event.target.result == 2, "Good id");
55 executeSoon(function() {
60 let request = indexedDB.open(name, j);
61 request.onerror = errorHandler;
62 request.onsuccess = grabEventAndContinueHandler;
63 let event = yield undefined;
65 let db = event.target.result;
67 for (let i in objectStores) {
68 for (let j in indexes) {
70 .transaction(objectStores[i].name)
71 .objectStore(objectStores[i].name);
72 let index = objectStore.index(indexes[j].name);
74 request = index.openCursor();
75 request.onerror = errorHandler;
76 request.onsuccess = function(event) {
77 is(event.target.result.value.name, "Ben", "Good object");
78 executeSoon(function() {