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 let request = indexedDB.open(
11 this.window ? window.location.pathname : "Splendid Test",
14 request.onerror = errorHandler;
15 request.onupgradeneeded = grabEventAndContinueHandler;
16 request.onsuccess = unexpectedSuccessHandler;
17 let event = yield undefined;
19 let db = event.target.result;
20 db.onerror = errorHandler;
22 event.target.transaction.onerror = errorHandler;
23 event.target.transaction.oncomplete = grabEventAndContinueHandler;
25 let os = db.createObjectStore("foo", { autoIncrement: true });
26 os.createIndex("bar", "foo.bar");
27 event = yield undefined;
32 "request.transaction should still be set"
35 request.onsuccess = grabEventAndContinueHandler;
36 event = yield undefined;
38 is(request.transaction, null, "request.transaction should be cleared");
40 let transaction = db.transaction("foo", "readwrite");
42 os = transaction.objectStore("foo");
43 // Place a request to keep the transaction alive long enough for our
45 let requestComplete = false;
47 let wasAbleToGrabObjectStoreOutsideOfCallback = false;
48 let wasAbleToGrabIndexOutsideOfCallback = false;
49 executeSoon(function() {
50 ok(!requestComplete, "Ordering is correct.");
51 wasAbleToGrabObjectStoreOutsideOfCallback = !!transaction.objectStore(
54 wasAbleToGrabIndexOutsideOfCallback = !!transaction
60 request.onerror = errorHandler;
61 request.onsuccess = grabEventAndContinueHandler;
63 event = yield undefined;
65 requestComplete = true;
68 wasAbleToGrabObjectStoreOutsideOfCallback,
69 "Should be able to get objectStore"
71 ok(wasAbleToGrabIndexOutsideOfCallback, "Should be able to get index");
73 transaction.oncomplete = grabEventAndContinueHandler;
77 transaction.objectStore("foo");
78 ok(false, "Should have thrown!");
80 ok(e instanceof DOMException, "Got database exception.");
81 is(e.name, "InvalidStateError", "Good error.");
82 is(e.code, DOMException.INVALID_STATE_ERR, "Good error code.");
89 transaction.objectStore("foo");
90 ok(false, "Should have thrown!");
92 ok(e instanceof DOMException, "Got database exception.");
93 is(e.name, "InvalidStateError", "Good error.");
94 is(e.code, DOMException.INVALID_STATE_ERR, "Good error code.");