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: db.onerror = errorHandler; michael@0: michael@0: event.target.onsuccess = continueToNextStep; michael@0: db.createObjectStore("foo"); michael@0: yield undefined; michael@0: michael@0: let transaction1 = db.transaction("foo"); michael@0: michael@0: let transaction2; michael@0: michael@0: let comp = this.window ? SpecialPowers.wrap(Components) : Components; michael@0: let thread = comp.classes["@mozilla.org/thread-manager;1"] michael@0: .getService(comp.interfaces.nsIThreadManager) michael@0: .currentThread; michael@0: michael@0: let eventHasRun; michael@0: michael@0: thread.dispatch(function() { michael@0: eventHasRun = true; michael@0: michael@0: transaction2 = db.transaction("foo"); michael@0: }, Components.interfaces.nsIThread.DISPATCH_NORMAL); michael@0: michael@0: while (!eventHasRun) { michael@0: thread.processNextEvent(false); michael@0: } michael@0: michael@0: ok(transaction2, "Non-null transaction2"); michael@0: michael@0: continueToNextStep(); michael@0: yield undefined; michael@0: michael@0: finishTest(); michael@0: yield undefined; michael@0: }