1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/indexedDB/test/unit/test_transaction_lifetimes_nested.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 1.4 +/** 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.7 + */ 1.8 + 1.9 +var testGenerator = testSteps(); 1.10 + 1.11 +function testSteps() 1.12 +{ 1.13 + let request = indexedDB.open(this.window ? window.location.pathname : "Splendid Test", 1); 1.14 + request.onerror = errorHandler; 1.15 + request.onupgradeneeded = grabEventAndContinueHandler; 1.16 + let event = yield undefined; 1.17 + 1.18 + let db = event.target.result; 1.19 + db.onerror = errorHandler; 1.20 + 1.21 + event.target.onsuccess = continueToNextStep; 1.22 + db.createObjectStore("foo"); 1.23 + yield undefined; 1.24 + 1.25 + let transaction1 = db.transaction("foo"); 1.26 + 1.27 + let transaction2; 1.28 + 1.29 + let comp = this.window ? SpecialPowers.wrap(Components) : Components; 1.30 + let thread = comp.classes["@mozilla.org/thread-manager;1"] 1.31 + .getService(comp.interfaces.nsIThreadManager) 1.32 + .currentThread; 1.33 + 1.34 + let eventHasRun; 1.35 + 1.36 + thread.dispatch(function() { 1.37 + eventHasRun = true; 1.38 + 1.39 + transaction2 = db.transaction("foo"); 1.40 + }, Components.interfaces.nsIThread.DISPATCH_NORMAL); 1.41 + 1.42 + while (!eventHasRun) { 1.43 + thread.processNextEvent(false); 1.44 + } 1.45 + 1.46 + ok(transaction2, "Non-null transaction2"); 1.47 + 1.48 + continueToNextStep(); 1.49 + yield undefined; 1.50 + 1.51 + finishTest(); 1.52 + yield undefined; 1.53 +}