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 = event.target.result; michael@0: michael@0: event.target.onsuccess = continueToNextStep; michael@0: michael@0: let objectStore = db.createObjectStore("foo"); michael@0: objectStore.add({}, 1).onerror = errorHandler; michael@0: michael@0: yield undefined; michael@0: michael@0: objectStore = db.transaction("foo").objectStore("foo"); michael@0: michael@0: let transaction = objectStore.transaction; michael@0: transaction.oncomplete = unexpectedSuccessHandler; michael@0: transaction.onabort = grabEventAndContinueHandler; michael@0: michael@0: let sawError = false; michael@0: michael@0: request = objectStore.get(1); michael@0: request.onsuccess = unexpectedSuccessHandler; michael@0: request.onerror = function(event) { michael@0: is(event.target.error.name, "AbortError", "Good error"); michael@0: sawError = true; michael@0: event.preventDefault(); michael@0: } michael@0: michael@0: transaction.abort(); michael@0: michael@0: event = yield undefined; michael@0: michael@0: is(event.type, "abort", "Got abort event"); michael@0: is(sawError, true, "Saw get() error"); michael@0: if (this.window) { michael@0: // Make sure the success event isn't queued somehow. michael@0: let comp = SpecialPowers.wrap(Components); michael@0: let thread = comp.classes["@mozilla.org/thread-manager;1"] michael@0: .getService(comp.interfaces.nsIThreadManager) michael@0: .currentThread; michael@0: while (thread.hasPendingEvents()) { michael@0: thread.processNextEvent(false); michael@0: } michael@0: } michael@0: michael@0: finishTest(); michael@0: yield undefined; michael@0: } michael@0: