diff --git a/dom/archivereader/test/helpers.js b/dom/archivereader/test/helpers.js index 3ba430436049..f6ad40a9c1fe 100644 --- a/dom/archivereader/test/helpers.js +++ b/dom/archivereader/test/helpers.js @@ -3,8 +3,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -var testGenerator; - function runTest() { SimpleTest.waitForExplicitFinish(); @@ -12,8 +10,7 @@ function runTest() SpecialPowers.pushPrefEnv({'set': [ ["dom.archivereader.enabled", true] ]}, function() { SpecialPowers.createFiles(filesToCreate(), function (files) { - testGenerator = testSteps(files); - return testGenerator.next(); + testSteps(files); }, function (msg) { ok(false, "File creation error: " + msg); @@ -25,7 +22,6 @@ function runTest() function finishTest() { SpecialPowers.popPrefEnv(function() { - testGenerator.close(); SimpleTest.finish(); }); } diff --git a/dom/archivereader/test/test_basic.html b/dom/archivereader/test/test_basic.html index b3e5ab852ace..516c9d8e4547 100644 --- a/dom/archivereader/test/test_basic.html +++ b/dom/archivereader/test/test_basic.html @@ -212,7 +212,6 @@ ok(false, "ArchiveReader.getFiles() should not return an 'error'"); markTestDone(); } - yield undefined; } diff --git a/dom/archivereader/test/test_nonUnicode.html b/dom/archivereader/test/test_nonUnicode.html index 6237ce10f9fe..f24e400ec601 100644 --- a/dom/archivereader/test/test_nonUnicode.html +++ b/dom/archivereader/test/test_nonUnicode.html @@ -51,7 +51,6 @@ function testSteps(files) { test1(files[0]); - yield undefined; } diff --git a/dom/archivereader/test/test_zip_in_zip.html b/dom/archivereader/test/test_zip_in_zip.html index 7e381a1efeae..69e1c1de78c8 100644 --- a/dom/archivereader/test/test_zip_in_zip.html +++ b/dom/archivereader/test/test_zip_in_zip.html @@ -25,8 +25,6 @@ // The input is 4 nested zip archives: doLoop(binaryFile, 4); - - yield undefined; } function doLoop(blob, loop) diff --git a/dom/base/test/browser_use_counters.js b/dom/base/test/browser_use_counters.js index e4d29654be1e..27ca44161356 100644 --- a/dom/base/test/browser_use_counters.js +++ b/dom/base/test/browser_use_counters.js @@ -83,7 +83,7 @@ add_task(function* () { let Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry); Telemetry.canRecordExtended = gOldParentCanRecord; - yield ContentTask.spawn(gBrowser.selectedBrowser, { oldCanRecord: gOldContentCanRecord }, function (arg) { + yield ContentTask.spawn(gBrowser.selectedBrowser, { oldCanRecord: gOldContentCanRecord }, function* (arg) { Cu.import("resource://gre/modules/PromiseUtils.jsm"); yield new Promise(resolve => { let telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry); @@ -127,7 +127,7 @@ function grabHistogramsFromContent(use_counter_middlefix, page_before = null) { }).then(gather, gather); } -var check_use_counter_iframe = Task.async(function* (file, use_counter_middlefix, check_documents=true) { +var check_use_counter_iframe = async function(file, use_counter_middlefix, check_documents=true) { info("checking " + file + " with histogram " + use_counter_middlefix); let newTab = gBrowser.addTab( "about:blank"); @@ -138,13 +138,13 @@ var check_use_counter_iframe = Task.async(function* (file, use_counter_middlefix // interested in. let [histogram_page_before, histogram_document_before, histogram_docs_before, histogram_toplevel_docs_before] = - yield grabHistogramsFromContent(use_counter_middlefix); + await grabHistogramsFromContent(use_counter_middlefix); gBrowser.selectedBrowser.loadURI(gHttpTestRoot + "file_use_counter_outer.html"); - yield waitForPageLoad(gBrowser.selectedBrowser); + await waitForPageLoad(gBrowser.selectedBrowser); // Inject our desired file into the iframe of the newly-loaded page. - yield ContentTask.spawn(gBrowser.selectedBrowser, { file: file }, function(opts) { + await ContentTask.spawn(gBrowser.selectedBrowser, { file: file }, function(opts) { Cu.import("resource://gre/modules/PromiseUtils.jsm"); let deferred = PromiseUtils.defer(); @@ -174,12 +174,12 @@ var check_use_counter_iframe = Task.async(function* (file, use_counter_middlefix // The histograms only get recorded when the document actually gets // destroyed, which might not have happened yet due to GC/CC effects, etc. // Try to force document destruction. - yield waitForDestroyedDocuments(); + await waitForDestroyedDocuments(); // Grab histograms again and compare. let [histogram_page_after, histogram_document_after, histogram_docs_after, histogram_toplevel_docs_after] = - yield grabHistogramsFromContent(use_counter_middlefix, histogram_page_before); + await grabHistogramsFromContent(use_counter_middlefix, histogram_page_before); is(histogram_page_after, histogram_page_before + 1, "page counts for " + use_counter_middlefix + " after are correct"); @@ -189,9 +189,9 @@ var check_use_counter_iframe = Task.async(function* (file, use_counter_middlefix is(histogram_document_after, histogram_document_before + 1, "document counts for " + use_counter_middlefix + " after are correct"); } -}); +}; -var check_use_counter_img = Task.async(function* (file, use_counter_middlefix) { +var check_use_counter_img = async function(file, use_counter_middlefix) { info("checking " + file + " as image with histogram " + use_counter_middlefix); let newTab = gBrowser.addTab("about:blank"); @@ -202,13 +202,13 @@ var check_use_counter_img = Task.async(function* (file, use_counter_middlefix) { // interested in. let [histogram_page_before, histogram_document_before, histogram_docs_before, histogram_toplevel_docs_before] = - yield grabHistogramsFromContent(use_counter_middlefix); + await grabHistogramsFromContent(use_counter_middlefix); gBrowser.selectedBrowser.loadURI(gHttpTestRoot + "file_use_counter_outer.html"); - yield waitForPageLoad(gBrowser.selectedBrowser); + await waitForPageLoad(gBrowser.selectedBrowser); // Inject our desired file into the img of the newly-loaded page. - yield ContentTask.spawn(gBrowser.selectedBrowser, { file: file }, function(opts) { + await ContentTask.spawn(gBrowser.selectedBrowser, { file: file }, function*(opts) { Cu.import("resource://gre/modules/PromiseUtils.jsm"); let deferred = PromiseUtils.defer(); @@ -239,12 +239,12 @@ var check_use_counter_img = Task.async(function* (file, use_counter_middlefix) { // The histograms only get recorded when the document actually gets // destroyed, which might not have happened yet due to GC/CC effects, etc. // Try to force document destruction. - yield waitForDestroyedDocuments(); + await waitForDestroyedDocuments(); // Grab histograms again and compare. let [histogram_page_after, histogram_document_after, histogram_docs_after, histogram_toplevel_docs_after] = - yield grabHistogramsFromContent(use_counter_middlefix, histogram_page_before); + await grabHistogramsFromContent(use_counter_middlefix, histogram_page_before); is(histogram_page_after, histogram_page_before + 1, "page counts for " + use_counter_middlefix + " after are correct"); is(histogram_document_after, histogram_document_before + 1, @@ -255,9 +255,9 @@ var check_use_counter_img = Task.async(function* (file, use_counter_middlefix) { // one for the SVG image itself. ok(histogram_docs_after >= histogram_docs_before + 2, "document counts are correct"); -}); +}; -var check_use_counter_direct = Task.async(function* (file, use_counter_middlefix, xfail=false) { +var check_use_counter_direct = async function(file, use_counter_middlefix, xfail=false) { info("checking " + file + " with histogram " + use_counter_middlefix); let newTab = gBrowser.addTab( "about:blank"); @@ -268,10 +268,10 @@ var check_use_counter_direct = Task.async(function* (file, use_counter_middlefix // interested in. let [histogram_page_before, histogram_document_before, histogram_docs_before, histogram_toplevel_docs_before] = - yield grabHistogramsFromContent(use_counter_middlefix); + await grabHistogramsFromContent(use_counter_middlefix); gBrowser.selectedBrowser.loadURI(gHttpTestRoot + file); - yield ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { + await ContentTask.spawn(gBrowser.selectedBrowser, null, function*() { Cu.import("resource://gre/modules/PromiseUtils.jsm"); yield new Promise(resolve => { let listener = () => { @@ -292,12 +292,12 @@ var check_use_counter_direct = Task.async(function* (file, use_counter_middlefix // The histograms only get recorded when the document actually gets // destroyed, which might not have happened yet due to GC/CC effects, etc. // Try to force document destruction. - yield waitForDestroyedDocuments(); + await waitForDestroyedDocuments(); // Grab histograms again and compare. let [histogram_page_after, histogram_document_after, histogram_docs_after, histogram_toplevel_docs_after] = - yield grabHistogramsFromContent(use_counter_middlefix, histogram_page_before); + await grabHistogramsFromContent(use_counter_middlefix, histogram_page_before); (xfail ? todo_is : is)(histogram_page_after, histogram_page_before + 1, "page counts for " + use_counter_middlefix + " after are correct"); (xfail ? todo_is : is)(histogram_document_after, histogram_document_before + 1, @@ -306,4 +306,4 @@ var check_use_counter_direct = Task.async(function* (file, use_counter_middlefix "top level document counts are correct"); ok(histogram_docs_after >= histogram_docs_before + 1, "document counts are correct"); -}); +}; diff --git a/dom/base/test/referrer_helper.js b/dom/base/test/referrer_helper.js index c46bdea7a49c..5615b038ddba 100644 --- a/dom/base/test/referrer_helper.js +++ b/dom/base/test/referrer_helper.js @@ -66,7 +66,7 @@ function resetState() { /** * testing if anchor and area referrer attributes are honoured (1174913) */ -var tests = (function() { +var tests = (function*() { // enable referrer attribute yield SpecialPowers.pushPrefEnv({"set": [['network.http.enablePerElementReferrer', true]]}, advance); @@ -97,6 +97,6 @@ var tests = (function() { }; }; - // complete. Be sure to yield so we don't call this twice. - yield SimpleTest.finish(); -})(); \ No newline at end of file + // complete. + SimpleTest.finish(); +})(); diff --git a/dom/base/test/test_audioNotificationSilent_audioFile.html b/dom/base/test/test_audioNotificationSilent_audioFile.html index 0b3b89580101..38f7221499cb 100644 --- a/dom/base/test/test_audioNotificationSilent_audioFile.html +++ b/dom/base/test/test_audioNotificationSilent_audioFile.html @@ -28,11 +28,7 @@ var observer = { }; function continueTest() { - try { - generator.next(); - } catch (e if e instanceof StopIteration) { - error("Stop test because of exception!"); - } + generator.next(); } function audioPlayingStart() { @@ -58,16 +54,16 @@ function finish() { SimpleTest.finish(); } -function runTest() { +function* runTest() { yield audioPlayingStart(); yield audioBecomeSilentDuringPlaying(); - yield finish(); + finish(); } continueTest(); - \ No newline at end of file + diff --git a/dom/base/test/test_audioNotificationSilent_webAudio.html b/dom/base/test/test_audioNotificationSilent_webAudio.html index de4165f8e438..ef180952c00b 100644 --- a/dom/base/test/test_audioNotificationSilent_webAudio.html +++ b/dom/base/test/test_audioNotificationSilent_webAudio.html @@ -30,11 +30,7 @@ var observer = { }; function continueTest() { - try { - generator.next(); - } catch (e if e instanceof StopIteration) { - error("Stop test because of exception!"); - } + generator.next(); } function playOscillatorNode() { @@ -86,18 +82,18 @@ function startAudioContext() { } } -function runTest() { +function* runTest() { yield startAudioContext(); yield audioPlayingStart(); yield audioBecomeSilentDuringPlaying(); - yield finish(); + finish(); } continueTest(); - \ No newline at end of file + diff --git a/dom/base/test/test_bug1163743.html b/dom/base/test/test_bug1163743.html index 69d1c8c33f54..e718bca29626 100644 --- a/dom/base/test/test_bug1163743.html +++ b/dom/base/test/test_bug1163743.html @@ -20,7 +20,7 @@ var advance = function() { tests.next(); }; /** * testing legacy support for origin-when-crossorigin (1163743) */ -var tests = (function() { +var tests = (function*() { var iframe = document.getElementById("testframe"); const sjs = "/tests/dom/base/test/bug704320.sjs?action=generate-policy-test"; @@ -29,8 +29,8 @@ var tests = (function() { yield iframe.src = sjs + "&policy=" + escape(' origin-when-crossorigin'); yield checkIndividualResults("origin-when-cross-origin", ["origin", "full"]); - // complete. Be sure to yield so we don't call this twice. - yield SimpleTest.finish(); + // complete. + SimpleTest.finish(); })(); diff --git a/dom/base/test/test_bug1165501.html b/dom/base/test/test_bug1165501.html index fe932d4ea87c..35bee854fd3c 100644 --- a/dom/base/test/test_bug1165501.html +++ b/dom/base/test/test_bug1165501.html @@ -21,7 +21,7 @@ var advance = function() { tests.next(); }; * testing if policy is overwritten if there are two meta statements (1165501) * XXX: would be nice to test this with CSP and meta as well */ -var tests = (function() { +var tests = (function*() { var iframe = document.getElementById("testframe"); const sjs = "/tests/dom/base/test/bug704320.sjs?action=generate-policy-test"; @@ -36,8 +36,8 @@ var tests = (function() { yield checkIndividualResults("no-referrer then default", ["full"]); - // complete. Be sure to yield so we don't call this twice. - yield SimpleTest.finish(); + // complete. + SimpleTest.finish(); })(); diff --git a/dom/base/test/test_bug544642.html b/dom/base/test/test_bug544642.html index 350360f41c5b..a0ee76b8ac57 100644 --- a/dom/base/test/test_bug544642.html +++ b/dom/base/test/test_bug544642.html @@ -17,10 +17,10 @@ var gen = runTest(); addLoadEvent(function() { gen.next(); }); -function runTest() { +function* runTest() { var iframe = $('iframe'); - iframe.onerror = function() { gen.send("error"); }; - iframe.onload = function() { gen.send("load"); }; + iframe.onerror = function() { gen.next("error"); }; + iframe.onload = function() { gen.next("load"); }; iframe.src = "data:text/plain,hello"; is((yield), "load", "plaintext data"); @@ -34,8 +34,6 @@ function runTest() { //is((yield), "error", "invalid http"); SimpleTest.finish(); - - yield undefined; } diff --git a/dom/base/test/test_bug590870.html b/dom/base/test/test_bug590870.html index 0faa2f4b6080..980ba7bbaf55 100644 --- a/dom/base/test/test_bug590870.html +++ b/dom/base/test/test_bug590870.html @@ -15,11 +15,11 @@ diff --git a/dom/base/test/test_bug682592.html b/dom/base/test/test_bug682592.html index c2dc8ed3a484..a9b66442d771 100644 --- a/dom/base/test/test_bug682592.html +++ b/dom/base/test/test_bug682592.html @@ -51,14 +51,14 @@ var testFrame = document.getElementById("iframe-test"); refFrame.addEventListener("load", function() { testFrame.addEventListener("load", function() { - try { - tests.next(); + let {done} = tests.next(); + if (!done) { ok(compareSnapshots(snapshotWindow(testFrame.contentWindow), snapshotWindow(refFrame.contentWindow), true)[0], "bidi is not detected correctly"); testFrame.contentWindow.location.reload(); - } catch (err if err instanceof StopIteration) { + } else { SimpleTest.finish(); } }, false); @@ -78,7 +78,7 @@ function strMult(aStr, aNumber) { return strMult(aStr, aNumber - 1) + aStr; } -function runTests () { +function* runTests () { var ltr = "", prefix = null; var refContainer = refFrame.contentDocument.getElementById('content'); var testContainer, textNode; diff --git a/dom/base/test/test_bug704320.html b/dom/base/test/test_bug704320.html index 5c8e46c03d37..a536807fb88c 100644 --- a/dom/base/test/test_bug704320.html +++ b/dom/base/test/test_bug704320.html @@ -41,7 +41,7 @@ var advance = function() { tests.next(); }; * This is the main test routine -- serialized by use of a generator. * It performs all tests in sequence using in the same iframe. */ -var tests = (function() { +var tests = (function*() { SimpleTest.requestLongerTimeout(4); var iframe = document.getElementById("testframe"); iframe.onload = function() { @@ -57,8 +57,8 @@ var tests = (function() { yield checkExpectedGlobalResults(); } - // complete. Be sure to yield so we don't call this twice. - yield SimpleTest.finish(); + // complete. + SimpleTest.finish(); })(); diff --git a/dom/base/test/test_bug704320_policyset.html b/dom/base/test/test_bug704320_policyset.html index 8188a9480652..ac4eafa7e66b 100644 --- a/dom/base/test/test_bug704320_policyset.html +++ b/dom/base/test/test_bug704320_policyset.html @@ -22,7 +22,7 @@ var advance = function() { tests.next(); }; * It resets the counter, then performs two tests in sequence using * the same iframe. */ -var tests = (function() { +var tests = (function*() { var iframe = document.getElementById("testframe"); const sjs = "/tests/dom/base/test/bug704320.sjs?action=generate-policy-test"; @@ -89,8 +89,8 @@ var tests = (function() { yield iframe.src = sjs + "&policy=" + escape('\f OrigIn'); yield checkIndividualResults("origin case insensitive", ["origin"]); - // complete. Be sure to yield so we don't call this twice. - yield SimpleTest.finish(); + // complete. + SimpleTest.finish(); })(); diff --git a/dom/base/test/test_bug704320_policyset2.html b/dom/base/test/test_bug704320_policyset2.html index b9cc74e3d782..9bb5b3d27c90 100644 --- a/dom/base/test/test_bug704320_policyset2.html +++ b/dom/base/test/test_bug704320_policyset2.html @@ -22,7 +22,7 @@ var advance = function() { tests.next(); }; * It resets the counter, then performs two tests in sequence using * the same iframe. */ -var tests = (function() { +var tests = (function*() { var iframe = document.getElementById("testframe"); const sjs = "/tests/dom/base/test/bug704320.sjs?action=generate-policy-test"; @@ -30,8 +30,8 @@ var tests = (function() { yield iframe.src = sjs + "&policy=" + escape(' \f\r\n\t '); yield checkIndividualResults("whitespace only policy", ["full"]); - // complete. Be sure to yield so we don't call this twice. - yield SimpleTest.finish(); + // complete. + SimpleTest.finish(); })(); diff --git a/dom/base/test/test_bug704320_preload.html b/dom/base/test/test_bug704320_preload.html index d7f2fc72d39b..bba534ca45b5 100644 --- a/dom/base/test/test_bug704320_preload.html +++ b/dom/base/test/test_bug704320_preload.html @@ -22,7 +22,7 @@ var advance = function() { tests.next(); }; * It resets the counter, then performs two tests in sequence using * the same iframe. */ -var tests = (function() { +var tests = (function*() { var iframe = document.getElementById("testframe"); // reset the counter @@ -47,8 +47,8 @@ var tests = (function() { // check the second test yield checkResults(finalizePreloadReuse); - // complete. Be sure to yield so we don't call this twice. - yield SimpleTest.finish(); + // complete. + SimpleTest.finish(); })(); // Helper functions below. diff --git a/dom/base/test/test_change_policy.html b/dom/base/test/test_change_policy.html index 76816f01feed..4ab5b9ce38eb 100644 --- a/dom/base/test/test_change_policy.html +++ b/dom/base/test/test_change_policy.html @@ -78,7 +78,7 @@ function resetState() { * It resets the counter, then performs two tests in sequence using * the same iframe. */ -var tests = (function() { +var tests = (function*() { var iframe = document.getElementById("testframe"); var sjs = "/tests/dom/base/test/referrer_change_server.sjs?action=generate-policy-test"; @@ -114,8 +114,8 @@ var tests = (function() { yield iframe.src = sjs + "&policy=" + escape('unsafe-url') + "&name=" + name + "&newPolicy=" + escape('no-referrer'); yield checkIndividualResults("no-referrer (changed) with unsafe-url first", ["none"], [name+'no-referrer']); - // complete. Be sure to yield so we don't call this twice. - yield SimpleTest.finish(); + // complete. + SimpleTest.finish(); })(); diff --git a/dom/base/test/test_img_referrer.html b/dom/base/test/test_img_referrer.html index 16259bcc3930..2f7bffc4fae7 100644 --- a/dom/base/test/test_img_referrer.html +++ b/dom/base/test/test_img_referrer.html @@ -82,7 +82,7 @@ function resetState() { /** * testing if img referrer attribute is honoured (1165501) */ -var tests = (function() { +var tests = (function*() { // enable referrer attribute yield SpecialPowers.pushPrefEnv({"set": [['network.http.enablePerElementReferrer', true]]}, advance); @@ -174,8 +174,8 @@ var tests = (function() { yield iframe.src = sjs + "&imgPolicy=" + escape('default') + "&policy=" + escape('unsafe-url') + "&name=" + name; yield checkIndividualResults("unsafe-url in meta, default in img", ["full"], [name]); - // complete. Be sure to yield so we don't call this twice. - yield SimpleTest.finish(); + // complete. + SimpleTest.finish(); })(); diff --git a/dom/browser-element/mochitest/browserElement_ActiveStateChange.js b/dom/browser-element/mochitest/browserElement_ActiveStateChange.js index cfbc1cb1e185..60fb09d321fe 100644 --- a/dom/browser-element/mochitest/browserElement_ActiveStateChange.js +++ b/dom/browser-element/mochitest/browserElement_ActiveStateChange.js @@ -4,7 +4,6 @@ SimpleTest.waitForExplicitFinish(); browserElementTestHelpers.setEnabledPref(true); var fileURL = 'chrome://mochitests/content/chrome/dom/browser-element/mochitest/file_browserElement_ActiveStateChange.html'; -var generator = runTests(); var testFrame; var ac; @@ -17,55 +16,46 @@ function error(aMessage) { finish(); } -function continueTest() { - try { - generator.next(); - } catch (e if e instanceof StopIteration) { - error("Stop test because of exception!"); - } -} - function finish() { document.body.removeChild(testFrame); SimpleTest.finish(); } function setCommand(aArg) { - assert(!!ac, "Audio channel doesn't exist!"); - info("# Command = " + aArg); + return new Promise(resolve => { + assert(!!ac, "Audio channel doesn't exist!"); + info("# Command = " + aArg); - testFrame.src = fileURL + '#' + aArg; - var expectedActive = false; - switch (aArg) { - case 'play': - expectedActive = true; - break; - case 'pause': - expectedActive = false; - break; - default : - error("Undefined command!"); - } - - ac.onactivestatechanged = () => { - ac.onactivestatechanged = null; - ac.isActive().onsuccess = (e) => { - is(expectedActive, e.target.result, - "Correct active state = " + expectedActive); - continueTest(); + testFrame.src = fileURL + '#' + aArg; + var expectedActive = false; + switch (aArg) { + case 'play': + expectedActive = true; + break; + case 'pause': + expectedActive = false; + break; + default : + error("Undefined command!"); } - }; + + ac.onactivestatechanged = () => { + ac.onactivestatechanged = null; + ac.isActive().onsuccess = (e) => { + is(expectedActive, e.target.result, + "Correct active state = " + expectedActive); + resolve(); + }; + }; + }); } -function runTests() { - setCommand('play'); - yield undefined; +async function runTests() { + await setCommand('play'); - setCommand('pause'); - yield undefined; + await setCommand('pause'); finish(); - yield undefined; } function setupTestFrame() { @@ -74,7 +64,6 @@ function setupTestFrame() { testFrame.src = fileURL; function loadend() { - testFrame.removeEventListener('mozbrowserloadend', loadend); ok("allowedAudioChannels" in testFrame, "allowedAudioChannels exist"); var channels = testFrame.allowedAudioChannels; is(channels.length, 9, "9 audio channel by default"); @@ -85,7 +74,7 @@ function setupTestFrame() { ok("isActive" in ac, "isActive exists"); ok("onactivestatechanged" in ac, "onactivestatechanged exists"); - generator.next(); + runTests(); } function alertError(e) { @@ -94,7 +83,7 @@ function setupTestFrame() { error(message); } - testFrame.addEventListener('mozbrowserloadend', loadend); + testFrame.addEventListener('mozbrowserloadend', loadend, {once: true}); testFrame.addEventListener('mozbrowsershowmodalprompt', alertError); document.body.appendChild(testFrame); } diff --git a/dom/browser-element/mochitest/browserElement_AudioChannelSeeking.js b/dom/browser-element/mochitest/browserElement_AudioChannelSeeking.js index f354a9d82e68..796d17d41cc3 100644 --- a/dom/browser-element/mochitest/browserElement_AudioChannelSeeking.js +++ b/dom/browser-element/mochitest/browserElement_AudioChannelSeeking.js @@ -32,11 +32,7 @@ function error(aMessage) { } function continueTest() { - try { - generator.next(); - } catch (e if e instanceof StopIteration) { - error("Stop test because of exception!"); - } + generator.next(); } function finish() { @@ -74,7 +70,7 @@ function setCommand(aArg) { } } -function runTests() { +function* runTests() { setCommand('play'); yield undefined; @@ -91,7 +87,6 @@ function runTests() { yield undefined; finish(); - yield undefined; } function setupTestFrame() { diff --git a/dom/browser-element/mochitest/browserElement_NoAudioTrack.js b/dom/browser-element/mochitest/browserElement_NoAudioTrack.js index 47f0fd5244d4..32fcfb6e95ff 100644 --- a/dom/browser-element/mochitest/browserElement_NoAudioTrack.js +++ b/dom/browser-element/mochitest/browserElement_NoAudioTrack.js @@ -25,11 +25,7 @@ function error(aMessage) { } function continueTest() { - try { - generator.next(); - } catch (e if e instanceof StopIteration) { - error("Stop test because of exception!"); - } + generator.next(); } function finish() { @@ -45,7 +41,7 @@ function setCommand(aArg) { testFrame.src = fileURL + '#' + aArg; } -function runTests() { +function* runTests() { setCommand('play'); yield undefined; @@ -54,7 +50,6 @@ function runTests() { yield undefined; finish(); - yield undefined; } function setupTestFrame() { diff --git a/dom/devicestorage/test/test_app_permissions.html b/dom/devicestorage/test/test_app_permissions.html index 528d3e9832ae..aaa834388f70 100644 --- a/dom/devicestorage/test/test_app_permissions.html +++ b/dom/devicestorage/test/test_app_permissions.html @@ -432,7 +432,7 @@ function testComplete(iframe, data) { } } -function runTest() { +function* runTest() { while (gData.length > 0) { var iframe = document.createElement('iframe'); var data = gData.pop(); diff --git a/dom/devicestorage/test/test_fs_app_permissions.html b/dom/devicestorage/test/test_fs_app_permissions.html index ac4db92b6b79..32ccf5382d98 100644 --- a/dom/devicestorage/test/test_fs_app_permissions.html +++ b/dom/devicestorage/test/test_fs_app_permissions.html @@ -550,7 +550,7 @@ function testComplete(iframe, data) { } } -function runTest() { +function* runTest() { while (gData.length > 0) { let iframe = document.createElement('iframe'); let data = gData.shift(); diff --git a/dom/events/test/bug426082.html b/dom/events/test/bug426082.html index 8eaaa7391a44..90c95575978e 100644 --- a/dom/events/test/bug426082.html +++ b/dom/events/test/bug426082.html @@ -61,19 +61,20 @@ var gNeedsPaint = false; function executeTests() { var testYielder = tests(); function execNext() { - try { - if (!gNeedsPaint) { - testYielder.next(); - button.getBoundingClientRect(); // Flush. - gNeedsPaint = true; + if (!gNeedsPaint) { + let {done} = testYielder.next(); + if (done) { + return; } - SimpleTest.executeSoon(execNext); - } catch (e) {} + button.getBoundingClientRect(); // Flush. + gNeedsPaint = true; + } + SimpleTest.executeSoon(execNext); } execNext(); } -function tests() { +function* tests() { window.addEventListener("MozAfterPaint", paintListener, false); normalButtonCanvas = takeSnapshot(); // Press the button. diff --git a/dom/events/test/bug656379-1.html b/dom/events/test/bug656379-1.html index d7a04e3bfbf6..a6e94e5b67b4 100644 --- a/dom/events/test/bug656379-1.html +++ b/dom/events/test/bug656379-1.html @@ -77,19 +77,20 @@ var gNeedsPaint = false; function executeTests() { var testYielder = tests(); function execNext() { - try { - if (!gNeedsPaint) { - testYielder.next(); - button.getBoundingClientRect(); // Flush. - gNeedsPaint = true; + if (!gNeedsPaint) { + let {done} = testYielder.next(); + if (done) { + return; } - SimpleTest.executeSoon(execNext); - } catch (e) {} + button.getBoundingClientRect(); // Flush. + gNeedsPaint = true; + } + SimpleTest.executeSoon(execNext); } execNext(); } -function tests() { +function* tests() { window.addEventListener("MozAfterPaint", paintListener, false); normalButtonCanvas = takeSnapshot(); // Press the button. diff --git a/dom/events/test/test_bug415498.xul b/dom/events/test/test_bug415498.xul index 009431cb1400..70d19828654d 100644 --- a/dom/events/test/test_bug415498.xul +++ b/dom/events/test/test_bug415498.xul @@ -52,12 +52,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=415498 } function nextTest() { - try { - gTestsIterator.next(); - } catch (err) { - ok(err instanceof StopIteration, - "Some other exception was thrown than what we expected!"); - + let {done} = gTestsIterator.next(); + if (done) { if (gConsole && gConsoleListener) { gConsole.unregisterListener(gConsoleListener); } @@ -65,7 +61,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=415498 } } - function testsIterator() { + function* testsIterator() { var browser = $("browser"); browser.addEventListener("load", function() { diff --git a/dom/events/test/test_bug656379-2.html b/dom/events/test/test_bug656379-2.html index d53abce41e6f..40e62fc66434 100644 --- a/dom/events/test/test_bug656379-2.html +++ b/dom/events/test/test_bug656379-2.html @@ -30,7 +30,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=656379 /** Test for Bug 656379 **/ SimpleTest.waitForExplicitFinish(); -function tests() { +function* tests() { synthesizeMouseAtCenter($("label1"), { type: "mousemove" }); yield undefined; is($("button1").matches(":hover"), true, @@ -67,10 +67,11 @@ function tests() { function executeTests() { var testYielder = tests(); function execNext() { - try { - testYielder.next(); - SimpleTest.executeSoon(execNext); - } catch(e) {} + let {done} = testYielder.next(); + if (done) { + return; + } + SimpleTest.executeSoon(execNext); } execNext(); } diff --git a/dom/file/tests/test_mozfiledataurl.html b/dom/file/tests/test_mozfiledataurl.html index b842336d8de0..9596550de1d7 100644 --- a/dom/file/tests/test_mozfiledataurl.html +++ b/dom/file/tests/test_mozfiledataurl.html @@ -10,8 +10,8 @@

- -