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 data = { key: 5, index: 10 };
12 let request = indexedDB.open(
13 this.window ? window.location.pathname : "Splendid Test",
16 request.onerror = errorHandler;
17 request.onupgradeneeded = grabEventAndContinueHandler;
18 let event = yield undefined;
20 let db = event.target.result;
22 ok(db instanceof IDBDatabase, "Got a real database");
24 db.onerror = errorHandler;
26 let objectStore = db.createObjectStore("foo", {
30 objectStore.createIndex("foo", "index");
32 event.target.onsuccess = continueToNextStep;
35 objectStore = db.transaction("foo", "readwrite").objectStore("foo");
36 request = objectStore.add(data);
37 request.onsuccess = grabEventAndContinueHandler;
38 event = yield undefined;
41 executeSoon(function() {
47 is(key, data.key, "Got the right key");
49 objectStore = db.transaction("foo").objectStore("foo");
50 objectStore.get(data.key).onsuccess = grabEventAndContinueHandler;
51 event = yield undefined;
54 executeSoon(function() {
55 obj = event.target.result;
60 is(obj.key, data.key, "Got the right key");
61 is(obj.index, data.index, "Got the right property value");
63 objectStore = db.transaction("foo", "readwrite").objectStore("foo");
64 request = objectStore.delete(data.key);
65 request.onsuccess = grabEventAndContinueHandler;
66 event = yield undefined;
69 executeSoon(function() {
75 ok(key === undefined, "Got the right value");