2 * Any copyright is dedicated to the Public Domain.
3 * http://creativecommons.org/publicdomain/zero/1.0/
6 /* exported testGenerator */
7 var testGenerator = testSteps();
9 function* testSteps() {
10 const name = this.window ? window.location.pathname : "Splendid Test";
14 name: "inline key; key generator",
16 storedObject: { name: "Lincoln" },
21 name: "inline key; no key generator",
23 storedObject: { id: 1, name: "Lincoln" },
28 name: "out of line key; key generator",
30 storedObject: { name: "Lincoln" },
35 name: "out of line key; no key generator",
37 storedObject: { name: "Lincoln" },
43 for (let i = 0; i < data.length; i++) {
46 let request = indexedDB.open(name, i + 1);
47 request.onerror = errorHandler;
48 request.onupgradeneeded = grabEventAndContinueHandler;
49 request.onsuccess = grabEventAndContinueHandler;
50 let event = yield undefined;
52 let db = event.target.result;
53 db.onversionchange = function(event) {
57 let objectStore = db.createObjectStore(test.name, {
58 keyPath: test.keyName,
59 autoIncrement: test.autoIncrement,
62 request = objectStore.add(test.storedObject, test.keyValue);
63 request.onerror = errorHandler;
64 request.onsuccess = grabEventAndContinueHandler;
65 event = yield undefined;
67 let id = event.target.result;
68 request = objectStore.get(id);
69 request.onerror = errorHandler;
70 request.onsuccess = grabEventAndContinueHandler;
71 event = yield undefined;
75 test.storedObject.name,
76 event.target.result.name,
77 "The correct object was stored."
80 request = objectStore.delete(id);
81 request.onerror = errorHandler;
82 request.onsuccess = grabEventAndContinueHandler;
83 event = yield undefined;
85 // Make sure it was removed.
86 request = objectStore.get(id);
87 request.onerror = errorHandler;
88 request.onsuccess = grabEventAndContinueHandler;
89 event = yield undefined;
91 ok(event.target.result === undefined, "Object was deleted");