Bug 1003095 - Refactor breakpoint tests to run against multiple loaders;r=past
authorEddy Bruel <ejpbruel@mozilla.com>
Thu, 15 May 2014 16:47:12 +0200
changeset 183213 2018cc988098b19c80909ffe7b1f7e7b9860a68d
parent 183212 ef16253669f15031ef9a9fe74cc5a8c7d3854363
child 183214 46b718e4a76d4a709586dc73b9f12cffb3598dd3
child 183443 5fff5735d8fa5eaf16068107aa51898b26f187f7
push idunknown
push userunknown
push dateunknown
reviewerspast
bugs1003095
milestone32.0a1
Bug 1003095 - Refactor breakpoint tests to run against multiple loaders;r=past
toolkit/devtools/server/tests/unit/head_dbg.js
toolkit/devtools/server/tests/unit/test_breakpoint-01.js
toolkit/devtools/server/tests/unit/test_breakpoint-02.js
toolkit/devtools/server/tests/unit/test_breakpoint-03.js
toolkit/devtools/server/tests/unit/test_breakpoint-04.js
toolkit/devtools/server/tests/unit/test_breakpoint-05.js
toolkit/devtools/server/tests/unit/test_breakpoint-06.js
toolkit/devtools/server/tests/unit/test_breakpoint-07.js
toolkit/devtools/server/tests/unit/test_breakpoint-08.js
toolkit/devtools/server/tests/unit/test_breakpoint-09.js
toolkit/devtools/server/tests/unit/test_breakpoint-10.js
toolkit/devtools/server/tests/unit/test_breakpoint-11.js
toolkit/devtools/server/tests/unit/test_breakpoint-12.js
toolkit/devtools/server/tests/unit/test_breakpoint-13.js
toolkit/devtools/server/tests/unit/test_breakpoint-14.js
toolkit/devtools/server/tests/unit/test_breakpoint-15.js
toolkit/devtools/server/tests/unit/test_breakpoint-16.js
toolkit/devtools/server/tests/unit/test_breakpoint-17.js
toolkit/devtools/server/tests/unit/test_breakpoint-18.js
--- a/toolkit/devtools/server/tests/unit/head_dbg.js
+++ b/toolkit/devtools/server/tests/unit/head_dbg.js
@@ -2,22 +2,24 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cu = Components.utils;
 const Cr = Components.results;
 
-const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+const { DevToolsLoader, devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
+const worker = new DevToolsLoader(); // TODO: Replace this with the worker loader
 const {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {});
 
 const Services = devtools.require("Services");
 const DevToolsUtils = devtools.require("devtools/toolkit/DevToolsUtils.js");
 const { DebuggerServer } = devtools.require("devtools/server/main");
+const { DebuggerServer: WorkerDebuggerServer } = worker.require("devtools/server/main");
 
 // Always log packets when running tests. runxpcshelltests.py will throw
 // the output away anyway, unless you give it the --verbose flag.
 Services.prefs.setBoolPref("devtools.debugger.log", true);
 // Enable remote debugging for the relevant tests.
 Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
 
 function tryImport(url) {
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-01.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-01.js
@@ -1,31 +1,39 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Check basic breakpoint functionality.
  */
-
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_simple_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_simple_breakpoint()
 {
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let path = getFilePath('test_breakpoint-01.js');
     let location = {
       url: path,
@@ -41,17 +49,17 @@ function test_simple_breakpoint()
         do_check_eq(aPacket.why.actors[0], bpClient.actor);
         // Check that the breakpoint worked.
         do_check_eq(gDebuggee.a, 1);
         do_check_eq(gDebuggee.b, undefined);
 
         // Remove the breakpoint.
         bpClient.remove(function (aResponse) {
           gThreadClient.resume(function () {
-            finishClient(gClient);
+            gClient.close(gCallback);
           });
         });
 
       });
       // Continue until the breakpoint is hit.
       gThreadClient.resume();
 
     });
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-02.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-02.js
@@ -3,29 +3,38 @@
 
 /**
  * Check that setting breakpoints when the debuggee is running works.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_breakpoint_running();
     });
   });
-  do_test_pending();
 }
 
 function test_breakpoint_running()
 {
   gDebuggee.eval("var line0 = Error().lineNumber;\n" +
                  "var a = 1;\n" +  // line0 + 1
                  "var b = 2;\n");  // line0 + 2
 
@@ -39,12 +48,12 @@ function test_breakpoint_running()
   });
 
   gThreadClient.setBreakpoint(location, function(aResponse) {
     // Eval scripts don't stick around long enough for the breakpoint to be set,
     // so just make sure we got the expected response from the actor.
     do_check_neq(aResponse.error, "noScript");
 
     do_execute_soon(function() {
-      finishClient(gClient);
+      gClient.close(gCallback);
     });
   });
 }
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-03.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-03.js
@@ -3,31 +3,40 @@
 
 /**
  * Check that setting a breakpoint in a line without code will skip forward.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient,
                            "test-stack",
                            function (aResponse, aTabClient, aThreadClient) {
                              gThreadClient = aThreadClient;
                              test_skip_breakpoint();
                            });
   });
-  do_test_pending();
 }
 
 function test_skip_breakpoint()
 {
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let path = getFilePath('test_breakpoint-03.js');
     let location = { url: path, line: gDebuggee.line0 + 3};
     gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
@@ -44,17 +53,17 @@ function test_skip_breakpoint()
         do_check_eq(aPacket.why.actors[0], bpClient.actor);
         // Check that the breakpoint worked.
         do_check_eq(gDebuggee.a, 1);
         do_check_eq(gDebuggee.b, undefined);
 
         // Remove the breakpoint.
         bpClient.remove(function (aResponse) {
           gThreadClient.resume(function () {
-            finishClient(gClient);
+            gClient.close(gCallback);
           });
         });
 
       });
       // Continue until the breakpoint is hit.
       gThreadClient.resume();
 
     });
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-04.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-04.js
@@ -3,29 +3,38 @@
 
 /**
  * Check that setting a breakpoint in a line in a child script works.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_child_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_child_breakpoint()
 {
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let path = getFilePath('test_breakpoint-04.js');
     let location = { url: path, line: gDebuggee.line0 + 3};
     gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
@@ -40,17 +49,17 @@ function test_child_breakpoint()
         do_check_eq(aPacket.why.actors[0], bpClient.actor);
         // Check that the breakpoint worked.
         do_check_eq(gDebuggee.a, 1);
         do_check_eq(gDebuggee.b, undefined);
 
         // Remove the breakpoint.
         bpClient.remove(function (aResponse) {
           gThreadClient.resume(function () {
-            finishClient(gClient);
+            gClient.close(gCallback);
           });
         });
 
       });
       // Continue until the breakpoint is hit.
       gThreadClient.resume();
 
     });
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-05.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-05.js
@@ -4,29 +4,38 @@
 /**
  * Check that setting a breakpoint in a line without code in a child script
  * will skip forward.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_child_skip_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_child_skip_breakpoint()
 {
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let path = getFilePath('test_breakpoint-05.js');
     let location = { url: path, line: gDebuggee.line0 + 3};
     gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
@@ -42,17 +51,17 @@ function test_child_skip_breakpoint()
         do_check_eq(aPacket.why.actors[0], bpClient.actor);
         // Check that the breakpoint worked.
         do_check_eq(gDebuggee.a, 1);
         do_check_eq(gDebuggee.b, undefined);
 
         // Remove the breakpoint.
         bpClient.remove(function (aResponse) {
           gThreadClient.resume(function () {
-            finishClient(gClient);
+            gClient.close(gCallback);
           });
         });
 
       });
       // Continue until the breakpoint is hit.
       gThreadClient.resume();
 
     });
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-06.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-06.js
@@ -4,29 +4,38 @@
 /**
  * Check that setting a breakpoint in a line without code in a deeply-nested
  * child script will skip forward.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_nested_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_nested_breakpoint()
 {
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let path = getFilePath('test_breakpoint-06.js');
     let location = { url: path, line: gDebuggee.line0 + 5};
     gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
@@ -42,17 +51,17 @@ function test_nested_breakpoint()
         do_check_eq(aPacket.why.actors[0], bpClient.actor);
         // Check that the breakpoint worked.
         do_check_eq(gDebuggee.a, 1);
         do_check_eq(gDebuggee.b, undefined);
 
         // Remove the breakpoint.
         bpClient.remove(function (aResponse) {
           gThreadClient.resume(function () {
-            finishClient(gClient);
+            gClient.close(gCallback);
           });
         });
 
       });
       // Continue until the breakpoint is hit.
       gThreadClient.resume();
 
     });
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-07.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-07.js
@@ -4,29 +4,38 @@
 /**
  * Check that setting a breakpoint in a line without code in the second child
  * script will skip forward.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_second_child_skip_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_second_child_skip_breakpoint()
 {
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let path = getFilePath('test_breakpoint-07.js');
     let location = { url: path, line: gDebuggee.line0 + 6};
     gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
@@ -42,17 +51,17 @@ function test_second_child_skip_breakpoi
         do_check_eq(aPacket.why.actors[0], bpClient.actor);
         // Check that the breakpoint worked.
         do_check_eq(gDebuggee.a, 1);
         do_check_eq(gDebuggee.b, undefined);
 
         // Remove the breakpoint.
         bpClient.remove(function (aResponse) {
           gThreadClient.resume(function () {
-            finishClient(gClient);
+            gClient.close(gCallback);
           });
         });
 
       });
       // Continue until the breakpoint is hit.
       gThreadClient.resume();
 
     });
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-08.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-08.js
@@ -4,29 +4,38 @@
 /**
  * Check that setting a breakpoint in a line without code in a child script
  * will skip forward, in a file with two scripts.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_child_skip_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_child_skip_breakpoint()
 {
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let path = getFilePath('test_breakpoint-08.js');
     let location = { url: path, line: gDebuggee.line0 + 3};
     gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
@@ -42,17 +51,17 @@ function test_child_skip_breakpoint()
         do_check_eq(aPacket.why.actors[0], bpClient.actor);
         // Check that the breakpoint worked.
         do_check_eq(gDebuggee.a, 1);
         do_check_eq(gDebuggee.b, undefined);
 
         // Remove the breakpoint.
         bpClient.remove(function (aResponse) {
           gThreadClient.resume(function () {
-            finishClient(gClient);
+            gClient.close(gCallback);
           });
         });
 
       });
       // Continue until the breakpoint is hit.
       gThreadClient.resume();
 
     });
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-09.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-09.js
@@ -3,29 +3,38 @@
 
 /**
  * Check that removing a breakpoint works.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_remove_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_remove_breakpoint()
 {
   let done = false;
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let path = getFilePath('test_breakpoint-09.js');
     let location = { url: path, line: gDebuggee.line0 + 2};
@@ -68,10 +77,10 @@ function test_remove_breakpoint()
                  "  delete this.a;\n" +     // line0 + 4
                  "  foo(true);\n" +         // line0 + 5
                  "}\n" +                    // line0 + 6
                  "debugger;\n" +            // line1 + 7
                  "foo();\n");               // line1 + 8
   if (!done) {
     do_check_true(false);
   }
-  finishClient(gClient);
+  gClient.close(gCallback);
 }
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-10.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-10.js
@@ -4,29 +4,38 @@
 /**
  * Check that setting a breakpoint in a line with multiple entry points
  * triggers no matter which entry point we reach.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_child_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_child_breakpoint()
 {
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let path = getFilePath('test_breakpoint-10.js');
     let location = { url: path, line: gDebuggee.line0 + 3};
     gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
@@ -46,17 +55,17 @@ function test_child_breakpoint()
           do_check_eq(aPacket.why.type, "breakpoint");
           do_check_eq(aPacket.why.actors[0], bpClient.actor);
           // Check that the breakpoint worked.
           do_check_eq(gDebuggee.i, 1);
 
           // Remove the breakpoint.
           bpClient.remove(function (aResponse) {
             gThreadClient.resume(function () {
-              finishClient(gClient);
+              gClient.close(gCallback);
             });
           });
         });
 
         // Continue until the breakpoint is hit again.
         gThreadClient.resume();
 
       });
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-11.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-11.js
@@ -4,29 +4,38 @@
 /**
  * Make sure that setting a breakpoint in a line with bytecodes in multiple
  * scripts, sets the breakpoint in all of them (bug 793214).
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_child_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_child_breakpoint()
 {
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let path = getFilePath('test_breakpoint-11.js');
     let location = { url: path, line: gDebuggee.line0 + 2};
     gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
@@ -47,17 +56,17 @@ function test_child_breakpoint()
           do_check_eq(aPacket.why.actors[0], bpClient.actor);
           // Check that the breakpoint worked.
           do_check_eq(gDebuggee.a.b, 1);
           do_check_eq(gDebuggee.res, undefined);
 
           // Remove the breakpoint.
           bpClient.remove(function (aResponse) {
             gThreadClient.resume(function () {
-              finishClient(gClient);
+              gClient.close(gCallback);
             });
           });
         });
 
         // Continue until the breakpoint is hit again.
         gThreadClient.resume();
 
       });
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-12.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-12.js
@@ -7,30 +7,40 @@
  */
 
 const NUM_BREAKPOINTS = 10;
 var gDebuggee;
 var gClient;
 var gThreadClient;
 var gPath = getFilePath('test_breakpoint-12.js');
 var gBpActor;
-var gCount = 1;
+var gCount;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  gCount = 1;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_child_skip_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_child_skip_breakpoint()
 {
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let location = { url: gPath, line: gDebuggee.line0 + 3};
     gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
       // Check that the breakpoint has properly skipped forward one line.
@@ -83,17 +93,19 @@ function set_breakpoints(location) {
       do_check_eq(gDebuggee.b, undefined);
 
       gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
         // We don't expect any more pauses after the breakpoint was hit once.
         do_check_true(false);
       });
       gThreadClient.resume(function () {
         // Give any remaining breakpoints a chance to trigger.
-        do_timeout(1000, finishClient.bind(null, gClient));
+        do_timeout(1000, function () {
+          gClient.close(gCallback);
+        });
       });
 
     });
     // Continue until the breakpoint is hit.
     gThreadClient.resume();
   });
 
 }
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-13.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-13.js
@@ -4,29 +4,38 @@
 /**
  * Check that execution doesn't pause twice while stepping, when encountering
  * either a breakpoint or a debugger statement.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_simple_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_simple_breakpoint()
 {
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let path = getFilePath('test_breakpoint-13.js');
     let location = { url: path, line: gDebuggee.line0 + 2};
     gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
@@ -65,17 +74,17 @@ function test_simple_breakpoint()
 
                 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
                   // Check that the debugger statement wasn't the reason for this pause.
                   do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 7);
                   do_check_neq(aPacket.why.type, "debuggerStatement");
                   do_check_eq(aPacket.why.type, "resumeLimit");
 
                   // Remove the breakpoint and finish.
-                  bpClient.remove(() => gThreadClient.resume(() => finishClient(gClient)));
+                  bpClient.remove(() => gThreadClient.resume(() => gClient.close(gCallback)));
 
                 });
                 // Step past the debugger statement.
                 gThreadClient.stepIn();
               });
               // Step into the debugger statement.
               gThreadClient.stepIn();
             });
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-14.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-14.js
@@ -4,29 +4,38 @@
 /**
  * Check that a breakpoint or a debugger statement cause execution to pause even
  * in a stepped-over function.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_simple_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_simple_breakpoint()
 {
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let path = getFilePath('test_breakpoint-14.js');
     let location = { url: path, line: gDebuggee.line0 + 2};
     gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
@@ -64,17 +73,17 @@ function test_simple_breakpoint()
 
                 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
                   // Check that the debugger statement wasn't the reason for this pause.
                   do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 7);
                   do_check_neq(aPacket.why.type, "debuggerStatement");
                   do_check_eq(aPacket.why.type, "resumeLimit");
 
                   // Remove the breakpoint and finish.
-                  bpClient.remove(() => gThreadClient.resume(() => finishClient(gClient)));
+                  bpClient.remove(() => gThreadClient.resume(() => gClient.close(gCallback)));
 
                 });
                 // Step past the debugger statement.
                 gThreadClient.stepOver();
               });
               // Step over the debugger statement.
               gThreadClient.stepOver();
             });
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-15.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-15.js
@@ -3,29 +3,38 @@
 
 /**
  * Check that adding a breakpoint in the same place returns the same actor.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-stack");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-stack", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_same_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_same_breakpoint()
 {
   gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
     let path = getFilePath('test_breakpoint-01.js');
     let location = {
       url: path,
@@ -39,17 +48,17 @@ function test_same_breakpoint()
           url: path,
           line: gDebuggee.line0 + 2,
           column: 6
         };
         gThreadClient.setBreakpoint(location, function (aResponse, bpClient) {
           gThreadClient.setBreakpoint(location, function (aResponse, secondBpClient) {
             do_check_eq(bpClient.actor, secondBpClient.actor,
                         "Should get the same actor column breakpoints");
-            finishClient(gClient);
+            gClient.close(gCallback);
           });
         });
       });
     });
 
   });
 
   Components.utils.evalInSandbox("var line0 = Error().lineNumber;\n" +
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-16.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-16.js
@@ -3,31 +3,40 @@
 
 /**
  * Check that we can set breakpoints in columns, not just lines.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-breakpoints");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-breakpoints", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient,
                            "test-breakpoints",
                            function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_column_breakpoint();
     });
   });
-  do_test_pending();
 }
 
 function test_column_breakpoint()
 {
   const location = {
     url: "https://example.com/foo.js",
     line: 1,
     column: 55
@@ -48,17 +57,17 @@ function test_column_breakpoint()
 
         do_check_eq(gDebuggee.acc, timesBreakpointHit);
         do_check_eq(aPacket.frame.environment.bindings.variables.i.value,
                     timesBreakpointHit);
 
         if (++timesBreakpointHit === 3) {
           gThreadClient.removeListener("paused", _onPaused);
           bpClient.remove(function (aResponse) {
-            gThreadClient.resume(() => finishClient(gClient));
+            gThreadClient.resume(() => gClient.close(gCallback));
           });
         } else {
           gThreadClient.resume();
         }
       });
 
       // Continue until the breakpoint is hit.
       gThreadClient.resume();
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-17.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-17.js
@@ -4,29 +4,36 @@
 /**
  * Test that when we add 2 breakpoints to the same line at different columns and
  * then remove one of them, we don't remove them both.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-breakpoints");
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  run_test_with_server(DebuggerServer, do_test_finished);
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-breakpoints", aServer);
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function() {
     attachTestTabAndResume(gClient, "test-breakpoints", function(aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       test_breakpoints_columns();
     });
   });
-  do_test_pending();
 }
 
 const URL = "http://example.com/benderbendingrodriguez.js";
 
 const code =
 "(" + function (global) {
   global.foo = function () {
     Math.abs(-1); Math.log(0.5);
@@ -99,17 +106,17 @@ function test_remove_one(aFirst, aSecond
         return;
       }
 
       if (why.type == "debuggerStatement") {
         gClient.removeListener("paused", _onPaused);
         do_check_true(hitSecond,
                       "We should still hit `second`, but not `first`.");
 
-        finishClient(gClient);
+        gClient.close(gCallback);
         return;
       }
 
       do_check_true(false, "Should never get here");
     });
 
     gThreadClient.resume(() => gDebuggee.foo());
   });
--- a/toolkit/devtools/server/tests/unit/test_breakpoint-18.js
+++ b/toolkit/devtools/server/tests/unit/test_breakpoint-18.js
@@ -4,32 +4,41 @@
 /**
  * Check that we only break on offsets that are entry points for the line we are
  * breaking on. Bug 907278.
  */
 
 var gDebuggee;
 var gClient;
 var gThreadClient;
+var gCallback;
 
 function run_test()
 {
-  initTestDebuggerServer();
-  gDebuggee = addTestGlobal("test-breakpoints");
+  run_test_with_server(DebuggerServer, function () {
+    run_test_with_server(WorkerDebuggerServer, do_test_finished);
+  });
+  do_test_pending();
+};
+
+function run_test_with_server(aServer, aCallback)
+{
+  gCallback = aCallback;
+  initTestDebuggerServer(aServer);
+  gDebuggee = addTestGlobal("test-breakpoints", aServer);
   gDebuggee.console = { log: x => void x };
-  gClient = new DebuggerClient(DebuggerServer.connectPipe());
+  gClient = new DebuggerClient(aServer.connectPipe());
   gClient.connect(function () {
     attachTestTabAndResume(gClient,
                            "test-breakpoints",
                            function (aResponse, aTabClient, aThreadClient) {
       gThreadClient = aThreadClient;
       setUpCode();
     });
   });
-  do_test_pending();
 }
 
 const URL = "test.js";
 
 function setUpCode() {
   gClient.addOneTimeListener("newSource", setBreakpoint);
   Cu.evalInSandbox(
     "" + function test() {
@@ -64,10 +73,10 @@ function testBPHit(event, { why }) {
 }
 
 function testDbgStatement(event, { why }) {
   // Should continue to the debugger statement.
   do_check_eq(why.type, "debuggerStatement");
   // Not break on another offset from the same line (that isn't an entry point
   // to the line)
   do_check_neq(why.type, "breakpoint");
-  finishClient(gClient);
+  gClient.close(gCallback);
 }