diff --git a/js/xpconnect/tests/unit/head_watchdog.js b/js/xpconnect/tests/unit/head_watchdog.js index cf006303aae8..87ec5de76910 100644 --- a/js/xpconnect/tests/unit/head_watchdog.js +++ b/js/xpconnect/tests/unit/head_watchdog.js @@ -95,18 +95,14 @@ function checkWatchdog(expectInterrupt, continuation) { }); } -var gGenerator; -function continueTest() { - gGenerator.next(); -} - function run_test() { // Run async. do_test_pending(); - // Instantiate the generator and kick it off. - gGenerator = testBody(); - gGenerator.next(); + // Run the async function. + testBody().then(() => { + do_test_finished(); + }); } diff --git a/js/xpconnect/tests/unit/test_watchdog_default.js b/js/xpconnect/tests/unit/test_watchdog_default.js index d5dac7b6aeaf..75e8f0e7632b 100644 --- a/js/xpconnect/tests/unit/test_watchdog_default.js +++ b/js/xpconnect/tests/unit/test_watchdog_default.js @@ -2,11 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -function testBody() { +async function testBody() { // Check that we properly implement whatever behavior is specified by the // default profile for this configuration. - checkWatchdog(isWatchdogEnabled(), continueTest); - yield; - do_test_finished(); - yield; + await checkWatchdog(isWatchdogEnabled()); } diff --git a/js/xpconnect/tests/unit/test_watchdog_disable.js b/js/xpconnect/tests/unit/test_watchdog_disable.js index dcdf21ce4656..45837dabaf5b 100644 --- a/js/xpconnect/tests/unit/test_watchdog_disable.js +++ b/js/xpconnect/tests/unit/test_watchdog_disable.js @@ -2,10 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -function testBody() { +async function testBody() { setWatchdogEnabled(false); - checkWatchdog(false, continueTest); - yield; - do_test_finished(); - yield; + await checkWatchdog(false); } diff --git a/js/xpconnect/tests/unit/test_watchdog_enable.js b/js/xpconnect/tests/unit/test_watchdog_enable.js index 8e31e1316928..234e7d76a49c 100644 --- a/js/xpconnect/tests/unit/test_watchdog_enable.js +++ b/js/xpconnect/tests/unit/test_watchdog_enable.js @@ -2,10 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -function testBody() { +async function testBody() { setWatchdogEnabled(true); - checkWatchdog(true, continueTest); - yield; - do_test_finished(); - yield; + await checkWatchdog(true); } diff --git a/js/xpconnect/tests/unit/test_watchdog_hibernate.js b/js/xpconnect/tests/unit/test_watchdog_hibernate.js index ce36429632f9..15d2014ed65e 100644 --- a/js/xpconnect/tests/unit/test_watchdog_hibernate.js +++ b/js/xpconnect/tests/unit/test_watchdog_hibernate.js @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -function testBody() { +async function testBody() { setWatchdogEnabled(true); @@ -23,10 +23,11 @@ function testBody() { // scheduling, we should never have more than 3 seconds of inactivity without // hibernating. To add some padding for automation, we mandate that hibernation // must begin between 2 and 5 seconds from now. - var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); - timer.initWithCallback(continueTest, 10000, Ci.nsITimer.TYPE_ONE_SHOT); - simulateActivityCallback(false); - yield; + await new Promise(resolve => { + var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); + timer.initWithCallback(resolve, 10000, Ci.nsITimer.TYPE_ONE_SHOT); + simulateActivityCallback(false); + }); simulateActivityCallback(true); busyWait(1000); // Give the watchdog time to wake up on the condvar. @@ -47,7 +48,4 @@ function testBody() { do_check_true(startHibernation > now + 2*1000*1000 - FUZZ_FACTOR); do_check_true(startHibernation < now + 5*1000*1000 + FUZZ_FACTOR); do_check_true(stopHibernation > now + 10*1000*1000 - FUZZ_FACTOR); - - do_test_finished(); - yield; } diff --git a/js/xpconnect/tests/unit/test_watchdog_toggle.js b/js/xpconnect/tests/unit/test_watchdog_toggle.js index f0d14c2dfe86..1b2c90df9d03 100644 --- a/js/xpconnect/tests/unit/test_watchdog_toggle.js +++ b/js/xpconnect/tests/unit/test_watchdog_toggle.js @@ -2,12 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -function testBody() { +async function testBody() { var defaultBehavior = isWatchdogEnabled(); setWatchdogEnabled(!defaultBehavior); setWatchdogEnabled(defaultBehavior); - checkWatchdog(defaultBehavior, continueTest); - yield; - do_test_finished(); - yield; + await checkWatchdog(defaultBehavior); }