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";
11 const objectStores = ["foo", "bar"];
13 let request = indexedDB.open(name, 1);
14 request.onerror = errorHandler;
15 request.onupgradeneeded = grabEventAndContinueHandler;
16 let event = yield undefined;
18 let db = event.target.result;
19 is(db.objectStoreNames.length, 0, "Correct objectStoreNames list");
21 event.target.onsuccess = grabEventAndContinueHandler;
22 for (let i in objectStores) {
23 db.createObjectStore(objectStores[i], { autoIncrement: true });
25 event = yield undefined;
28 db.objectStoreNames.length,
30 "Correct objectStoreNames list"
33 for (let i = 0; i < 50; i++) {
37 .transaction(["foo"], "readwrite")
40 request.onerror = errorHandler;
41 request.onsuccess = function(event) {
42 is(stepNumber, 1, "This callback came first");
44 event.target.transaction.oncomplete = grabEventAndContinueHandler;
48 .transaction(["foo"], "readwrite")
51 request.onerror = errorHandler;
52 request.onsuccess = function(event) {
53 is(stepNumber, 2, "This callback came second");
55 event.target.transaction.oncomplete = grabEventAndContinueHandler;
59 .transaction(["foo", "bar"], "readwrite")
62 request.onerror = errorHandler;
63 request.onsuccess = function(event) {
64 is(stepNumber, 3, "This callback came third");
66 event.target.transaction.oncomplete = grabEventAndContinueHandler;
70 .transaction(["foo", "bar"], "readwrite")
73 request.onerror = errorHandler;
74 request.onsuccess = function(event) {
75 is(stepNumber, 4, "This callback came fourth");
77 event.target.transaction.oncomplete = grabEventAndContinueHandler;
81 .transaction(["bar"], "readwrite")
84 request.onerror = errorHandler;
85 request.onsuccess = function(event) {
86 is(stepNumber, 5, "This callback came fifth");
88 event.target.transaction.oncomplete = grabEventAndContinueHandler;
98 is(stepNumber, 6, "All callbacks received");