michael@0: /** michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: var testGenerator = testSteps(); michael@0: michael@0: function testSteps() michael@0: { michael@0: let request = indexedDB.open(this.window ? window.location.pathname : "Splendid Test", 1); michael@0: request.onerror = errorHandler; michael@0: request.onupgradeneeded = grabEventAndContinueHandler; michael@0: let event = yield undefined; michael@0: michael@0: let db = request.result; michael@0: db.onerror = errorHandler; michael@0: michael@0: let objectStore = db.createObjectStore("foo", { keyPath: "id", michael@0: autoIncrement: true }); michael@0: objectStore.createIndex("first","first"); michael@0: objectStore.createIndex("second","second"); michael@0: objectStore.createIndex("third","third"); michael@0: michael@0: let data = { first: "foo", second: "foo", third: "foo" }; michael@0: michael@0: objectStore.add(data).onsuccess = grabEventAndContinueHandler; michael@0: event = yield undefined; michael@0: michael@0: is(event.target.result, 1, "Added entry"); michael@0: request.onsuccess = grabEventAndContinueHandler; michael@0: michael@0: event = yield undefined; michael@0: michael@0: let objectStore = db.transaction("foo").objectStore("foo"); michael@0: let first = objectStore.index("first"); michael@0: let second = objectStore.index("second"); michael@0: let third = objectStore.index("third"); michael@0: michael@0: first.get("foo").onsuccess = grabEventAndContinueHandler; michael@0: event = yield undefined; michael@0: michael@0: is (event.target.result.id, 1, "Entry in first"); michael@0: michael@0: second.get("foo").onsuccess = grabEventAndContinueHandler; michael@0: event = yield undefined; michael@0: michael@0: is (event.target.result.id, 1, "Entry in second"); michael@0: michael@0: third.get("foo").onsuccess = grabEventAndContinueHandler; michael@0: event = yield undefined; michael@0: michael@0: is (event.target.result.id, 1, "Entry in third"); michael@0: michael@0: finishTest(); michael@0: yield undefined; michael@0: }