Bug 1596114 - Refactor server unit tests part1 r=bhackett,jlast
authorchujun <chujunlu@hotmail.com>
Wed, 11 Dec 2019 16:13:18 +0000
changeset 506498 d74eec46c4ea1c3d7f287c359b51404425894ec5
parent 506497 df896e0907c044975ec2ddf4b0e168a242f1b343
child 506499 78b04bb8a18beb1fdaca10f1e113e6567a6051bb
push id36905
push userdluca@mozilla.com
push dateWed, 11 Dec 2019 21:46:29 +0000
treeherdermozilla-central@d74eec46c4ea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett, jlast
bugs1596114
milestone73.0a1
first release with
nightly linux32
d74eec46c4ea / 73.0a1 / 20191211214629 / files
nightly linux64
d74eec46c4ea / 73.0a1 / 20191211214629 / files
nightly mac
d74eec46c4ea / 73.0a1 / 20191211214629 / files
nightly win32
d74eec46c4ea / 73.0a1 / 20191211214629 / files
nightly win64
d74eec46c4ea / 73.0a1 / 20191211214629 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1596114 - Refactor server unit tests part1 r=bhackett,jlast I refactored some of the unit tests to see if I'm on the right direction. If so, I'll continue with other unit tests. Differential Revision: https://phabricator.services.mozilla.com/D55923
devtools/server/tests/unit/test_breakpoint-09.js
devtools/server/tests/unit/test_dbgactor.js
devtools/server/tests/unit/test_dbgclient_debuggerstatement.js
devtools/server/tests/unit/test_objectgrips-01.js
devtools/server/tests/unit/test_objectgrips-02.js
devtools/server/tests/unit/test_objectgrips-03.js
devtools/server/tests/unit/test_objectgrips-04.js
devtools/server/tests/unit/test_objectgrips-05.js
devtools/server/tests/unit/test_objectgrips-06.js
devtools/server/tests/unit/test_objectgrips-07.js
devtools/server/tests/unit/test_objectgrips-08.js
devtools/server/tests/unit/test_objectgrips-10.js
devtools/server/tests/unit/test_objectgrips-11.js
devtools/server/tests/unit/test_objectgrips-12.js
devtools/server/tests/unit/test_objectgrips-13.js
devtools/server/tests/unit/test_objectgrips-16.js
devtools/server/tests/unit/test_objectgrips-17.js
devtools/server/tests/unit/test_objectgrips-18.js
devtools/server/tests/unit/test_objectgrips-19.js
devtools/server/tests/unit/test_objectgrips-20.js
devtools/server/tests/unit/test_objectgrips-21.js
devtools/server/tests/unit/test_objectgrips-22.js
devtools/server/tests/unit/test_objectgrips-23.js
--- a/devtools/server/tests/unit/test_breakpoint-09.js
+++ b/devtools/server/tests/unit/test_breakpoint-09.js
@@ -58,16 +58,16 @@ function evaluateTestCode(debuggee) {
   /* eslint-disable */
       Cu.evalInSandbox("var line0 = Error().lineNumber;\n" +
                        "function foo(stop) {\n" + // line0 + 1
                        "  this.a = 1;\n" +        // line0 + 2
                        "  if (stop) return;\n" +  // line0 + 3
                        "  delete this.a;\n" +     // line0 + 4
                        "  foo(true);\n" +         // line0 + 5
                        "}\n" +                    // line0 + 6
-                       "debugger;\n" +            // line1 + 7
-                       "foo();\n",                // line1 + 8
+                       "debugger;\n" +            // line0 + 7
+                       "foo();\n",                // line0 + 8
                        debuggee);
       /* eslint-enable */
   if (!done) {
     Assert.ok(false);
   }
 }
--- a/devtools/server/tests/unit/test_dbgactor.js
+++ b/devtools/server/tests/unit/test_dbgactor.js
@@ -3,41 +3,44 @@
 
 "use strict";
 
 const xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(
   Ci.nsIJSInspector
 );
 
 add_task(
-  threadFrontTest(async ({ threadFront, debuggee, targetFront }) => {
+  threadFrontTest(async ({ threadFront, debuggee }) => {
     Assert.equal(xpcInspector.eventLoopNestLevel, 0);
 
-    await new Promise(resolve => {
-      threadFront.on("paused", function(packet) {
-        Assert.equal(false, "error" in packet);
-        Assert.ok("actor" in packet);
-        Assert.ok("why" in packet);
-        Assert.equal(packet.why.type, "debuggerStatement");
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
 
-        // Reach around the protocol to check that the debuggee is in the state
-        // we expect.
-        Assert.ok(debuggee.a);
-        Assert.ok(!debuggee.b);
+    Assert.equal(false, "error" in packet);
+    Assert.ok("actor" in packet);
+    Assert.ok("why" in packet);
+    Assert.equal(packet.why.type, "debuggerStatement");
 
-        Assert.equal(xpcInspector.eventLoopNestLevel, 1);
-
-        // Let the debuggee continue execution.
-        threadFront.resume().then(resolve);
-      });
+    // Reach around the protocol to check that the debuggee is in the state
+    // we expect.
+    Assert.ok(debuggee.a);
+    Assert.ok(!debuggee.b);
 
-      // Now that we know we're resumed, we can make the debuggee do something.
-      Cu.evalInSandbox(
-        "var a = true; var b = false; debugger; var b = true;",
-        debuggee
-      );
-      // Now make sure that we've run the code after the debugger statement...
-      Assert.ok(debuggee.b);
-    });
+    Assert.equal(xpcInspector.eventLoopNestLevel, 1);
+
+    // Let the debuggee continue execution.
+    await threadFront.resume();
+
+    // Now make sure that we've run the code after the debugger statement...
+    Assert.ok(debuggee.b);
 
     Assert.equal(xpcInspector.eventLoopNestLevel, 0);
   })
 );
+
+function evalCode(debuggee) {
+  Cu.evalInSandbox(
+    "var a = true; var b = false; debugger; var b = true;",
+    debuggee
+  );
+}
--- a/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js
+++ b/devtools/server/tests/unit/test_dbgclient_debuggerstatement.js
@@ -3,34 +3,37 @@
 
 "use strict";
 
 const xpcInspector = Cc["@mozilla.org/jsinspector;1"].getService(
   Ci.nsIJSInspector
 );
 
 add_task(
-  threadFrontTest(async ({ threadFront, debuggee, client, targetFront }) => {
-    await new Promise(resolve => {
-      threadFront.on("paused", function(packet) {
-        Assert.equal(threadFront.state, "paused");
-        // Reach around the protocol to check that the debuggee is in the state
-        // we expect.
-        Assert.ok(debuggee.a);
-        Assert.ok(!debuggee.b);
-
-        Assert.equal(xpcInspector.eventLoopNestLevel, 1);
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
 
-        threadFront.resume().then(resolve);
-      });
+    Assert.equal(threadFront.state, "paused");
+    // Reach around the protocol to check that the debuggee is in the state
+    // we expect.
+    Assert.ok(debuggee.a);
+    Assert.ok(!debuggee.b);
 
-      Cu.evalInSandbox(
-        "var a = true; var b = false; debugger; var b = true;",
-        debuggee
-      );
+    Assert.equal(xpcInspector.eventLoopNestLevel, 1);
 
-      // Now make sure that we've run the code after the debugger statement...
-      Assert.ok(debuggee.b);
-    });
+    await threadFront.resume();
+
+    // Now make sure that we've run the code after the debugger statement...
+    Assert.ok(debuggee.b);
 
     Assert.equal(xpcInspector.eventLoopNestLevel, 0);
   })
 );
+
+function evalCode(debuggee) {
+  Cu.evalInSandbox(
+    "var a = true; var b = false; debugger; var b = true;",
+    debuggee
+  );
+}
--- a/devtools/server/tests/unit/test_objectgrips-01.js
+++ b/devtools/server/tests/unit/test_objectgrips-01.js
@@ -4,35 +4,37 @@
 "use strict";
 
 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
 });
 
 add_task(
-  threadFrontTest(async ({ threadFront, debuggee, client }) => {
-    return new Promise(resolve => {
-      threadFront.once("paused", async function(packet) {
-        const args = packet.frame.arguments;
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
 
-        Assert.equal(args[0].class, "Object");
+    const args = packet.frame.arguments;
 
-        const objClient = threadFront.pauseGrip(args[0]);
-        const response = await objClient.getOwnPropertyNames();
-        Assert.equal(response.ownPropertyNames.length, 3);
-        Assert.equal(response.ownPropertyNames[0], "a");
-        Assert.equal(response.ownPropertyNames[1], "b");
-        Assert.equal(response.ownPropertyNames[2], "c");
+    Assert.equal(args[0].class, "Object");
 
-        await threadFront.resume();
-        resolve();
-      });
+    const objClient = threadFront.pauseGrip(args[0]);
+    const response = await objClient.getOwnPropertyNames();
+    Assert.equal(response.ownPropertyNames.length, 3);
+    Assert.equal(response.ownPropertyNames[0], "a");
+    Assert.equal(response.ownPropertyNames[1], "b");
+    Assert.equal(response.ownPropertyNames[2], "c");
 
-      debuggee.eval(
-        function stopMe(arg1) {
-          debugger;
-        }.toString()
-      );
-      debuggee.eval("stopMe({ a: 1, b: true, c: 'foo' })");
-    });
+    await threadFront.resume();
   })
 );
+
+function evalCode(debuggee) {
+  debuggee.eval(
+    function stopMe(arg1) {
+      debugger;
+    }.toString()
+  );
+  debuggee.eval("stopMe({ a: 1, b: true, c: 'foo' })");
+}
--- a/devtools/server/tests/unit/test_objectgrips-02.js
+++ b/devtools/server/tests/unit/test_objectgrips-02.js
@@ -5,45 +5,47 @@
 "use strict";
 
 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
 });
 
 add_task(
-  threadFrontTest(async ({ threadFront, debuggee, client }) => {
-    return new Promise(resolve => {
-      threadFront.once("paused", async function(packet) {
-        const args = packet.frame.arguments;
-
-        Assert.equal(args[0].class, "Object");
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
 
-        const objectFront = threadFront.pauseGrip(args[0]);
-        const response = await objectFront.getPrototype();
-        Assert.ok(response.prototype != undefined);
+    const args = packet.frame.arguments;
 
-        const protoFront = response.prototype;
-        const { ownPropertyNames } = await protoFront.getOwnPropertyNames();
-        Assert.equal(ownPropertyNames.length, 2);
-        Assert.equal(ownPropertyNames[0], "b");
-        Assert.equal(ownPropertyNames[1], "c");
+    Assert.equal(args[0].class, "Object");
 
-        await threadFront.resume();
-        resolve();
-      });
+    const objectFront = threadFront.pauseGrip(args[0]);
+    const response = await objectFront.getPrototype();
+    Assert.ok(response.prototype != undefined);
 
-      debuggee.eval(
-        function stopMe(arg1) {
-          debugger;
-        }.toString()
-      );
-      debuggee.eval(
-        function Constr() {
-          this.a = 1;
-        }.toString()
-      );
-      debuggee.eval(
-        "Constr.prototype = { b: true, c: 'foo' }; var o = new Constr(); stopMe(o)"
-      );
-    });
+    const protoFront = response.prototype;
+    const { ownPropertyNames } = await protoFront.getOwnPropertyNames();
+    Assert.equal(ownPropertyNames.length, 2);
+    Assert.equal(ownPropertyNames[0], "b");
+    Assert.equal(ownPropertyNames[1], "c");
+
+    await threadFront.resume();
   })
 );
+
+function evalCode(debuggee) {
+  debuggee.eval(
+    function stopMe(arg1) {
+      debugger;
+    }.toString()
+  );
+  debuggee.eval(
+    function Constr() {
+      this.a = 1;
+    }.toString()
+  );
+  debuggee.eval(
+    "Constr.prototype = { b: true, c: 'foo' }; var o = new Constr(); stopMe(o)"
+  );
+}
--- a/devtools/server/tests/unit/test_objectgrips-03.js
+++ b/devtools/server/tests/unit/test_objectgrips-03.js
@@ -5,48 +5,49 @@
 "use strict";
 
 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
 });
 
 add_task(
-  threadFrontTest(async ({ threadFront, debuggee, client }) => {
-    return new Promise(resolve => {
-      threadFront.once("paused", async function(packet) {
-        const args = packet.frame.arguments;
-
-        Assert.equal(args[0].class, "Object");
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
+    const args = packet.frame.arguments;
 
-        const objClient = threadFront.pauseGrip(args[0]);
-        let response = await objClient.getProperty("x");
-        Assert.equal(response.descriptor.configurable, true);
-        Assert.equal(response.descriptor.enumerable, true);
-        Assert.equal(response.descriptor.writable, true);
-        Assert.equal(response.descriptor.value, 10);
+    Assert.equal(args[0].class, "Object");
 
-        response = await objClient.getProperty("y");
-        Assert.equal(response.descriptor.configurable, true);
-        Assert.equal(response.descriptor.enumerable, true);
-        Assert.equal(response.descriptor.writable, true);
-        Assert.equal(response.descriptor.value, "kaiju");
+    const objClient = threadFront.pauseGrip(args[0]);
+    let response = await objClient.getProperty("x");
+    Assert.equal(response.descriptor.configurable, true);
+    Assert.equal(response.descriptor.enumerable, true);
+    Assert.equal(response.descriptor.writable, true);
+    Assert.equal(response.descriptor.value, 10);
 
-        response = await objClient.getProperty("a");
-        Assert.equal(response.descriptor.configurable, true);
-        Assert.equal(response.descriptor.enumerable, true);
-        Assert.equal(response.descriptor.get.type, "object");
-        Assert.equal(response.descriptor.get.class, "Function");
-        Assert.equal(response.descriptor.set.type, "undefined");
+    response = await objClient.getProperty("y");
+    Assert.equal(response.descriptor.configurable, true);
+    Assert.equal(response.descriptor.enumerable, true);
+    Assert.equal(response.descriptor.writable, true);
+    Assert.equal(response.descriptor.value, "kaiju");
 
-        await threadFront.resume();
-        resolve();
-      });
+    response = await objClient.getProperty("a");
+    Assert.equal(response.descriptor.configurable, true);
+    Assert.equal(response.descriptor.enumerable, true);
+    Assert.equal(response.descriptor.get.type, "object");
+    Assert.equal(response.descriptor.get.class, "Function");
+    Assert.equal(response.descriptor.set.type, "undefined");
 
-      debuggee.eval(
-        function stopMe(arg1) {
-          debugger;
-        }.toString()
-      );
-      debuggee.eval("stopMe({ x: 10, y: 'kaiju', get a() { return 42; } })");
-    });
+    await threadFront.resume();
   })
 );
+
+function evalCode(debuggee) {
+  debuggee.eval(
+    function stopMe(arg1) {
+      debugger;
+    }.toString()
+  );
+  debuggee.eval("stopMe({ x: 10, y: 'kaiju', get a() { return 42; } })");
+}
--- a/devtools/server/tests/unit/test_objectgrips-04.js
+++ b/devtools/server/tests/unit/test_objectgrips-04.js
@@ -5,54 +5,56 @@
 "use strict";
 
 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
 });
 
 add_task(
-  threadFrontTest(async ({ threadFront, debuggee, client }) => {
-    return new Promise(resolve => {
-      threadFront.once("paused", async function(packet) {
-        const args = packet.frame.arguments;
-
-        Assert.equal(args[0].class, "Object");
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
 
-        const objectFront = threadFront.pauseGrip(args[0]);
-        const {
-          ownProperties,
-          prototype,
-        } = await objectFront.getPrototypeAndProperties();
-        Assert.equal(ownProperties.x.configurable, true);
-        Assert.equal(ownProperties.x.enumerable, true);
-        Assert.equal(ownProperties.x.writable, true);
-        Assert.equal(ownProperties.x.value, 10);
+    const args = packet.frame.arguments;
 
-        Assert.equal(ownProperties.y.configurable, true);
-        Assert.equal(ownProperties.y.enumerable, true);
-        Assert.equal(ownProperties.y.writable, true);
-        Assert.equal(ownProperties.y.value, "kaiju");
+    Assert.equal(args[0].class, "Object");
 
-        Assert.equal(ownProperties.a.configurable, true);
-        Assert.equal(ownProperties.a.enumerable, true);
-        Assert.equal(ownProperties.a.get.getGrip().type, "object");
-        Assert.equal(ownProperties.a.get.getGrip().class, "Function");
-        Assert.equal(ownProperties.a.set.type, "undefined");
-
-        Assert.ok(prototype != undefined);
-
-        const { ownPropertyNames } = await prototype.getOwnPropertyNames();
-        Assert.ok(ownPropertyNames.toString != undefined);
+    const objectFront = threadFront.pauseGrip(args[0]);
+    const {
+      ownProperties,
+      prototype,
+    } = await objectFront.getPrototypeAndProperties();
+    Assert.equal(ownProperties.x.configurable, true);
+    Assert.equal(ownProperties.x.enumerable, true);
+    Assert.equal(ownProperties.x.writable, true);
+    Assert.equal(ownProperties.x.value, 10);
 
-        await threadFront.resume();
-        resolve();
-      });
+    Assert.equal(ownProperties.y.configurable, true);
+    Assert.equal(ownProperties.y.enumerable, true);
+    Assert.equal(ownProperties.y.writable, true);
+    Assert.equal(ownProperties.y.value, "kaiju");
 
-      debuggee.eval(
-        function stopMe(arg1) {
-          debugger;
-        }.toString()
-      );
-      debuggee.eval("stopMe({ x: 10, y: 'kaiju', get a() { return 42; } })");
-    });
+    Assert.equal(ownProperties.a.configurable, true);
+    Assert.equal(ownProperties.a.enumerable, true);
+    Assert.equal(ownProperties.a.get.getGrip().type, "object");
+    Assert.equal(ownProperties.a.get.getGrip().class, "Function");
+    Assert.equal(ownProperties.a.set.type, "undefined");
+
+    Assert.ok(prototype != undefined);
+
+    const { ownPropertyNames } = await prototype.getOwnPropertyNames();
+    Assert.ok(ownPropertyNames.toString != undefined);
+
+    await threadFront.resume();
   })
 );
+
+function evalCode(debuggee) {
+  debuggee.eval(
+    function stopMe(arg1) {
+      debugger;
+    }.toString()
+  );
+  debuggee.eval("stopMe({ x: 10, y: 'kaiju', get a() { return 42; } })");
+}
--- a/devtools/server/tests/unit/test_objectgrips-05.js
+++ b/devtools/server/tests/unit/test_objectgrips-05.js
@@ -9,46 +9,48 @@
  */
 
 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
 });
 
 add_task(
-  threadFrontTest(async ({ threadFront, debuggee, client }) => {
-    return new Promise(resolve => {
-      threadFront.once("paused", async function(packet) {
-        const obj1 = packet.frame.arguments[0];
-        Assert.ok(obj1.frozen);
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
 
-        const obj1Client = threadFront.pauseGrip(obj1);
-        Assert.ok(obj1Client.isFrozen);
-
-        const obj2 = packet.frame.arguments[1];
-        Assert.ok(!obj2.frozen);
-
-        const obj2Client = threadFront.pauseGrip(obj2);
-        Assert.ok(!obj2Client.isFrozen);
+    const obj1 = packet.frame.arguments[0];
+    Assert.ok(obj1.frozen);
 
-        await threadFront.resume();
-        resolve();
-      });
+    const obj1Client = threadFront.pauseGrip(obj1);
+    Assert.ok(obj1Client.isFrozen);
 
-      debuggee.eval(
-        function stopMe(arg1) {
-          debugger;
-        }.toString()
-      );
-      /* eslint-disable no-undef */
-      debuggee.eval(
-        "(" +
-          function() {
-            const obj1 = {};
-            Object.freeze(obj1);
-            stopMe(obj1, {});
-          } +
-          "())"
-      );
-      /* eslint-enable no-undef */
-    });
+    const obj2 = packet.frame.arguments[1];
+    Assert.ok(!obj2.frozen);
+
+    const obj2Client = threadFront.pauseGrip(obj2);
+    Assert.ok(!obj2Client.isFrozen);
+
+    await threadFront.resume();
   })
 );
+
+function evalCode(debuggee) {
+  debuggee.eval(
+    function stopMe(arg1) {
+      debugger;
+    }.toString()
+  );
+  /* eslint-disable no-undef */
+  debuggee.eval(
+    "(" +
+      function() {
+        const obj1 = {};
+        Object.freeze(obj1);
+        stopMe(obj1, {});
+      } +
+      "())"
+  );
+  /* eslint-enable no-undef */
+}
--- a/devtools/server/tests/unit/test_objectgrips-06.js
+++ b/devtools/server/tests/unit/test_objectgrips-06.js
@@ -9,46 +9,48 @@
  */
 
 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
 });
 
 add_task(
-  threadFrontTest(async ({ threadFront, debuggee, client }) => {
-    return new Promise(resolve => {
-      threadFront.once("paused", async function(packet) {
-        const obj1 = packet.frame.arguments[0];
-        Assert.ok(obj1.sealed);
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
 
-        const obj1Client = threadFront.pauseGrip(obj1);
-        Assert.ok(obj1Client.isSealed);
-
-        const obj2 = packet.frame.arguments[1];
-        Assert.ok(!obj2.sealed);
-
-        const obj2Client = threadFront.pauseGrip(obj2);
-        Assert.ok(!obj2Client.isSealed);
+    const obj1 = packet.frame.arguments[0];
+    Assert.ok(obj1.sealed);
 
-        await threadFront.resume();
-        resolve();
-      });
+    const obj1Client = threadFront.pauseGrip(obj1);
+    Assert.ok(obj1Client.isSealed);
 
-      debuggee.eval(
-        function stopMe(arg1) {
-          debugger;
-        }.toString()
-      );
-      /* eslint-disable no-undef */
-      debuggee.eval(
-        "(" +
-          function() {
-            const obj1 = {};
-            Object.seal(obj1);
-            stopMe(obj1, {});
-          } +
-          "())"
-      );
-      /* eslint-enable no-undef */
-    });
+    const obj2 = packet.frame.arguments[1];
+    Assert.ok(!obj2.sealed);
+
+    const obj2Client = threadFront.pauseGrip(obj2);
+    Assert.ok(!obj2Client.isSealed);
+
+    await threadFront.resume();
   })
 );
+
+function evalCode(debuggee) {
+  debuggee.eval(
+    function stopMe(arg1) {
+      debugger;
+    }.toString()
+  );
+  /* eslint-disable no-undef */
+  debuggee.eval(
+    "(" +
+      function() {
+        const obj1 = {};
+        Object.seal(obj1);
+        stopMe(obj1, {});
+      } +
+      "())"
+  );
+  /* eslint-enable no-undef */
+}
--- a/devtools/server/tests/unit/test_objectgrips-07.js
+++ b/devtools/server/tests/unit/test_objectgrips-07.js
@@ -9,58 +9,57 @@
  */
 
 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
 });
 
 add_task(
-  threadFrontTest(async ({ threadFront, debuggee, client }) => {
-    return new Promise(resolve => {
-      threadFront.once("paused", async function(packet) {
-        const [f, s, ne, e] = packet.frame.arguments;
-        const [
-          fClient,
-          sClient,
-          neClient,
-          eClient,
-        ] = packet.frame.arguments.map(a => threadFront.pauseGrip(a));
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
 
-        Assert.ok(!f.extensible);
-        Assert.ok(!fClient.isExtensible);
-
-        Assert.ok(!s.extensible);
-        Assert.ok(!sClient.isExtensible);
-
-        Assert.ok(!ne.extensible);
-        Assert.ok(!neClient.isExtensible);
-
-        Assert.ok(e.extensible);
-        Assert.ok(eClient.isExtensible);
+    const [f, s, ne, e] = packet.frame.arguments;
+    const [fClient, sClient, neClient, eClient] = packet.frame.arguments.map(
+      a => threadFront.pauseGrip(a)
+    );
 
-        await threadFront.resume();
-        resolve();
-      });
+    Assert.ok(!f.extensible);
+    Assert.ok(!fClient.isExtensible);
+
+    Assert.ok(!s.extensible);
+    Assert.ok(!sClient.isExtensible);
 
-      debuggee.eval(
-        function stopMe(arg1) {
-          debugger;
-        }.toString()
-      );
-      /* eslint-disable no-undef */
-      debuggee.eval(
-        "(" +
-          function() {
-            const f = {};
-            Object.freeze(f);
-            const s = {};
-            Object.seal(s);
-            const ne = {};
-            Object.preventExtensions(ne);
-            stopMe(f, s, ne, {});
-          } +
-          "())"
-      );
-      /* eslint-enable no-undef */
-    });
+    Assert.ok(!ne.extensible);
+    Assert.ok(!neClient.isExtensible);
+
+    Assert.ok(e.extensible);
+    Assert.ok(eClient.isExtensible);
+
+    await threadFront.resume();
   })
 );
+
+function evalCode(debuggee) {
+  debuggee.eval(
+    function stopMe(arg1) {
+      debugger;
+    }.toString()
+  );
+  /* eslint-disable no-undef */
+  debuggee.eval(
+    "(" +
+      function() {
+        const f = {};
+        Object.freeze(f);
+        const s = {};
+        Object.seal(s);
+        const ne = {};
+        Object.preventExtensions(ne);
+        stopMe(f, s, ne, {});
+      } +
+      "())"
+  );
+  /* eslint-enable no-undef */
+}
--- a/devtools/server/tests/unit/test_objectgrips-08.js
+++ b/devtools/server/tests/unit/test_objectgrips-08.js
@@ -5,53 +5,57 @@
 
 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
 });
 
 add_task(
   threadFrontTest(async ({ threadFront, debuggee }) => {
-    return new Promise(resolve => {
-      threadFront.once("paused", async function(packet) {
-        const args = packet.frame.arguments;
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
 
-        Assert.equal(args[0].class, "Object");
+    const args = packet.frame.arguments;
+
+    Assert.equal(args[0].class, "Object");
 
-        const objClient = threadFront.pauseGrip(args[0]);
-        const response = await objClient.getPrototypeAndProperties();
-        const { a, b, c, d, e, f, g } = response.ownProperties;
-        testPropertyType(a, "Infinity");
-        testPropertyType(b, "-Infinity");
-        testPropertyType(c, "NaN");
-        testPropertyType(d, "-0");
-        testPropertyType(e, "BigInt");
-        testPropertyType(f, "BigInt");
-        testPropertyType(g, "BigInt");
+    const objClient = threadFront.pauseGrip(args[0]);
+    const response = await objClient.getPrototypeAndProperties();
+    const { a, b, c, d, e, f, g } = response.ownProperties;
+    testPropertyType(a, "Infinity");
+    testPropertyType(b, "-Infinity");
+    testPropertyType(c, "NaN");
+    testPropertyType(d, "-0");
+    testPropertyType(e, "BigInt");
+    testPropertyType(f, "BigInt");
+    testPropertyType(g, "BigInt");
 
-        await threadFront.resume();
-        resolve();
-      });
+    await threadFront.resume();
+  })
+);
 
-      debuggee.eval(
-        function stopMe(arg1) {
-          debugger;
-        }.toString()
-      );
-      debuggee.eval(`stopMe({
+function evalCode(debuggee) {
+  debuggee.eval(
+    function stopMe(arg1) {
+      debugger;
+    }.toString()
+  );
+  debuggee.eval(
+    `stopMe({
       a: Infinity,
       b: -Infinity,
       c: NaN,
       d: -0,
       e: 1n,
       f: -2n,
       g: 0n,
-      })`);
-    });
-  })
-);
+    })`
+  );
+}
 
 function testPropertyType(prop, expectedType) {
   Assert.equal(prop.configurable, true);
   Assert.equal(prop.enumerable, true);
   Assert.equal(prop.writable, true);
   Assert.equal(prop.value.type, expectedType);
 }
--- a/devtools/server/tests/unit/test_objectgrips-10.js
+++ b/devtools/server/tests/unit/test_objectgrips-10.js
@@ -1,38 +1,29 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 /* eslint-disable no-shadow, max-nested-callbacks */
 
 "use strict";
 
-var gDebuggee;
-var gThreadFront;
-
 // Test that closures can be inspected.
 
 add_task(
-  threadFrontTest(
-    async ({ threadFront, debuggee }) => {
-      gThreadFront = threadFront;
-      gDebuggee = debuggee;
-      test_object_grip();
-    },
-    { waitForFinish: true }
-  )
-);
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
 
-function test_object_grip() {
-  gThreadFront.once("paused", async function(packet) {
     const environment = await packet.frame.getEnvironment();
     const person = environment.bindings.variables.person;
 
     Assert.equal(person.value.class, "Object");
 
-    const personFront = gThreadFront.pauseGrip(person.value);
+    const personFront = threadFront.pauseGrip(person.value);
     const { ownProperties } = await personFront.getPrototypeAndProperties();
     Assert.equal(ownProperties.getName.value.getGrip().class, "Function");
     Assert.equal(ownProperties.getAge.value.getGrip().class, "Function");
     Assert.equal(ownProperties.getFoo.value.getGrip().class, "Function");
 
     const getNameFront = ownProperties.getName.value;
     const getAgeFront = ownProperties.getAge.value;
     const getFooFront = ownProperties.getFoo.value;
@@ -44,22 +35,23 @@ function test_object_grip() {
     response = await getAgeFront.getScope();
     bindings = await response.scope.bindings();
     Assert.equal(bindings.arguments[1].age.value, 58);
 
     response = await getFooFront.getScope();
     bindings = await response.scope.bindings();
     Assert.equal(bindings.variables.foo.value, 10);
 
-    await gThreadFront.resume();
-    threadFrontTestFinished();
-  });
+    await threadFront.resume();
+  })
+);
 
+function evalCode(debuggee) {
   /* eslint-disable */
-  gDebuggee.eval(
+  debuggee.eval(
     "(" +
       function() {
         var PersonFactory = function(name, age) {
           var foo = 10;
           return {
             getName: function() {
               return name;
             },
--- a/devtools/server/tests/unit/test_objectgrips-11.js
+++ b/devtools/server/tests/unit/test_objectgrips-11.js
@@ -1,47 +1,38 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 // Test that we get the magic properties on Error objects.
 
-var gDebuggee;
-var gThreadFront;
-
 add_task(
-  threadFrontTest(
-    async ({ threadFront, debuggee }) => {
-      gThreadFront = threadFront;
-      gDebuggee = debuggee;
-      test_object_grip();
-    },
-    { waitForFinish: true }
-  )
-);
-
-function test_object_grip() {
-  gThreadFront.once("paused", async function(packet) {
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
     const args = packet.frame.arguments;
 
-    const objClient = gThreadFront.pauseGrip(args[0]);
+    const objClient = threadFront.pauseGrip(args[0]);
     const response = await objClient.getOwnPropertyNames();
     const opn = response.ownPropertyNames;
     Assert.equal(opn.length, 4);
     opn.sort();
     Assert.equal(opn[0], "columnNumber");
     Assert.equal(opn[1], "fileName");
     Assert.equal(opn[2], "lineNumber");
     Assert.equal(opn[3], "message");
 
-    await gThreadFront.resume();
-    threadFrontTestFinished();
-  });
+    await threadFront.resume();
+  })
+);
 
-  gDebuggee.eval(
+function evalCode(debuggee) {
+  debuggee.eval(
     function stopMe(arg1) {
       debugger;
     }.toString()
   );
 
-  gDebuggee.eval("stopMe(new TypeError('error message text'))");
+  debuggee.eval("stopMe(new TypeError('error message text'))");
 }
--- a/devtools/server/tests/unit/test_objectgrips-12.js
+++ b/devtools/server/tests/unit/test_objectgrips-12.js
@@ -9,27 +9,24 @@
 const { PromiseTestUtils } = ChromeUtils.import(
   "resource://testing-common/PromiseTestUtils.jsm"
 );
 
 var gDebuggee;
 var gThreadFront;
 
 add_task(
-  threadFrontTest(
-    async ({ threadFront, debuggee }) => {
-      gThreadFront = threadFront;
-      gDebuggee = debuggee;
-      test_display_string();
-    },
-    { waitForFinish: true }
-  )
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    gThreadFront = threadFront;
+    gDebuggee = debuggee;
+    await test_display_string();
+  })
 );
 
-function test_display_string() {
+async function test_display_string() {
   const testCases = [
     {
       input: "new Boolean(true)",
       output: "true",
     },
     {
       input: "new Number(5)",
       output: "5",
@@ -136,33 +133,35 @@ function test_display_string() {
     {
       input: "new Promise(function () {})",
       output: "Promise (pending)",
     },
   ];
 
   PromiseTestUtils.expectUncaughtRejection(/Error/);
 
-  gThreadFront.once("paused", function(packet) {
-    const args = packet.frame.arguments;
+  const inputs = testCases.map(({ input }) => input).join(",");
+
+  const packet = await executeOnNextTickAndWaitForPause(
+    () => evalCode(inputs),
+    gThreadFront
+  );
+
+  const args = packet.frame.arguments;
 
-    (async function loop() {
-      const objClient = gThreadFront.pauseGrip(args.pop());
-      const response = await objClient.getDisplayString();
-      Assert.equal(response.displayString, testCases.pop().output);
-      if (args.length) {
-        loop();
-      } else {
-        await gThreadFront.resume();
-        threadFrontTestFinished();
-      }
-    })();
-  });
+  while (args.length) {
+    const objClient = gThreadFront.pauseGrip(args.pop());
+    const response = await objClient.getDisplayString();
+    Assert.equal(response.displayString, testCases.pop().output);
+  }
 
+  await gThreadFront.resume();
+}
+
+function evalCode(inputs) {
   gDebuggee.eval(
     function stopMe(arg1) {
       debugger;
     }.toString()
   );
 
-  const inputs = testCases.map(({ input }) => input).join(",");
   gDebuggee.eval("stopMe(" + inputs + ")");
 }
--- a/devtools/server/tests/unit/test_objectgrips-13.js
+++ b/devtools/server/tests/unit/test_objectgrips-13.js
@@ -1,68 +1,51 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 // Test that ObjectFront.prototype.getDefinitionSite and the "definitionSite"
 // request work properly.
 
-var gDebuggee;
-var gThreadFront;
+add_task(
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
+    const [funcGrip, objGrip] = packet.frame.arguments;
+    const func = threadFront.pauseGrip(funcGrip);
+    const obj = threadFront.pauseGrip(objGrip);
 
-add_task(
-  threadFrontTest(
-    async ({ threadFront, debuggee }) => {
-      gThreadFront = threadFront;
-      gDebuggee = debuggee;
-      add_pause_listener();
-    },
-    { waitForFinish: true }
-  )
+    // test definition site
+    const response = await func.getDefinitionSite();
+    Assert.ok(!response.error);
+    Assert.equal(response.source.url, getFilePath("test_objectgrips-13.js"));
+    Assert.equal(response.line, debuggee.line0 + 1);
+    Assert.equal(response.column, 0);
+
+    // test bad definition site
+    try {
+      obj._client.request("definitionSite", () => Assert.ok(false));
+    } catch (e) {
+      threadFront.resume();
+    }
+  })
 );
 
-function add_pause_listener() {
-  gThreadFront.once("paused", function(packet) {
-    const [funcGrip, objGrip] = packet.frame.arguments;
-    const func = gThreadFront.pauseGrip(funcGrip);
-    const obj = gThreadFront.pauseGrip(objGrip);
-    test_definition_site(func, obj);
-  });
-
-  eval_code();
-}
-
-function eval_code() {
+function evalCode(debuggee) {
   Cu.evalInSandbox(
     function stopMe() {
       debugger;
     }.toString(),
-    gDebuggee
+    debuggee
   );
 
   Cu.evalInSandbox(
     [
       "this.line0 = Error().lineNumber;",
       "function f() {}",
       "stopMe(f, {});",
     ].join("\n"),
-    gDebuggee
+    debuggee
   );
 }
-
-async function test_definition_site(func, obj) {
-  const response = await func.getDefinitionSite();
-  Assert.ok(!response.error);
-  Assert.equal(response.source.url, getFilePath("test_objectgrips-13.js"));
-  Assert.equal(response.line, gDebuggee.line0 + 1);
-  Assert.equal(response.column, 0);
-
-  test_bad_definition_site(obj);
-}
-
-function test_bad_definition_site(obj) {
-  try {
-    obj._client.request("definitionSite", () => Assert.ok(false));
-  } catch (e) {
-    gThreadFront.resume().then(() => threadFrontTestFinished());
-  }
-}
--- a/devtools/server/tests/unit/test_objectgrips-16.js
+++ b/devtools/server/tests/unit/test_objectgrips-16.js
@@ -5,51 +5,52 @@
 "use strict";
 
 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
 });
 
 add_task(
-  threadFrontTest(async ({ threadFront, debuggee, client }) => {
-    return new Promise(resolve => {
-      threadFront.once("paused", async function(packet) {
-        const [grip] = packet.frame.arguments;
-
-        // Checks grip.preview properties.
-        check_preview(grip);
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    const packet = await executeOnNextTickAndWaitForPause(
+      eval_code,
+      threadFront
+    );
+    const [grip] = packet.frame.arguments;
 
-        const objClient = threadFront.pauseGrip(grip);
-        const response = await objClient.getPrototypeAndProperties();
-        // Checks the result of getPrototypeAndProperties.
-        check_prototype_and_properties(response);
+    // Checks grip.preview properties.
+    check_preview(grip);
 
-        await threadFront.resume();
-        resolve();
-      });
+    const objClient = threadFront.pauseGrip(grip);
+    const response = await objClient.getPrototypeAndProperties();
+    // Checks the result of getPrototypeAndProperties.
+    check_prototype_and_properties(response);
 
+    await threadFront.resume();
+
+    function eval_code() {
       debuggee.eval(
         function stopMe(arg1) {
           debugger;
         }.toString()
       );
       debuggee.eval(`
-      stopMe({
-        [Symbol()]: "first unnamed symbol",
-        [Symbol()]: "second unnamed symbol",
-        [Symbol("named")] : "named symbol",
-        [Symbol.iterator] : function* () {
-          yield 1;
-          yield 2;
-        },
-        x: 10,
-      });
-    `);
-    });
+        stopMe({
+          [Symbol()]: "first unnamed symbol",
+          [Symbol()]: "second unnamed symbol",
+          [Symbol("named")] : "named symbol",
+          [Symbol.iterator] : function* () {
+            yield 1;
+            yield 2;
+          },
+          x: 10,
+        });
+      `);
+    }
 
     function check_preview(grip) {
       Assert.equal(grip.class, "Object");
 
       const { preview } = grip;
       Assert.equal(preview.ownProperties.x.configurable, true);
       Assert.equal(preview.ownProperties.x.enumerable, true);
       Assert.equal(preview.ownProperties.x.writable, true);
--- a/devtools/server/tests/unit/test_objectgrips-17.js
+++ b/devtools/server/tests/unit/test_objectgrips-17.js
@@ -44,89 +44,81 @@ async function testPrincipal(options, gl
       if (!globalHasXrays) {
         global = Cu.waiveXrays(global);
       }
       await test(options, { global, subsumes, isOpaque, globalIsInvisible });
     }
   }
 }
 
-function test({ threadFront, debuggee }, testOptions) {
+async function test({ threadFront, debuggee }, testOptions) {
   const { global } = testOptions;
-  return new Promise(function(resolve) {
-    threadFront.once("paused", async function(packet) {
-      // Get the grips.
-      const [
-        proxyGrip,
-        inheritsProxyGrip,
-        inheritsProxy2Grip,
-      ] = packet.frame.arguments;
-
-      // Check the grip of the proxy object.
-      check_proxy_grip(debuggee, testOptions, proxyGrip);
+  const packet = await executeOnNextTickAndWaitForPause(eval_code, threadFront);
+  // Get the grips.
+  const [
+    proxyGrip,
+    inheritsProxyGrip,
+    inheritsProxy2Grip,
+  ] = packet.frame.arguments;
 
-      // Check the target and handler slots of the proxy object.
-      const proxyClient = threadFront.pauseGrip(proxyGrip);
-      const proxySlots = await proxyClient.getProxySlots();
-      check_proxy_slots(debuggee, testOptions, proxyGrip, proxySlots);
+  // Check the grip of the proxy object.
+  check_proxy_grip(debuggee, testOptions, proxyGrip);
 
-      // Check the prototype and properties of the proxy object.
-      const proxyResponse = await proxyClient.getPrototypeAndProperties();
-      check_properties(testOptions, proxyResponse.ownProperties, true, false);
-      check_prototype(
-        debuggee,
-        testOptions,
-        proxyResponse.prototype,
-        true,
-        false
-      );
+  // Check the target and handler slots of the proxy object.
+  const proxyClient = threadFront.pauseGrip(proxyGrip);
+  const proxySlots = await proxyClient.getProxySlots();
+  check_proxy_slots(debuggee, testOptions, proxyGrip, proxySlots);
+
+  // Check the prototype and properties of the proxy object.
+  const proxyResponse = await proxyClient.getPrototypeAndProperties();
+  check_properties(testOptions, proxyResponse.ownProperties, true, false);
+  check_prototype(debuggee, testOptions, proxyResponse.prototype, true, false);
 
-      // Check the prototype and properties of the object which inherits from the proxy.
-      const inheritsProxyClient = threadFront.pauseGrip(inheritsProxyGrip);
-      const inheritsProxyResponse = await inheritsProxyClient.getPrototypeAndProperties();
-      check_properties(
-        testOptions,
-        inheritsProxyResponse.ownProperties,
-        false,
-        false
-      );
-      check_prototype(
-        debuggee,
-        testOptions,
-        inheritsProxyResponse.prototype,
-        false,
-        false
-      );
+  // Check the prototype and properties of the object which inherits from the proxy.
+  const inheritsProxyClient = threadFront.pauseGrip(inheritsProxyGrip);
+  const inheritsProxyResponse = await inheritsProxyClient.getPrototypeAndProperties();
+  check_properties(
+    testOptions,
+    inheritsProxyResponse.ownProperties,
+    false,
+    false
+  );
+  check_prototype(
+    debuggee,
+    testOptions,
+    inheritsProxyResponse.prototype,
+    false,
+    false
+  );
 
-      // The prototype chain was not iterated if the object was inaccessible, so now check
-      // another object which inherits from the proxy, but was created in the debuggee.
-      const inheritsProxy2Client = threadFront.pauseGrip(inheritsProxy2Grip);
-      const inheritsProxy2Response = await inheritsProxy2Client.getPrototypeAndProperties();
-      check_properties(
-        testOptions,
-        inheritsProxy2Response.ownProperties,
-        false,
-        true
-      );
-      check_prototype(
-        debuggee,
-        testOptions,
-        inheritsProxy2Response.prototype,
-        false,
-        true
-      );
+  // The prototype chain was not iterated if the object was inaccessible, so now check
+  // another object which inherits from the proxy, but was created in the debuggee.
+  const inheritsProxy2Client = threadFront.pauseGrip(inheritsProxy2Grip);
+  const inheritsProxy2Response = await inheritsProxy2Client.getPrototypeAndProperties();
+  check_properties(
+    testOptions,
+    inheritsProxy2Response.ownProperties,
+    false,
+    true
+  );
+  check_prototype(
+    debuggee,
+    testOptions,
+    inheritsProxy2Response.prototype,
+    false,
+    true
+  );
 
-      // Check that none of the above ran proxy traps.
-      strictEqual(global.trapDidRun, false, "No proxy trap did run.");
+  // Check that none of the above ran proxy traps.
+  strictEqual(global.trapDidRun, false, "No proxy trap did run.");
 
-      // Resume the debugger and finish the current test.
-      await threadFront.resume();
-      resolve();
-    });
+  // Resume the debugger and finish the current test.
+  await threadFront.resume();
 
+  function eval_code() {
     // Create objects in `global`, and debug them in `debuggee`. They may get various
     // kinds of security wrappers, or no wrapper at all.
     // To detect that no proxy trap runs, the proxy handler should define all possible
     // traps, but the list is long and may change. Therefore a second proxy is used as
     // the handler, so that a single `get` trap suffices.
     global.eval(`
       var trapDidRun = false;
       var proxy = new Proxy({}, new Proxy({}, {get: (_, trap) => {
@@ -137,17 +129,17 @@ function test({ threadFront, debuggee },
     `);
     const data = Cu.createObjectIn(debuggee, { defineAs: "data" });
     data.proxy = global.proxy;
     data.inheritsProxy = global.inheritsProxy;
     debuggee.eval(`
       var inheritsProxy2 = Object.create(data.proxy, {x:{value:1}});
       stopMe(data.proxy, data.inheritsProxy, inheritsProxy2);
     `);
-  });
+  }
 }
 
 function check_proxy_grip(debuggee, testOptions, grip) {
   const { global, isOpaque, subsumes, globalIsInvisible } = testOptions;
   const { preview } = grip;
 
   if (global === debuggee) {
     // The proxy has no security wrappers.
--- a/devtools/server/tests/unit/test_objectgrips-18.js
+++ b/devtools/server/tests/unit/test_objectgrips-18.js
@@ -5,58 +5,61 @@
 "use strict";
 
 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
 });
 
 add_task(
-  threadFrontTest(async ({ threadFront, debuggee, client }) => {
-    return new Promise(resolve => {
-      threadFront.once("paused", async function(packet) {
-        const [grip] = packet.frame.arguments;
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    const packet = await executeOnNextTickAndWaitForPause(
+      eval_code,
+      threadFront
+    );
 
-        const objectFront = threadFront.pauseGrip(grip);
+    const [grip] = packet.frame.arguments;
+
+    const objectFront = threadFront.pauseGrip(grip);
 
-        // Checks the result of enumProperties.
-        let response = await objectFront.enumProperties({});
-        await check_enum_properties(response);
+    // Checks the result of enumProperties.
+    let response = await objectFront.enumProperties({});
+    await check_enum_properties(response);
 
-        // Checks the result of enumSymbols.
-        response = await objectFront.enumSymbols();
-        await check_enum_symbols(response);
+    // Checks the result of enumSymbols.
+    response = await objectFront.enumSymbols();
+    await check_enum_symbols(response);
 
-        await threadFront.resume();
-        resolve();
-      });
+    await threadFront.resume();
 
+    function eval_code() {
       debuggee.eval(
         function stopMe(arg1) {
           debugger;
         }.toString()
       );
+
       debuggee.eval(`
-      var obj = Array.from({length: 10})
-        .reduce((res, _, i) => {
-          res["property_" + i + "_key"] = "property_" + i + "_value";
-          res[Symbol("symbol_" + i)] = "symbol_" + i + "_value";
-          return res;
-        }, {});
+        var obj = Array.from({length: 10})
+          .reduce((res, _, i) => {
+            res["property_" + i + "_key"] = "property_" + i + "_value";
+            res[Symbol("symbol_" + i)] = "symbol_" + i + "_value";
+            return res;
+          }, {});
 
-      obj[Symbol()] = "first unnamed symbol";
-      obj[Symbol()] = "second unnamed symbol";
-      obj[Symbol.iterator] = function* () {
-        yield 1;
-        yield 2;
-      };
+        obj[Symbol()] = "first unnamed symbol";
+        obj[Symbol()] = "second unnamed symbol";
+        obj[Symbol.iterator] = function* () {
+          yield 1;
+          yield 2;
+        };
 
-      stopMe(obj);
-    `);
-    });
+        stopMe(obj);
+      `);
+    }
 
     async function check_enum_properties(iterator) {
       equal(iterator.count, 10, "iterator.count has the expected value");
 
       info("Check iterator.slice response for all properties");
       let sliceResponse = await iterator.slice(0, iterator.count);
       ok(
         sliceResponse &&
--- a/devtools/server/tests/unit/test_objectgrips-19.js
+++ b/devtools/server/tests/unit/test_objectgrips-19.js
@@ -31,27 +31,25 @@ add_task(
       },
       {
         value: Symbol("bar"),
         class: "Symbol",
         name: "bar",
       },
     ];
     for (const data of tests) {
-      await new Promise(function(resolve) {
-        threadFront.once("paused", async function(packet) {
-          const [grip] = packet.frame.arguments;
-          check_wrapped_primitive_grip(grip, data);
+      debuggee.primitive = data.value;
+      const packet = await executeOnNextTickAndWaitForPause(() => {
+        debuggee.eval("stopMe(Object(primitive));");
+      }, threadFront);
 
-          await threadFront.resume();
-          resolve();
-        });
-        debuggee.primitive = data.value;
-        debuggee.eval("stopMe(Object(primitive));");
-      });
+      const [grip] = packet.frame.arguments;
+      check_wrapped_primitive_grip(grip, data);
+
+      await threadFront.resume();
     }
   })
 );
 
 function check_wrapped_primitive_grip(grip, data) {
   strictEqual(grip.class, data.class, "The grip has the proper class.");
 
   if (!grip.preview) {
--- a/devtools/server/tests/unit/test_objectgrips-20.js
+++ b/devtools/server/tests/unit/test_objectgrips-20.js
@@ -236,59 +236,58 @@ async function test_object_grip(
   testData = {}
 ) {
   const {
     evaledObject,
     expectedIndexedProperties,
     expectedNonIndexedProperties,
   } = testData;
 
-  return new Promise((resolve, reject) => {
-    threadFront.once("paused", async function(packet) {
-      const [grip] = packet.frame.arguments;
+  const packet = await executeOnNextTickAndWaitForPause(eval_code, threadFront);
+
+  const [grip] = packet.frame.arguments;
 
-      const objClient = threadFront.pauseGrip(grip);
+  const objClient = threadFront.pauseGrip(grip);
 
-      info(`
+  info(`
         Check enumProperties response for
         ${
           typeof evaledObject === "string"
             ? evaledObject
             : JSON.stringify(evaledObject)
         }
       `);
 
-      // Checks the result of enumProperties.
-      let response = await objClient.enumProperties({
-        ignoreNonIndexedProperties: true,
-      });
-      await check_enum_properties(response, expectedIndexedProperties);
+  // Checks the result of enumProperties.
+  let response = await objClient.enumProperties({
+    ignoreNonIndexedProperties: true,
+  });
+  await check_enum_properties(response, expectedIndexedProperties);
 
-      response = await objClient.enumProperties({
-        ignoreIndexedProperties: true,
-      });
-      await check_enum_properties(response, expectedNonIndexedProperties);
+  response = await objClient.enumProperties({
+    ignoreIndexedProperties: true,
+  });
+  await check_enum_properties(response, expectedNonIndexedProperties);
 
-      await threadFront.resume();
-      resolve();
-    });
+  await threadFront.resume();
 
+  function eval_code() {
     // Be sure to run debuggee code in its own HTML 'task', so that when we call
     // the onDebuggerStatement hook, the test's own microtasks don't get suspended
     // along with the debuggee's.
     do_timeout(0, () => {
       debuggee.eval(`
         stopMe(${
           typeof evaledObject === "string"
             ? evaledObject
             : JSON.stringify(evaledObject)
         });
       `);
     });
-  });
+  }
 }
 
 async function check_enum_properties(iterator, expected = []) {
   equal(
     iterator.count,
     expected.length,
     "iterator.count has the expected value"
   );
--- a/devtools/server/tests/unit/test_objectgrips-21.js
+++ b/devtools/server/tests/unit/test_objectgrips-21.js
@@ -217,110 +217,109 @@ async function test_unsafe_grips(
   principal
 ) {
   debuggee.eval(
     function stopMe(arg1, arg2) {
       debugger;
     }.toString()
   );
   for (let data of tests) {
-    await new Promise(function(resolve) {
-      threadFront.once("paused", async function(packet) {
-        const [objGrip, inheritsGrip] = packet.frame.arguments;
-        for (const grip of [objGrip, inheritsGrip]) {
-          const isUnsafe = grip === objGrip;
-          // If `isUnsafe` is true, the parameters in `data` will be used to assert
-          // against `objGrip`, the grip of the object `obj` created by the test.
-          // Otherwise, the grip will refer to `inherits`, an ordinary object which
-          // inherits from `obj`. Then all checks are hardcoded because in every test
-          // all methods are expected to work the same on `inheritsGrip`.
-
-          check_grip(grip, data, isUnsafe);
-
-          let objClient = threadFront.pauseGrip(grip);
-          let response, slice;
-
-          response = await objClient.getPrototypeAndProperties();
-          check_properties(response.ownProperties, data, isUnsafe);
-          check_symbols(response.ownSymbols, data, isUnsafe);
-          check_prototype(response.prototype, data, isUnsafe);
-
-          response = await objClient.enumProperties({
-            ignoreIndexedProperties: true,
-          });
-          slice = await response.slice(0, response.count);
-          check_properties(slice.ownProperties, data, isUnsafe);
-
-          response = await objClient.enumProperties({});
-          slice = await response.slice(0, response.count);
-          check_properties(slice.ownProperties, data, isUnsafe);
-
-          response = await objClient.getOwnPropertyNames();
-          check_property_names(response.ownPropertyNames, data, isUnsafe);
-
-          response = await objClient.getProperty("x");
-          check_property(response.descriptor, data, isUnsafe);
-
-          response = await objClient.enumSymbols();
-          slice = await response.slice(0, response.count);
-          check_symbol_names(slice.ownSymbols, data, isUnsafe);
-
-          response = await objClient.getProperty(Symbol.for("x"));
-          check_symbol(response.descriptor, data, isUnsafe);
+    data = { ...defaults, ...data };
 
-          response = await objClient.getPrototype();
-          check_prototype(response.prototype, data, isUnsafe);
-
-          response = await objClient.getDisplayString();
-          check_display_string(response.displayString, data, isUnsafe);
-
-          if (data.isFunction && isUnsafe) {
-            // For function-related methods, the object front checks that the class
-            // of the grip is "Function", and if it's not, the method in object.js
-            // is not called. But some tests have a grip with a class that is not
-            // "Function" (e.g. it's "Proxy") but the DebuggerObject has a "Function"
-            // class because the object is callable (despite not being a Function object).
-            // So the grip class is changed in order to test the object.js method.
-            grip.class = "Function";
-            objClient = threadFront.pauseGrip(grip);
-            try {
-              response = await objClient.getParameterNames();
-              ok(
-                true,
-                "getParameterNames passed. DebuggerObject.class is 'Function'" +
-                  "on the object actor"
-              );
-            } catch (e) {
-              ok(
-                false,
-                "getParameterNames failed. DebuggerObject.class may not be" +
-                  " 'Function' on the object actor"
-              );
-            }
-          }
-        }
-
-        await threadFront.resume();
-        resolve();
-      });
-
-      data = { ...defaults, ...data };
-
-      // Run the code and test the results.
-      const sandbox = Cu.Sandbox(systemPrincipal);
-      Object.assign(sandbox, { Services, systemPrincipal, Cu });
-      sandbox.eval(data.code);
-      debuggee.obj = sandbox.obj;
-      const inherits = `Object.create(obj, {
+    // Run the code and test the results.
+    const sandbox = Cu.Sandbox(systemPrincipal);
+    Object.assign(sandbox, { Services, systemPrincipal, Cu });
+    sandbox.eval(data.code);
+    debuggee.obj = sandbox.obj;
+    const inherits = `Object.create(obj, {
         x: {value: 1},
         [Symbol.for("x")]: {value: 2}
       })`;
-      debuggee.eval(`stopMe(obj, ${inherits});`);
-      ok(sandbox.eval(data.afterTest), "Check after test passes");
-    });
+
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => debuggee.eval(`stopMe(obj, ${inherits});`),
+      threadFront
+    );
+
+    const [objGrip, inheritsGrip] = packet.frame.arguments;
+    for (const grip of [objGrip, inheritsGrip]) {
+      const isUnsafe = grip === objGrip;
+      // If `isUnsafe` is true, the parameters in `data` will be used to assert
+      // against `objGrip`, the grip of the object `obj` created by the test.
+      // Otherwise, the grip will refer to `inherits`, an ordinary object which
+      // inherits from `obj`. Then all checks are hardcoded because in every test
+      // all methods are expected to work the same on `inheritsGrip`.
+      check_grip(grip, data, isUnsafe);
+
+      let objClient = threadFront.pauseGrip(grip);
+      let response, slice;
+
+      response = await objClient.getPrototypeAndProperties();
+      check_properties(response.ownProperties, data, isUnsafe);
+      check_symbols(response.ownSymbols, data, isUnsafe);
+      check_prototype(response.prototype, data, isUnsafe);
+
+      response = await objClient.enumProperties({
+        ignoreIndexedProperties: true,
+      });
+      slice = await response.slice(0, response.count);
+      check_properties(slice.ownProperties, data, isUnsafe);
+
+      response = await objClient.enumProperties({});
+      slice = await response.slice(0, response.count);
+      check_properties(slice.ownProperties, data, isUnsafe);
+
+      response = await objClient.getOwnPropertyNames();
+      check_property_names(response.ownPropertyNames, data, isUnsafe);
+
+      response = await objClient.getProperty("x");
+      check_property(response.descriptor, data, isUnsafe);
+
+      response = await objClient.enumSymbols();
+      slice = await response.slice(0, response.count);
+      check_symbol_names(slice.ownSymbols, data, isUnsafe);
+
+      response = await objClient.getProperty(Symbol.for("x"));
+      check_symbol(response.descriptor, data, isUnsafe);
+
+      response = await objClient.getPrototype();
+      check_prototype(response.prototype, data, isUnsafe);
+
+      response = await objClient.getDisplayString();
+      check_display_string(response.displayString, data, isUnsafe);
+
+      if (data.isFunction && isUnsafe) {
+        // For function-related methods, the object front checks that the class
+        // of the grip is "Function", and if it's not, the method in object.js
+        // is not called. But some tests have a grip with a class that is not
+        // "Function" (e.g. it's "Proxy") but the DebuggerObject has a "Function"
+        // class because the object is callable (despite not being a Function object).
+        // So the grip class is changed in order to test the object.js method.
+        grip.class = "Function";
+        objClient = threadFront.pauseGrip(grip);
+        try {
+          response = await objClient.getParameterNames();
+          ok(
+            true,
+            "getParameterNames passed. DebuggerObject.class is 'Function'" +
+              "on the object actor"
+          );
+        } catch (e) {
+          ok(
+            false,
+            "getParameterNames failed. DebuggerObject.class may not be" +
+              " 'Function' on the object actor"
+          );
+        }
+      }
+    }
+
+    await threadFront.resume();
+
+    ok(sandbox.eval(data.afterTest), "Check after test passes");
   }
 }
 
 function check_grip(grip, data, isUnsafe) {
   if (isUnsafe) {
     strictEqual(grip.class, data.class, "The grip has the proper class.");
     strictEqual("preview" in grip, data.hasPreview, "Check preview presence.");
   } else {
--- a/devtools/server/tests/unit/test_objectgrips-22.js
+++ b/devtools/server/tests/unit/test_objectgrips-22.js
@@ -5,44 +5,47 @@
 "use strict";
 
 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
 });
 
 add_task(
-  threadFrontTest(async ({ threadFront, debuggee, client }) => {
-    await new Promise(function(resolve) {
-      threadFront.once("paused", async function(packet) {
-        const [grip] = packet.frame.arguments;
-        const objClient = threadFront.pauseGrip(grip);
-        const iterator = await objClient.enumSymbols();
-        const { ownSymbols } = await iterator.slice(0, iterator.count);
+  threadFrontTest(async ({ threadFront, debuggee }) => {
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
+
+    const [grip] = packet.frame.arguments;
+    const objClient = threadFront.pauseGrip(grip);
+    const iterator = await objClient.enumSymbols();
+    const { ownSymbols } = await iterator.slice(0, iterator.count);
 
-        strictEqual(ownSymbols.length, 1, "There is 1 symbol property.");
-        const { name, descriptor } = ownSymbols[0];
-        strictEqual(name, "Symbol(sym)", "Got right symbol name.");
-        deepEqual(
-          descriptor,
-          {
-            configurable: false,
-            enumerable: false,
-            writable: false,
-            value: 1,
-          },
-          "Got right property descriptor."
-        );
+    strictEqual(ownSymbols.length, 1, "There is 1 symbol property.");
+    const { name, descriptor } = ownSymbols[0];
+    strictEqual(name, "Symbol(sym)", "Got right symbol name.");
+    deepEqual(
+      descriptor,
+      {
+        configurable: false,
+        enumerable: false,
+        writable: false,
+        value: 1,
+      },
+      "Got right property descriptor."
+    );
 
-        await threadFront.resume();
-        resolve();
-      });
-      debuggee.eval(
-        function stopMe(arg1) {
-          debugger;
-        }.toString()
-      );
-      debuggee.eval(
-        `stopMe(Object.defineProperty({}, Symbol("sym"), {value: 1}));`
-      );
-    });
+    await threadFront.resume();
   })
 );
+
+function evalCode(debuggee) {
+  debuggee.eval(
+    function stopMe(arg1) {
+      debugger;
+    }.toString()
+  );
+  debuggee.eval(
+    `stopMe(Object.defineProperty({}, Symbol("sym"), {value: 1}));`
+  );
+}
--- a/devtools/server/tests/unit/test_objectgrips-23.js
+++ b/devtools/server/tests/unit/test_objectgrips-23.js
@@ -7,37 +7,39 @@
 
 Services.prefs.setBoolPref("security.allow_eval_with_system_principal", true);
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
 });
 
 add_task(
   threadFrontTest(async ({ threadFront, debuggee }) => {
-    await new Promise(function(resolve) {
-      threadFront.once("paused", async function(packet) {
-        const [grip] = packet.frame.arguments;
-        strictEqual(
-          grip.class,
-          "Function",
-          `Grip has expected value for "class" property`
-        );
-        strictEqual(
-          grip.isClassConstructor,
-          true,
-          `Grip has expected value for "isClassConstructor" property`
-        );
+    const packet = await executeOnNextTickAndWaitForPause(
+      () => evalCode(debuggee),
+      threadFront
+    );
 
-        await threadFront.resume();
-        resolve();
-      });
+    const [grip] = packet.frame.arguments;
+    strictEqual(
+      grip.class,
+      "Function",
+      `Grip has expected value for "class" property`
+    );
+    strictEqual(
+      grip.isClassConstructor,
+      true,
+      `Grip has expected value for "isClassConstructor" property`
+    );
 
-      debuggee.eval(`
-        class MyClass {};
-        stopMe(MyClass);
-
-        function stopMe(arg1) {
-          debugger;
-        }
-      `);
-    });
+    await threadFront.resume();
   })
 );
+
+function evalCode(debuggee) {
+  debuggee.eval(`
+    class MyClass {};
+    stopMe(MyClass);
+
+    function stopMe(arg1) {
+      debugger;
+    }
+  `);
+}