Bug 1512220 - Switch devtools/server/tests/unit/test_setBreakpoint* tests to threadClientTest. r=yulia
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 11 Dec 2018 17:46:10 +0000
changeset 450236 434525362f73aec285ee22315fe5e6c87e27f04f
parent 450235 ddb7c9f71ce2883ab9d1912fc09bee67b9f83f09
child 450237 67fb7c7594fcf301bbae0a664d7453a436408617
push id74564
push userapoirot@mozilla.com
push dateWed, 12 Dec 2018 08:22:23 +0000
treeherderautoland@943836f5e528 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyulia
bugs1512220
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1512220 - Switch devtools/server/tests/unit/test_setBreakpoint* tests to threadClientTest. r=yulia All these tests are clearly copy pasting existing threadClientTest helper. They might run as well against workers but today we don't run them there, so I used the doNotRunWorker flag. MozReview-Commit-ID: 7k1lJ06WeGZ Differential Revision: https://phabricator.services.mozilla.com/D13899
devtools/server/tests/unit/head_dbg.js
devtools/server/tests/unit/test_setBreakpoint-at-the-beginning-of-a-line.js
devtools/server/tests/unit/test_setBreakpoint-at-the-beginning-of-a-minified-fn.js
devtools/server/tests/unit/test_setBreakpoint-at-the-end-of-a-line.js
devtools/server/tests/unit/test_setBreakpoint-at-the-end-of-a-minified-fn.js
devtools/server/tests/unit/test_setBreakpoint-on-column-in-gcd-script.js
devtools/server/tests/unit/test_setBreakpoint-on-column.js
devtools/server/tests/unit/test_setBreakpoint-on-line-in-gcd-script.js
devtools/server/tests/unit/test_setBreakpoint-on-line-with-multiple-offsets.js
devtools/server/tests/unit/test_setBreakpoint-on-line-with-multiple-statements.js
devtools/server/tests/unit/test_setBreakpoint-on-line-with-no-offsets-in-gcd-script.js
devtools/server/tests/unit/test_setBreakpoint-on-line-with-no-offsets.js
devtools/server/tests/unit/test_setBreakpoint-on-line.js
--- a/devtools/server/tests/unit/head_dbg.js
+++ b/devtools/server/tests/unit/head_dbg.js
@@ -869,21 +869,21 @@ function threadClientTest(test, options 
     debuggee.__name = scriptName;
     server.addTestGlobal(debuggee);
 
     const client = new DebuggerClient(server.connectPipe());
     await client.connect();
 
     // Attach to the fake tab target and retrieve the ThreadClient instance.
     // Automatically resume as the thread is paused by default after attach.
-    const [, , threadClient] =
+    const [, targetFront, threadClient] =
       await attachTestTabAndResume(client, scriptName);
 
     // Run the test function
-    await test({ threadClient, debuggee, client });
+    await test({ threadClient, debuggee, client, targetFront });
 
     // Cleanup the client after the test ran
     await client.close();
 
     server.removeTestGlobal(debuggee);
 
     // Also cleanup the created server
     server.destroy();
--- a/devtools/server/tests/unit/test_setBreakpoint-at-the-beginning-of-a-line.js
+++ b/devtools/server/tests/unit/test_setBreakpoint-at-the-beginning-of-a-line.js
@@ -1,45 +1,29 @@
 "use strict";
 
-var SOURCE_URL = getFileUrl("setBreakpoint-on-column.js");
-
-async function run_test() {
-  do_test_pending();
-  const { createRootActor } = require("xpcshell-test/testactors");
-  DebuggerServer.setRootActor(createRootActor);
-  DebuggerServer.init(() => true);
-  const global = createTestGlobal("test");
-  DebuggerServer.addTestGlobal(global);
+const SOURCE_URL = getFileUrl("setBreakpoint-on-column.js");
 
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  await connect(client);
-
-  const { tabs } = await listTabs(client);
-  const tab = findTab(tabs, "test");
-  const [, targetFront] = await attachTarget(client, tab);
-  const [, threadClient] = await attachThread(targetFront);
-  await resume(threadClient);
-
+add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
   const promise = waitForNewSource(threadClient, SOURCE_URL);
-  loadSubScript(SOURCE_URL, global);
+  loadSubScript(SOURCE_URL, debuggee);
   const { source } = await promise;
   const sourceClient = threadClient.source(source);
 
   const location = { line: 4, column: 2 };
   let [packet, breakpointClient] = await setBreakpoint(
     sourceClient,
     location
   );
 
   Assert.ok(!packet.isPending);
   Assert.equal(false, "actualLocation" in packet);
 
   packet = await executeOnNextTickAndWaitForPause(function() {
-    Cu.evalInSandbox("f()", global);
+    Cu.evalInSandbox("f()", debuggee);
   }, client);
 
   Assert.equal(packet.type, "paused");
   const why = packet.why;
   Assert.equal(why.type, "breakpoint");
   Assert.equal(why.actors.length, 1);
   Assert.equal(why.actors[0], breakpointClient.actor);
 
@@ -50,11 +34,9 @@ async function run_test() {
   Assert.equal(where.column, 6);
 
   const variables = frame.environment.bindings.variables;
   Assert.equal(variables.a.value.type, "undefined");
   Assert.equal(variables.b.value.type, "undefined");
   Assert.equal(variables.c.value.type, "undefined");
 
   await resume(threadClient);
-  await close(client);
-  do_test_finished();
-}
+}, { doNotRunWorker: true }));
--- a/devtools/server/tests/unit/test_setBreakpoint-at-the-beginning-of-a-minified-fn.js
+++ b/devtools/server/tests/unit/test_setBreakpoint-at-the-beginning-of-a-minified-fn.js
@@ -1,47 +1,31 @@
 "use strict";
 
-var SOURCE_URL = getFileUrl("setBreakpoint-on-column-minified.js");
-
-async function run_test() {
-  do_test_pending();
-  const { createRootActor } = require("xpcshell-test/testactors");
-  DebuggerServer.setRootActor(createRootActor);
-  DebuggerServer.init(() => true);
-  const global = createTestGlobal("test");
-  DebuggerServer.addTestGlobal(global);
+const SOURCE_URL = getFileUrl("setBreakpoint-on-column-minified.js");
 
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  await connect(client);
-
-  const { tabs } = await listTabs(client);
-  const tab = findTab(tabs, "test");
-  const [, targetFront] = await attachTarget(client, tab);
-  const [, threadClient] = await attachThread(targetFront);
-  await resume(threadClient);
-
+add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
   const promise = waitForNewSource(threadClient, SOURCE_URL);
-  loadSubScript(SOURCE_URL, global);
+  loadSubScript(SOURCE_URL, debuggee);
   const { source } = await promise;
   const sourceClient = threadClient.source(source);
 
   // Pause inside of the nested function so we can make sure that we don't
   // add any other breakpoints at other places on this line.
   const location = { line: 3, column: 47 };
   let [packet, breakpointClient] = await setBreakpoint(
     sourceClient,
     location
   );
 
   Assert.ok(!packet.isPending);
   Assert.equal(false, "actualLocation" in packet);
 
   packet = await executeOnNextTickAndWaitForPause(function() {
-    Cu.evalInSandbox("f()", global);
+    Cu.evalInSandbox("f()", debuggee);
   }, client);
 
   Assert.equal(packet.type, "paused");
   const why = packet.why;
   Assert.equal(why.type, "breakpoint");
   Assert.equal(why.actors.length, 1);
   Assert.equal(why.actors[0], breakpointClient.actor);
 
@@ -52,11 +36,9 @@ async function run_test() {
   Assert.equal(where.column, 52);
 
   const variables = frame.environment.bindings.variables;
   Assert.equal(variables.a.value.type, "undefined");
   Assert.equal(variables.b.value.type, "undefined");
   Assert.equal(variables.c.value.type, "undefined");
 
   await resume(threadClient);
-  await close(client);
-  do_test_finished();
-}
+}, { doNotRunWorker: true }));
--- a/devtools/server/tests/unit/test_setBreakpoint-at-the-end-of-a-line.js
+++ b/devtools/server/tests/unit/test_setBreakpoint-at-the-end-of-a-line.js
@@ -1,47 +1,29 @@
 "use strict";
 
-var SOURCE_URL = getFileUrl("setBreakpoint-on-column.js");
-
-async function run_test() {
-  do_test_pending();
-
-  const { createRootActor } = require("xpcshell-test/testactors");
-  DebuggerServer.setRootActor(createRootActor);
-  DebuggerServer.init(() => true);
-
-  const global = createTestGlobal("test");
-  DebuggerServer.addTestGlobal(global);
+const SOURCE_URL = getFileUrl("setBreakpoint-on-column.js");
 
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  await connect(client);
-
-  const { tabs } = await listTabs(client);
-  const tab = findTab(tabs, "test");
-  const [, targetFront] = await attachTarget(client, tab);
-  const [, threadClient] = await attachThread(targetFront);
-  await resume(threadClient);
-
+add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
   const promise = waitForNewSource(threadClient, SOURCE_URL);
-  loadSubScript(SOURCE_URL, global);
+  loadSubScript(SOURCE_URL, debuggee);
   const { source } = await promise;
   const sourceClient = threadClient.source(source);
 
   const location = { line: 4, column: 42 };
   let [packet, breakpointClient] = await setBreakpoint(
     sourceClient,
     location
   );
 
   Assert.ok(!packet.isPending);
   Assert.equal(false, "actualLocation" in packet);
 
   packet = await executeOnNextTickAndWaitForPause(function() {
-    Cu.evalInSandbox("f()", global);
+    Cu.evalInSandbox("f()", debuggee);
   }, client);
 
   Assert.equal(packet.type, "paused");
   const why = packet.why;
   Assert.equal(why.type, "breakpoint");
   Assert.equal(why.actors.length, 1);
   Assert.equal(why.actors[0], breakpointClient.actor);
 
@@ -52,12 +34,9 @@ async function run_test() {
   Assert.equal(where.column, 28);
 
   const variables = frame.environment.bindings.variables;
   Assert.equal(variables.a.value, 1);
   Assert.equal(variables.b.value, 2);
   Assert.equal(variables.c.value.type, "undefined");
 
   await resume(threadClient);
-  await close(client);
-
-  do_test_finished();
-}
+}, { doNotRunWorker: true }));
--- a/devtools/server/tests/unit/test_setBreakpoint-at-the-end-of-a-minified-fn.js
+++ b/devtools/server/tests/unit/test_setBreakpoint-at-the-end-of-a-minified-fn.js
@@ -1,47 +1,31 @@
 "use strict";
 
-var SOURCE_URL = getFileUrl("setBreakpoint-on-column-minified.js");
-
-async function run_test() {
-  do_test_pending();
-  const { createRootActor } = require("xpcshell-test/testactors");
-  DebuggerServer.setRootActor(createRootActor);
-  DebuggerServer.init(() => true);
-  const global = createTestGlobal("test");
-  DebuggerServer.addTestGlobal(global);
+const SOURCE_URL = getFileUrl("setBreakpoint-on-column-minified.js");
 
-  const client = new DebuggerClient(DebuggerServer.connectPipe());
-  await connect(client);
-
-  const { tabs } = await listTabs(client);
-  const tab = findTab(tabs, "test");
-  const [, targetFront] = await attachTarget(client, tab);
-  const [, threadClient] = await attachThread(targetFront);
-  await resume(threadClient);
-
+add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
   const promise = waitForNewSource(threadClient, SOURCE_URL);
-  loadSubScript(SOURCE_URL, global);
+  loadSubScript(SOURCE_URL, debuggee);
   const { source } = await promise;
   const sourceClient = threadClient.source(source);
 
   // Pause inside of the nested function so we can make sure that we don't
   // add any other breakpoints at other places on this line.
   const location = { line: 3, column: 81 };
   let [packet, breakpointClient] = await setBreakpoint(
     sourceClient,
     location
   );
 
   Assert.ok(!packet.isPending);
   Assert.equal(false, "actualLocation" in packet);
 
   packet = await executeOnNextTickAndWaitForPause(function() {
-    Cu.evalInSandbox("f()", global);
+    Cu.evalInSandbox("f()", debuggee);
   }, client);
 
   Assert.equal(packet.type, "paused");
   const why = packet.why;
   Assert.equal(why.type, "breakpoint");
   Assert.equal(why.actors.length, 1);
   Assert.equal(why.actors[0], breakpointClient.actor);
 
@@ -52,11 +36,9 @@ async function run_test() {
   Assert.equal(where.column, 81);
 
   const variables = frame.environment.bindings.variables;
   Assert.equal(variables.a.value, 1);
   Assert.equal(variables.b.value, 2);
   Assert.equal(variables.c.value, 3);
 
   await resume(threadClient);
-  await close(client);
-  do_test_finished();
-}
+}, { doNotRunWorker: true }));
--- a/devtools/server/tests/unit/test_setBreakpoint-on-column-in-gcd-script.js
+++ b/devtools/server/tests/unit/test_setBreakpoint-on-column-in-gcd-script.js
@@ -1,59 +1,38 @@
 "use strict";
 
-var SOURCE_URL = getFileUrl("setBreakpoint-on-column-in-gcd-script.js");
+const SOURCE_URL = getFileUrl("setBreakpoint-on-column-in-gcd-script.js");
 
-function run_test() {
-  return (async function() {
-    do_test_pending();
-
-    const global = testGlobal("test");
-    loadSubScriptWithOptions(SOURCE_URL, {target: global, ignoreCache: true});
-    Cu.forceGC(); Cu.forceGC(); Cu.forceGC();
+add_task(threadClientTest(async ({ threadClient, debuggee, client, targetFront }) => {
+  const promise = waitForNewSource(threadClient, SOURCE_URL);
+  loadSubScriptWithOptions(SOURCE_URL, {target: debuggee, ignoreCache: true});
+  Cu.forceGC(); Cu.forceGC(); Cu.forceGC();
 
-    const { createRootActor } = require("xpcshell-test/testactors");
-    DebuggerServer.setRootActor(createRootActor);
-    DebuggerServer.init(() => true);
-    DebuggerServer.addTestGlobal(global);
-    const client = new DebuggerClient(DebuggerServer.connectPipe());
-    await connect(client);
+  const { source } = await promise;
+  const sourceClient = threadClient.source(source);
 
-    const { tabs } = await listTabs(client);
-    const tab = findTab(tabs, "test");
-    const [, targetFront] = await attachTarget(client, tab);
-    const [, threadClient] = await attachThread(targetFront);
-    await resume(threadClient);
-
-    const { sources } = await getSources(threadClient);
-    const source = findSource(sources, SOURCE_URL);
-    const sourceClient = threadClient.source(source);
+  const location = { line: 6, column: 17 };
+  let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
+  Assert.ok(packet.isPending);
+  Assert.equal(false, "actualLocation" in packet);
 
-    const location = { line: 6, column: 17 };
-    let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
-    Assert.ok(packet.isPending);
-    Assert.equal(false, "actualLocation" in packet);
-
-    packet = await executeOnNextTickAndWaitForPause(function() {
-      reload(targetFront).then(function() {
-        loadSubScriptWithOptions(SOURCE_URL, {target: global, ignoreCache: true});
-      });
-    }, client);
-    Assert.equal(packet.type, "paused");
-    const why = packet.why;
-    Assert.equal(why.type, "breakpoint");
-    Assert.equal(why.actors.length, 1);
-    Assert.equal(why.actors[0], breakpointClient.actor);
-    const frame = packet.frame;
-    const where = frame.where;
-    Assert.equal(where.source.actor, source.actor);
-    Assert.equal(where.line, location.line);
-    Assert.equal(where.column, location.column);
-    const variables = frame.environment.bindings.variables;
-    Assert.equal(variables.a.value, 1);
-    Assert.equal(variables.b.value.type, "undefined");
-    Assert.equal(variables.c.value.type, "undefined");
-    await resume(threadClient);
-
-    await close(client);
-    do_test_finished();
-  })();
-}
+  packet = await executeOnNextTickAndWaitForPause(function() {
+    reload(targetFront).then(function() {
+      loadSubScriptWithOptions(SOURCE_URL, {target: debuggee, ignoreCache: true});
+    });
+  }, client);
+  Assert.equal(packet.type, "paused");
+  const why = packet.why;
+  Assert.equal(why.type, "breakpoint");
+  Assert.equal(why.actors.length, 1);
+  Assert.equal(why.actors[0], breakpointClient.actor);
+  const frame = packet.frame;
+  const where = frame.where;
+  Assert.equal(where.source.actor, source.actor);
+  Assert.equal(where.line, location.line);
+  Assert.equal(where.column, location.column);
+  const variables = frame.environment.bindings.variables;
+  Assert.equal(variables.a.value, 1);
+  Assert.equal(variables.b.value.type, "undefined");
+  Assert.equal(variables.c.value.type, "undefined");
+  await resume(threadClient);
+}, { doNotRunWorker: true }));
--- a/devtools/server/tests/unit/test_setBreakpoint-on-column.js
+++ b/devtools/server/tests/unit/test_setBreakpoint-on-column.js
@@ -1,58 +1,35 @@
 "use strict";
 
-var SOURCE_URL = getFileUrl("setBreakpoint-on-column.js");
-
-function run_test() {
-  return (async function() {
-    do_test_pending();
-
-    const { createRootActor } = require("xpcshell-test/testactors");
-    DebuggerServer.setRootActor(createRootActor);
-    DebuggerServer.init(() => true);
-
-    const global = createTestGlobal("test");
-    DebuggerServer.addTestGlobal(global);
+const SOURCE_URL = getFileUrl("setBreakpoint-on-column.js");
 
-    const client = new DebuggerClient(DebuggerServer.connectPipe());
-    await connect(client);
+add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
+  const promise = waitForNewSource(threadClient, SOURCE_URL);
+  loadSubScript(SOURCE_URL, debuggee);
+  const { source } = await promise;
+  const sourceClient = threadClient.source(source);
 
-    const { tabs } = await listTabs(client);
-    const tab = findTab(tabs, "test");
-    const [, targetFront] = await attachTarget(client, tab);
-    const [, threadClient] = await attachThread(targetFront);
-    await resume(threadClient);
-
-    const promise = waitForNewSource(threadClient, SOURCE_URL);
-    loadSubScript(SOURCE_URL, global);
-    const { source } = await promise;
-    const sourceClient = threadClient.source(source);
+  const location = { line: 4, column: 17 };
+  let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
+  Assert.ok(!packet.isPending);
+  Assert.equal(false, "actualLocation" in packet);
 
-    const location = { line: 4, column: 17 };
-    let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
-    Assert.ok(!packet.isPending);
-    Assert.equal(false, "actualLocation" in packet);
+  packet = await executeOnNextTickAndWaitForPause(function() {
+    Cu.evalInSandbox("f()", debuggee);
+  }, client);
+  Assert.equal(packet.type, "paused");
+  const why = packet.why;
+  Assert.equal(why.type, "breakpoint");
+  Assert.equal(why.actors.length, 1);
+  Assert.equal(why.actors[0], breakpointClient.actor);
+  const frame = packet.frame;
+  const where = frame.where;
+  Assert.equal(where.source.actor, source.actor);
+  Assert.equal(where.line, location.line);
+  Assert.equal(where.column, location.column);
+  const variables = frame.environment.bindings.variables;
+  Assert.equal(variables.a.value, 1);
+  Assert.equal(variables.b.value.type, "undefined");
+  Assert.equal(variables.c.value.type, "undefined");
 
-    packet = await executeOnNextTickAndWaitForPause(function() {
-      Cu.evalInSandbox("f()", global);
-    }, client);
-    Assert.equal(packet.type, "paused");
-    const why = packet.why;
-    Assert.equal(why.type, "breakpoint");
-    Assert.equal(why.actors.length, 1);
-    Assert.equal(why.actors[0], breakpointClient.actor);
-    const frame = packet.frame;
-    const where = frame.where;
-    Assert.equal(where.source.actor, source.actor);
-    Assert.equal(where.line, location.line);
-    Assert.equal(where.column, location.column);
-    const variables = frame.environment.bindings.variables;
-    Assert.equal(variables.a.value, 1);
-    Assert.equal(variables.b.value.type, "undefined");
-    Assert.equal(variables.c.value.type, "undefined");
-
-    await resume(threadClient);
-    await close(client);
-
-    do_test_finished();
-  })();
-}
+  await resume(threadClient);
+}, { doNotRunWorker: true }));
--- a/devtools/server/tests/unit/test_setBreakpoint-on-line-in-gcd-script.js
+++ b/devtools/server/tests/unit/test_setBreakpoint-on-line-in-gcd-script.js
@@ -1,58 +1,37 @@
 "use strict";
 
-var SOURCE_URL = getFileUrl("setBreakpoint-on-line-in-gcd-script.js");
+const SOURCE_URL = getFileUrl("setBreakpoint-on-line-in-gcd-script.js");
 
-function run_test() {
-  return (async function() {
-    do_test_pending();
-
-    const global = createTestGlobal("test");
-    loadSubScriptWithOptions(SOURCE_URL, {target: global, ignoreCache: true});
-    Cu.forceGC(); Cu.forceGC(); Cu.forceGC();
+add_task(threadClientTest(async ({ threadClient, debuggee, client, targetFront }) => {
+  const promise = waitForNewSource(threadClient, SOURCE_URL);
+  loadSubScriptWithOptions(SOURCE_URL, {target: debuggee, ignoreCache: true});
+  Cu.forceGC(); Cu.forceGC(); Cu.forceGC();
 
-    const { createRootActor } = require("xpcshell-test/testactors");
-    DebuggerServer.setRootActor(createRootActor);
-    DebuggerServer.init(() => true);
-    DebuggerServer.addTestGlobal(global);
-    const client = new DebuggerClient(DebuggerServer.connectPipe());
-    await connect(client);
+  const { source } = await promise;
+  const sourceClient = threadClient.source(source);
 
-    const { tabs } = await listTabs(client);
-    const tab = findTab(tabs, "test");
-    const [, targetFront] = await attachTarget(client, tab);
-    const [, threadClient] = await attachThread(targetFront);
-    await resume(threadClient);
-
-    const { sources } = await getSources(threadClient);
-    const source = findSource(sources, SOURCE_URL);
-    const sourceClient = threadClient.source(source);
+  const location = { line: 7 };
+  let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
+  Assert.ok(packet.isPending);
+  Assert.equal(false, "actualLocation" in packet);
 
-    const location = { line: 7 };
-    let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
-    Assert.ok(packet.isPending);
-    Assert.equal(false, "actualLocation" in packet);
-
-    packet = await executeOnNextTickAndWaitForPause(function() {
-      reload(targetFront).then(function() {
-        loadSubScriptWithOptions(SOURCE_URL, {target: global, ignoreCache: true});
-      });
-    }, client);
-    Assert.equal(packet.type, "paused");
-    const why = packet.why;
-    Assert.equal(why.type, "breakpoint");
-    Assert.equal(why.actors.length, 1);
-    Assert.equal(why.actors[0], breakpointClient.actor);
-    const frame = packet.frame;
-    const where = frame.where;
-    Assert.equal(where.source.actor, source.actor);
-    Assert.equal(where.line, location.line);
-    const variables = frame.environment.bindings.variables;
-    Assert.equal(variables.a.value, 1);
-    Assert.equal(variables.b.value.type, "undefined");
-    Assert.equal(variables.c.value.type, "undefined");
-    await resume(threadClient);
-
-    await close(client);
-    do_test_finished();
-  })();
-}
+  packet = await executeOnNextTickAndWaitForPause(function() {
+    reload(targetFront).then(function() {
+      loadSubScriptWithOptions(SOURCE_URL, {target: debuggee, ignoreCache: true});
+    });
+  }, client);
+  Assert.equal(packet.type, "paused");
+  const why = packet.why;
+  Assert.equal(why.type, "breakpoint");
+  Assert.equal(why.actors.length, 1);
+  Assert.equal(why.actors[0], breakpointClient.actor);
+  const frame = packet.frame;
+  const where = frame.where;
+  Assert.equal(where.source.actor, source.actor);
+  Assert.equal(where.line, location.line);
+  const variables = frame.environment.bindings.variables;
+  Assert.equal(variables.a.value, 1);
+  Assert.equal(variables.b.value.type, "undefined");
+  Assert.equal(variables.c.value.type, "undefined");
+  await resume(threadClient);
+}, { doNotRunWorker: true }));
--- a/devtools/server/tests/unit/test_setBreakpoint-on-line-with-multiple-offsets.js
+++ b/devtools/server/tests/unit/test_setBreakpoint-on-line-with-multiple-offsets.js
@@ -1,71 +1,47 @@
 "use strict";
 
-var SOURCE_URL = getFileUrl("setBreakpoint-on-line-with-multiple-offsets.js");
-
-function run_test() {
-  return (async function() {
-    do_test_pending();
-
-    const { createRootActor } = require("xpcshell-test/testactors");
-    DebuggerServer.setRootActor(createRootActor);
-    DebuggerServer.init(() => true);
-
-    const global = createTestGlobal("test");
-    DebuggerServer.addTestGlobal(global);
-
-    const client = new DebuggerClient(DebuggerServer.connectPipe());
-    await connect(client);
+const SOURCE_URL = getFileUrl("setBreakpoint-on-line-with-multiple-offsets.js");
 
-    const { tabs } = await listTabs(client);
-    const tab = findTab(tabs, "test");
-    const [, targetFront] = await attachTarget(client, tab);
-
-    const [, threadClient] = await attachThread(targetFront);
-    await resume(threadClient);
+add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
+  const promise = waitForNewSource(threadClient, SOURCE_URL);
+  loadSubScript(SOURCE_URL, debuggee);
+  const { source } = await promise;
+  const sourceClient = threadClient.source(source);
 
-    const promise = waitForNewSource(threadClient, SOURCE_URL);
-    loadSubScript(SOURCE_URL, global);
-    const { source } = await promise;
-    const sourceClient = threadClient.source(source);
-
-    const location = { line: 4 };
-    let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
-    Assert.ok(!packet.isPending);
-    Assert.equal(false, "actualLocation" in packet);
+  const location = { line: 4 };
+  let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
+  Assert.ok(!packet.isPending);
+  Assert.equal(false, "actualLocation" in packet);
 
-    packet = await executeOnNextTickAndWaitForPause(function() {
-      Cu.evalInSandbox("f()", global);
-    }, client);
-    Assert.equal(packet.type, "paused");
-    let why = packet.why;
-    Assert.equal(why.type, "breakpoint");
-    Assert.equal(why.actors.length, 1);
-    Assert.equal(why.actors[0], breakpointClient.actor);
-    let frame = packet.frame;
-    let where = frame.where;
-    Assert.equal(where.source.actor, source.actor);
-    Assert.equal(where.line, location.line);
-    let variables = frame.environment.bindings.variables;
-    Assert.equal(variables.i.value.type, "undefined");
+  packet = await executeOnNextTickAndWaitForPause(function() {
+    Cu.evalInSandbox("f()", debuggee);
+  }, client);
+  Assert.equal(packet.type, "paused");
+  let why = packet.why;
+  Assert.equal(why.type, "breakpoint");
+  Assert.equal(why.actors.length, 1);
+  Assert.equal(why.actors[0], breakpointClient.actor);
+  let frame = packet.frame;
+  let where = frame.where;
+  Assert.equal(where.source.actor, source.actor);
+  Assert.equal(where.line, location.line);
+  let variables = frame.environment.bindings.variables;
+  Assert.equal(variables.i.value.type, "undefined");
 
-    packet = await executeOnNextTickAndWaitForPause(function() {
-      resume(threadClient);
-    }, client);
-    Assert.equal(packet.type, "paused");
-    why = packet.why;
-    Assert.equal(why.type, "breakpoint");
-    Assert.equal(why.actors.length, 1);
-    Assert.equal(why.actors[0], breakpointClient.actor);
-    frame = packet.frame;
-    where = frame.where;
-    Assert.equal(where.source.actor, source.actor);
-    Assert.equal(where.line, location.line);
-    variables = frame.environment.bindings.variables;
-    Assert.equal(variables.i.value, 0);
+  packet = await executeOnNextTickAndWaitForPause(function() {
+    resume(threadClient);
+  }, client);
+  Assert.equal(packet.type, "paused");
+  why = packet.why;
+  Assert.equal(why.type, "breakpoint");
+  Assert.equal(why.actors.length, 1);
+  Assert.equal(why.actors[0], breakpointClient.actor);
+  frame = packet.frame;
+  where = frame.where;
+  Assert.equal(where.source.actor, source.actor);
+  Assert.equal(where.line, location.line);
+  variables = frame.environment.bindings.variables;
+  Assert.equal(variables.i.value, 0);
 
-    await resume(threadClient);
-    await close(client);
-
-    do_test_finished();
-  })();
-}
+  await resume(threadClient);
+}, { doNotRunWorker: true }));
--- a/devtools/server/tests/unit/test_setBreakpoint-on-line-with-multiple-statements.js
+++ b/devtools/server/tests/unit/test_setBreakpoint-on-line-with-multiple-statements.js
@@ -1,58 +1,34 @@
 "use strict";
 
-var SOURCE_URL = getFileUrl("setBreakpoint-on-line-with-multiple-statements.js");
-
-function run_test() {
-  return (async function() {
-    do_test_pending();
-
-    const { createRootActor } = require("xpcshell-test/testactors");
-    DebuggerServer.setRootActor(createRootActor);
-    DebuggerServer.init(() => true);
-
-    const global = createTestGlobal("test");
-    DebuggerServer.addTestGlobal(global);
+const SOURCE_URL = getFileUrl("setBreakpoint-on-line-with-multiple-statements.js");
 
-    const client = new DebuggerClient(DebuggerServer.connectPipe());
-    await connect(client);
-
-    const { tabs } = await listTabs(client);
-    const tab = findTab(tabs, "test");
-    const [, targetFront] = await attachTarget(client, tab);
+add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
+  const promise = waitForNewSource(threadClient, SOURCE_URL);
+  loadSubScript(SOURCE_URL, debuggee);
+  const { source } = await promise;
+  const sourceClient = threadClient.source(source);
 
-    const [, threadClient] = await attachThread(targetFront);
-    await resume(threadClient);
-
-    const promise = waitForNewSource(threadClient, SOURCE_URL);
-    loadSubScript(SOURCE_URL, global);
-    const { source } = await promise;
-    const sourceClient = threadClient.source(source);
+  const location = { line: 4 };
+  let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
+  Assert.ok(!packet.isPending);
+  Assert.equal(false, "actualLocation" in packet);
 
-    const location = { line: 4 };
-    let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
-    Assert.ok(!packet.isPending);
-    Assert.equal(false, "actualLocation" in packet);
+  packet = await executeOnNextTickAndWaitForPause(function() {
+    Cu.evalInSandbox("f()", debuggee);
+  }, client);
+  Assert.equal(packet.type, "paused");
+  const why = packet.why;
+  Assert.equal(why.type, "breakpoint");
+  Assert.equal(why.actors.length, 1);
+  Assert.equal(why.actors[0], breakpointClient.actor);
+  const frame = packet.frame;
+  const where = frame.where;
+  Assert.equal(where.source.actor, source.actor);
+  Assert.equal(where.line, location.line);
+  const variables = frame.environment.bindings.variables;
+  Assert.equal(variables.a.value.type, "undefined");
+  Assert.equal(variables.b.value.type, "undefined");
+  Assert.equal(variables.c.value.type, "undefined");
 
-    packet = await executeOnNextTickAndWaitForPause(function() {
-      Cu.evalInSandbox("f()", global);
-    }, client);
-    Assert.equal(packet.type, "paused");
-    const why = packet.why;
-    Assert.equal(why.type, "breakpoint");
-    Assert.equal(why.actors.length, 1);
-    Assert.equal(why.actors[0], breakpointClient.actor);
-    const frame = packet.frame;
-    const where = frame.where;
-    Assert.equal(where.source.actor, source.actor);
-    Assert.equal(where.line, location.line);
-    const variables = frame.environment.bindings.variables;
-    Assert.equal(variables.a.value.type, "undefined");
-    Assert.equal(variables.b.value.type, "undefined");
-    Assert.equal(variables.c.value.type, "undefined");
-
-    await resume(threadClient);
-    await close(client);
-
-    do_test_finished();
-  })();
-}
+  await resume(threadClient);
+}, { doNotRunWorker: true }));
--- a/devtools/server/tests/unit/test_setBreakpoint-on-line-with-no-offsets-in-gcd-script.js
+++ b/devtools/server/tests/unit/test_setBreakpoint-on-line-with-no-offsets-in-gcd-script.js
@@ -1,59 +1,37 @@
 "use strict";
 
-var SOURCE_URL = getFileUrl("setBreakpoint-on-line-with-no-offsets-in-gcd-script.js");
+const SOURCE_URL = getFileUrl("setBreakpoint-on-line-with-no-offsets-in-gcd-script.js");
 
-function run_test() {
-  return (async function() {
-    do_test_pending();
-
-    const global = createTestGlobal("test");
-    loadSubScriptWithOptions(SOURCE_URL, {target: global, ignoreCache: true});
-    Cu.forceGC(); Cu.forceGC(); Cu.forceGC();
+add_task(threadClientTest(async ({ threadClient, debuggee, client, targetFront }) => {
+  const promise = waitForNewSource(threadClient, SOURCE_URL);
+  loadSubScriptWithOptions(SOURCE_URL, {target: debuggee, ignoreCache: true});
+  Cu.forceGC(); Cu.forceGC(); Cu.forceGC();
 
-    const { createRootActor } = require("xpcshell-test/testactors");
-    DebuggerServer.setRootActor(createRootActor);
-    DebuggerServer.init(() => true);
-    DebuggerServer.addTestGlobal(global);
-
-    const client = new DebuggerClient(DebuggerServer.connectPipe());
-    await connect(client);
+  const { source } = await promise;
+  const sourceClient = threadClient.source(source);
 
-    const { tabs } = await listTabs(client);
-    const tab = findTab(tabs, "test");
-    const [, targetFront] = await attachTarget(client, tab);
-    const [, threadClient] = await attachThread(targetFront);
-    await resume(threadClient);
-
-    const { sources } = await getSources(threadClient);
-    const source = findSource(sources, SOURCE_URL);
-    const sourceClient = threadClient.source(source);
+  const location = { line: 7 };
+  let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
+  Assert.ok(packet.isPending);
+  Assert.equal(false, "actualLocation" in packet);
 
-    const location = { line: 7 };
-    let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
-    Assert.ok(packet.isPending);
-    Assert.equal(false, "actualLocation" in packet);
+  packet = await executeOnNextTickAndWaitForPause(function() {
+    reload(targetFront).then(function() {
+      loadSubScriptWithOptions(SOURCE_URL, {target: debuggee, ignoreCache: true});
+    });
+  }, client);
+  Assert.equal(packet.type, "paused");
+  const why = packet.why;
+  Assert.equal(why.type, "breakpoint");
+  Assert.equal(why.actors.length, 1);
+  Assert.equal(why.actors[0], breakpointClient.actor);
+  const frame = packet.frame;
+  const where = frame.where;
+  Assert.equal(where.source.actor, source.actor);
+  Assert.equal(where.line, 8);
+  const variables = frame.environment.bindings.variables;
+  Assert.equal(variables.a.value, 1);
+  Assert.equal(variables.c.value.type, "undefined");
 
-    packet = await executeOnNextTickAndWaitForPause(function() {
-      reload(targetFront).then(function() {
-        loadSubScriptWithOptions(SOURCE_URL, {target: global, ignoreCache: true});
-      });
-    }, client);
-    Assert.equal(packet.type, "paused");
-    const why = packet.why;
-    Assert.equal(why.type, "breakpoint");
-    Assert.equal(why.actors.length, 1);
-    Assert.equal(why.actors[0], breakpointClient.actor);
-    const frame = packet.frame;
-    const where = frame.where;
-    Assert.equal(where.source.actor, source.actor);
-    Assert.equal(where.line, 8);
-    const variables = frame.environment.bindings.variables;
-    Assert.equal(variables.a.value, 1);
-    Assert.equal(variables.c.value.type, "undefined");
-
-    await resume(threadClient);
-    await close(client);
-
-    do_test_finished();
-  })();
-}
+  await resume(threadClient);
+}, { doNotRunWorker: true }));
--- a/devtools/server/tests/unit/test_setBreakpoint-on-line-with-no-offsets.js
+++ b/devtools/server/tests/unit/test_setBreakpoint-on-line-with-no-offsets.js
@@ -1,58 +1,35 @@
 "use strict";
 
-var SOURCE_URL = getFileUrl("setBreakpoint-on-line-with-no-offsets.js");
-
-function run_test() {
-  return (async function() {
-    do_test_pending();
-
-    const { createRootActor } = require("xpcshell-test/testactors");
-    DebuggerServer.setRootActor(createRootActor);
-    DebuggerServer.init(() => true);
-
-    const global = createTestGlobal("test");
-    DebuggerServer.addTestGlobal(global);
+const SOURCE_URL = getFileUrl("setBreakpoint-on-line-with-no-offsets.js");
 
-    const client = new DebuggerClient(DebuggerServer.connectPipe());
-    await connect(client);
+add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
+  const promise = waitForNewSource(threadClient, SOURCE_URL);
+  loadSubScript(SOURCE_URL, debuggee);
+  const { source } = await promise;
+  const sourceClient = threadClient.source(source);
 
-    const { tabs } = await listTabs(client);
-    const tab = findTab(tabs, "test");
-    const [, targetFront] = await attachTarget(client, tab);
-    const [, threadClient] = await attachThread(targetFront);
-    await resume(threadClient);
-
-    const promise = waitForNewSource(threadClient, SOURCE_URL);
-    loadSubScript(SOURCE_URL, global);
-    const { source } = await promise;
-    const sourceClient = threadClient.source(source);
+  const location = { line: 5 };
+  let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
+  Assert.ok(!packet.isPending);
+  Assert.ok("actualLocation" in packet);
+  const actualLocation = packet.actualLocation;
+  Assert.equal(actualLocation.line, 6);
 
-    const location = { line: 5 };
-    let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
-    Assert.ok(!packet.isPending);
-    Assert.ok("actualLocation" in packet);
-    const actualLocation = packet.actualLocation;
-    Assert.equal(actualLocation.line, 6);
+  packet = await executeOnNextTickAndWaitForPause(function() {
+    Cu.evalInSandbox("f()", debuggee);
+  }, client);
+  Assert.equal(packet.type, "paused");
+  const why = packet.why;
+  Assert.equal(why.type, "breakpoint");
+  Assert.equal(why.actors.length, 1);
+  Assert.equal(why.actors[0], breakpointClient.actor);
+  const frame = packet.frame;
+  const where = frame.where;
+  Assert.equal(where.source.actor, source.actor);
+  Assert.equal(where.line, actualLocation.line);
+  const variables = frame.environment.bindings.variables;
+  Assert.equal(variables.a.value, 1);
+  Assert.equal(variables.c.value.type, "undefined");
 
-    packet = await executeOnNextTickAndWaitForPause(function() {
-      Cu.evalInSandbox("f()", global);
-    }, client);
-    Assert.equal(packet.type, "paused");
-    const why = packet.why;
-    Assert.equal(why.type, "breakpoint");
-    Assert.equal(why.actors.length, 1);
-    Assert.equal(why.actors[0], breakpointClient.actor);
-    const frame = packet.frame;
-    const where = frame.where;
-    Assert.equal(where.source.actor, source.actor);
-    Assert.equal(where.line, actualLocation.line);
-    const variables = frame.environment.bindings.variables;
-    Assert.equal(variables.a.value, 1);
-    Assert.equal(variables.c.value.type, "undefined");
-
-    await resume(threadClient);
-    await close(client);
-
-    do_test_finished();
-  })();
-}
+  await resume(threadClient);
+}, { doNotRunWorker: true }));
--- a/devtools/server/tests/unit/test_setBreakpoint-on-line.js
+++ b/devtools/server/tests/unit/test_setBreakpoint-on-line.js
@@ -1,58 +1,34 @@
 "use strict";
 
-var SOURCE_URL = getFileUrl("setBreakpoint-on-line.js");
-
-function run_test() {
-  return (async function() {
-    do_test_pending();
-
-    const { createRootActor } = require("xpcshell-test/testactors");
-    DebuggerServer.setRootActor(createRootActor);
-    DebuggerServer.init(() => true);
-
-    const global = createTestGlobal("test");
-    DebuggerServer.addTestGlobal(global);
+const SOURCE_URL = getFileUrl("setBreakpoint-on-line.js");
 
-    const client = new DebuggerClient(DebuggerServer.connectPipe());
-    await connect(client);
-
-    const { tabs } = await listTabs(client);
-    const tab = findTab(tabs, "test");
-    const [, targetFront] = await attachTarget(client, tab);
+add_task(threadClientTest(async ({ threadClient, debuggee, client }) => {
+  const promise = waitForNewSource(threadClient, SOURCE_URL);
+  loadSubScript(SOURCE_URL, debuggee);
+  const { source } = await promise;
+  const sourceClient = threadClient.source(source);
 
-    const [, threadClient] = await attachThread(targetFront);
-    await resume(threadClient);
-
-    const promise = waitForNewSource(threadClient, SOURCE_URL);
-    loadSubScript(SOURCE_URL, global);
-    const { source } = await promise;
-    const sourceClient = threadClient.source(source);
+  const location = { line: 5 };
+  let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
+  Assert.ok(!packet.isPending);
+  Assert.equal(false, "actualLocation" in packet);
 
-    const location = { line: 5 };
-    let [packet, breakpointClient] = await setBreakpoint(sourceClient, location);
-    Assert.ok(!packet.isPending);
-    Assert.equal(false, "actualLocation" in packet);
+  packet = await executeOnNextTickAndWaitForPause(function() {
+    Cu.evalInSandbox("f()", debuggee);
+  }, client);
+  Assert.equal(packet.type, "paused");
+  const why = packet.why;
+  Assert.equal(why.type, "breakpoint");
+  Assert.equal(why.actors.length, 1);
+  Assert.equal(why.actors[0], breakpointClient.actor);
+  const frame = packet.frame;
+  const where = frame.where;
+  Assert.equal(where.source.actor, source.actor);
+  Assert.equal(where.line, location.line);
+  const variables = frame.environment.bindings.variables;
+  Assert.equal(variables.a.value, 1);
+  Assert.equal(variables.b.value.type, "undefined");
+  Assert.equal(variables.c.value.type, "undefined");
 
-    packet = await executeOnNextTickAndWaitForPause(function() {
-      Cu.evalInSandbox("f()", global);
-    }, client);
-    Assert.equal(packet.type, "paused");
-    const why = packet.why;
-    Assert.equal(why.type, "breakpoint");
-    Assert.equal(why.actors.length, 1);
-    Assert.equal(why.actors[0], breakpointClient.actor);
-    const frame = packet.frame;
-    const where = frame.where;
-    Assert.equal(where.source.actor, source.actor);
-    Assert.equal(where.line, location.line);
-    const variables = frame.environment.bindings.variables;
-    Assert.equal(variables.a.value, 1);
-    Assert.equal(variables.b.value.type, "undefined");
-    Assert.equal(variables.c.value.type, "undefined");
-
-    await resume(threadClient);
-    await close(client);
-
-    do_test_finished();
-  })();
-}
+  await resume(threadClient);
+}, { doNotRunWorker: true }));