Bug 876277 - Cleanup remaining debugger tests, r=past
authorVictor Porof <vporof@mozilla.com>
Fri, 13 Sep 2013 16:23:19 +0300
changeset 147090 862a066d90d573b13f3157b4fd286061496bb29a
parent 147089 5f626c9dd0660bbbd145616119b884dcab404a37
child 147091 bc767637c93224ae7ac43735470713f4257a60b4
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerspast
bugs876277
milestone26.0a1
Bug 876277 - Cleanup remaining debugger tests, r=past
browser/devtools/debugger/test/browser_dbg_aaa_run_first_leaktest.js
browser/devtools/debugger/test/browser_dbg_bfcache.js
browser/devtools/debugger/test/browser_dbg_breadcrumbs-access.js
browser/devtools/debugger/test/browser_dbg_break-on-dom-event.js
browser/devtools/debugger/test/browser_dbg_bug727429_watch-expressions-01.js
browser/devtools/debugger/test/browser_dbg_bug727429_watch-expressions-02.js
browser/devtools/debugger/test/browser_dbg_bug731394_editor-contextmenu.js
browser/devtools/debugger/test/browser_dbg_bug868163_highight_on_pause.js
browser/devtools/debugger/test/browser_dbg_bug883220_raise_on_pause.js
browser/devtools/debugger/test/browser_dbg_chrome-create.js
browser/devtools/debugger/test/browser_dbg_chrome-debugging.js
browser/devtools/debugger/test/browser_dbg_clean-exit.js
browser/devtools/debugger/test/browser_dbg_cmd-blackbox.js
browser/devtools/debugger/test/browser_dbg_cmd-break.js
browser/devtools/debugger/test/browser_dbg_cmd-dbg.js
browser/devtools/debugger/test/browser_dbg_cmd.js
browser/devtools/debugger/test/browser_dbg_cmd_blackbox.js
browser/devtools/debugger/test/browser_dbg_cmd_break.js
browser/devtools/debugger/test/browser_dbg_createChrome.js
browser/devtools/debugger/test/browser_dbg_debugger-statement.js
browser/devtools/debugger/test/browser_dbg_debuggerstatement.js
browser/devtools/debugger/test/browser_dbg_displayName.js
browser/devtools/debugger/test/browser_dbg_editor-contextmenu.js
browser/devtools/debugger/test/browser_dbg_event-listeners.js
browser/devtools/debugger/test/browser_dbg_function-display-name.js
browser/devtools/debugger/test/browser_dbg_globalactor-01.js
browser/devtools/debugger/test/browser_dbg_globalactor.js
browser/devtools/debugger/test/browser_dbg_iframes.js
browser/devtools/debugger/test/browser_dbg_instruments-pane-collapse.js
browser/devtools/debugger/test/browser_dbg_listaddons.js
browser/devtools/debugger/test/browser_dbg_listtabs-01.js
browser/devtools/debugger/test/browser_dbg_listtabs-02.js
browser/devtools/debugger/test/browser_dbg_multiple-windows.js
browser/devtools/debugger/test/browser_dbg_nav-01.js
browser/devtools/debugger/test/browser_dbg_navigation.js
browser/devtools/debugger/test/browser_dbg_on-pause-highlight.js
browser/devtools/debugger/test/browser_dbg_on-pause-raise.js
browser/devtools/debugger/test/browser_dbg_pane-collapse.js
browser/devtools/debugger/test/browser_dbg_panel-size.js
browser/devtools/debugger/test/browser_dbg_panesize-inner.js
browser/devtools/debugger/test/browser_dbg_pause-exceptions-01.js
browser/devtools/debugger/test/browser_dbg_pause-exceptions-02.js
browser/devtools/debugger/test/browser_dbg_pause-exceptions-reload.js
browser/devtools/debugger/test/browser_dbg_pause-exceptions.js
browser/devtools/debugger/test/browser_dbg_pause-resume.js
browser/devtools/debugger/test/browser_dbg_pause-warning.js
browser/devtools/debugger/test/browser_dbg_progress-listener-bug.js
browser/devtools/debugger/test/browser_dbg_propertyview-filter-04.js
browser/devtools/debugger/test/browser_dbg_propertyview-filter-07.js
browser/devtools/debugger/test/browser_dbg_reload-preferred-script-01.js
browser/devtools/debugger/test/browser_dbg_reload-preferred-script.js
browser/devtools/debugger/test/browser_dbg_reload-same-script.js
browser/devtools/debugger/test/browser_dbg_step-out.js
browser/devtools/debugger/test/browser_dbg_tabactor-01.js
browser/devtools/debugger/test/browser_dbg_tabactor-02.js
browser/devtools/debugger/test/browser_dbg_watch-expressions-01.js
browser/devtools/debugger/test/browser_dbg_watch-expressions-02.js
--- a/browser/devtools/debugger/test/browser_dbg_aaa_run_first_leaktest.js
+++ b/browser/devtools/debugger/test/browser_dbg_aaa_run_first_leaktest.js
@@ -1,73 +1,28 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
- * This tests if the debugger leaks.
+ * This tests if the debugger leaks on initialization and sudden destruction.
+ * You can also use this initialization format as a template for other tests.
  * If leaks happen here, there's something very, very fishy going on.
  */
 
-const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
-
-let gPane = null;
-let gTab = null;
-let gDebuggee = null;
-let gDebugger = null;
+const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
 
-function test()
-{
-  let scriptShown = false;
-  let framesAdded = false;
-  let resumed = false;
-  let testStarted = false;
-
+function test() {
   // Wait longer for this very simple test that comes first, to make sure that
   // GC from previous tests does not interfere with the debugger suite.
   requestLongerTimeout(2);
 
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
-    gTab = aTab;
-    gDebuggee = aDebuggee;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
-    resumed = true;
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
+    ok(aTab, "Should have a tab available.");
+    ok(aDebuggee, "Should have a debuggee available.");
+    ok(aPanel, "Should have a debugger pane available.");
 
-    gDebugger.addEventListener("Debugger:SourceShown", onScriptShown);
-
-    gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
-      framesAdded = true;
-      executeSoon(startTest);
+    waitForSourceAndCaretAndScopes(aPanel, "-02.js", 6).then(() => {
+      resumeDebuggerThenCloseAndFinish(aPanel);
     });
 
-    executeSoon(function() {
-      gDebuggee.firstCall();
-    });
-  });
-
-  function onScriptShown(aEvent)
-  {
-    scriptShown = aEvent.detail.url.indexOf("-02.js") != -1;
-    executeSoon(startTest);
-  }
-
-  function startTest()
-  {
-    if (scriptShown && framesAdded && resumed && !testStarted) {
-      gDebugger.removeEventListener("Debugger:SourceShown", onScriptShown);
-      testStarted = true;
-      Services.tm.currentThread.dispatch({ run: performTest }, 0);
-    }
-  }
-
-  function performTest()
-  {
-    closeDebuggerAndFinish();
-  }
-
-  registerCleanupFunction(function() {
-    removeTab(gTab);
-    gPane = null;
-    gTab = null;
-    gDebuggee = null;
-    gDebugger = null;
+    aDebuggee.firstCall();
   });
 }
--- a/browser/devtools/debugger/test/browser_dbg_bfcache.js
+++ b/browser/devtools/debugger/test/browser_dbg_bfcache.js
@@ -1,129 +1,92 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
- * Make sure that the debugger is updated with the correct scripts when moving
+ * Make sure that the debugger is updated with the correct sources when moving
  * back and forward in the tab.
  */
 
-const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
-var gPane = null;
-var gTab = null;
-var gDebuggee = null;
-var gDebugger = null;
-var gSources = null;
+const TAB_URL_1 = EXAMPLE_URL + "doc_script-switching-01.html";
+const TAB_URL_2 = EXAMPLE_URL + "doc_recursion-stack.html";
 
-function test()
-{
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
+let gTab, gDebuggee, gPanel, gDebugger;
+let gSources;
+
+function test() {
+  initDebugger(TAB_URL_1).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
     gDebuggee = aDebuggee;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gSources = gDebugger.DebuggerView.Sources;
 
-    testInitialLoad();
+    testFirstPage()
+      .then(testLocationChange)
+      .then(testBack)
+      .then(testForward)
+      .then(() => closeDebuggerAndFinish(gPanel))
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
   });
 }
 
-function testInitialLoad() {
-  gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
-    executeSoon(function() {
-      validateFirstPage();
-      testLocationChange();
-    });
-  });
-
-  gDebuggee.firstCall();
-}
+function testFirstPage() {
+  info("Testing first page.");
 
-function testLocationChange()
-{
-  gDebugger.DebuggerController.activeThread.resume(function() {
-    gDebugger.DebuggerController._target.once("navigate", function onTabNavigated(aEvent, aPacket) {
-      ok(true, "tabNavigated event was fired.");
-      info("Still attached to the tab.");
+  // Spin the event loop before causing the debuggee to pause, to allow
+  // this function to return first.
+  executeSoon(() => gDebuggee.firstCall());
 
-      gDebugger.addEventListener("Debugger:AfterSourcesAdded", function _onEvent(aEvent) {
-        gDebugger.removeEventListener(aEvent.type, _onEvent);
-
-        executeSoon(function() {
-          validateSecondPage();
-          testBack();
-        });
-      });
-    });
-    gDebugger.DebuggerController.client.activeTab.navigateTo(STACK_URL);
+  return waitForSourceAndCaretAndScopes(gPanel, "-02.js", 6).then(() => {
+    validateFirstPage();
   });
 }
 
-function testBack()
-{
-  gDebugger.DebuggerController._target.once("navigate", function onTabNavigated(aEvent, aPacket) {
-    ok(true, "tabNavigated event was fired after going back.");
-    info("Still attached to the tab.");
-
-    gDebugger.addEventListener("Debugger:AfterSourcesAdded", function _onEvent(aEvent) {
-      gDebugger.removeEventListener(aEvent.type, _onEvent);
+function testLocationChange() {
+  info("Navigating to a different page.");
 
-      executeSoon(function() {
-        validateFirstPage();
-        testForward();
-      });
-    });
+  return navigateActiveTabTo(gPanel, TAB_URL_2, gDebugger.EVENTS.SOURCES_ADDED).then(() => {
+    validateSecondPage();
   });
-
-  info("Going back.");
-  content.history.back();
 }
 
-function testForward()
-{
-  gDebugger.DebuggerController._target.once("navigate", function onTabNavigated(aEvent, aPacket) {
-    ok(true, "tabNavigated event was fired after going forward.");
-    info("Still attached to the tab.");
-
-    gDebugger.addEventListener("Debugger:AfterSourcesAdded", function _onEvent(aEvent) {
-      gDebugger.removeEventListener(aEvent.type, _onEvent);
+function testBack() {
+  info("Going back.");
 
-      executeSoon(function() {
-        validateSecondPage();
-        closeDebuggerAndFinish();
-      });
-    });
+  return navigateActiveTabInHistory(gPanel, "back", gDebugger.EVENTS.SOURCES_ADDED).then(() => {
+    validateFirstPage();
   });
+}
 
+function testForward() {
   info("Going forward.");
-  content.history.forward();
+
+  return navigateActiveTabInHistory(gPanel, "forward", gDebugger.EVENTS.SOURCES_ADDED).then(() => {
+    validateSecondPage();
+  });
 }
 
 function validateFirstPage() {
-  gSources = gDebugger.DebuggerView.Sources;
-
   is(gSources.itemCount, 2,
-    "Found the expected number of scripts.");
-
-  ok(gDebugger.DebuggerView.Sources.containsLabel("test-script-switching-01.js"),
-     "Found the first script label.");
-  ok(gDebugger.DebuggerView.Sources.containsLabel("test-script-switching-02.js"),
-     "Found the second script label.");
+    "Found the expected number of sources.");
+  ok(gSources.containsLabel("code_script-switching-01.js"),
+    "Found the first source label.");
+  ok(gSources.containsLabel("code_script-switching-02.js"),
+    "Found the second source label.");
 }
 
 function validateSecondPage() {
-  gSources = gDebugger.DebuggerView.Sources;
-
   is(gSources.itemCount, 1,
-    "Found the expected number of scripts.");
-
-  ok(gDebugger.DebuggerView.Sources.containsLabel("browser_dbg_stack.html"),
-     "Found the single script label.");
+    "Found the expected number of sources.");
+  ok(gSources.containsLabel("doc_recursion-stack.html"),
+    "Found the single source label.");
 }
 
 registerCleanupFunction(function() {
-  removeTab(gTab);
-  gPane = null;
   gTab = null;
   gDebuggee = null;
+  gPanel = null;
   gDebugger = null;
   gSources = null;
 });
--- a/browser/devtools/debugger/test/browser_dbg_breadcrumbs-access.js
+++ b/browser/devtools/debugger/test/browser_dbg_breadcrumbs-access.js
@@ -1,154 +1,89 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
+/**
+ * Tests if the stackframe breadcrumbs are keyboard accessible.
+ */
 
-let gPane = null;
-let gTab = null;
-let gDebuggee = null;
-let gDebugger = null;
+const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
 
-function test()
-{
-  let scriptShown = false;
-  let framesAdded = false;
-  let resumed = false;
-  let testStarted = false;
+function test() {
+  let gTab, gDebuggee, gPanel, gDebugger;
+  let gSources, gFrames;
 
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
     gDebuggee = aDebuggee;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
-    resumed = true;
-
-    gDebugger.addEventListener("Debugger:SourceShown", onScriptShown);
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gSources = gDebugger.DebuggerView.Sources;
+    gFrames = gDebugger.DebuggerView.StackFrames;
 
-    gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
-      framesAdded = true;
-      executeSoon(startTest);
-    });
+    waitForSourceAndCaretAndScopes(gPanel, "-02.js", 6)
+      .then(checkNavigationWhileNotFocused)
+      .then(focusCurrentStackFrame)
+      .then(checkNavigationWhileFocused)
+      .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
 
-    executeSoon(function() {
-      gDebuggee.firstCall();
-    });
+    gDebuggee.firstCall();
   });
 
-  function onScriptShown(aEvent)
-  {
-    scriptShown = aEvent.detail.url.indexOf("-02.js") != -1;
-    executeSoon(startTest);
-  }
-
-  function startTest()
-  {
-    if (scriptShown && framesAdded && resumed && !testStarted) {
-      gDebugger.removeEventListener("Debugger:SourceShown", onScriptShown);
-      testStarted = true;
-      Services.tm.currentThread.dispatch({ run: performTest }, 0);
-    }
-  }
-
-  function performTest()
-  {
-    let editor = gDebugger.DebuggerView.editor;
-    let sources = gDebugger.DebuggerView.Sources;
-    let stackframes = gDebugger.DebuggerView.StackFrames;
-
-    is(editor.getCaretPosition().line, 5,
-      "The source editor caret position was incorrect (1).");
-    is(sources.selectedLabel, "test-script-switching-02.js",
-      "The currently selected source is incorrect (1).");
-    is(stackframes.selectedIndex, 3,
-      "The currently selected stackframe is incorrect (1).");
+  function checkNavigationWhileNotFocused() {
+    checkState({ frame: 3, source: 1, line: 6 });
 
     EventUtils.sendKey("DOWN", gDebugger);
-    is(editor.getCaretPosition().line, 6,
-      "The source editor caret position was incorrect (2).");
-    is(sources.selectedLabel, "test-script-switching-02.js",
-      "The currently selected source is incorrect (2).");
-    is(stackframes.selectedIndex, 3,
-      "The currently selected stackframe is incorrect (2).");
+    checkState({ frame: 3, source: 1, line: 7 });
 
     EventUtils.sendKey("UP", gDebugger);
-    is(editor.getCaretPosition().line, 5,
-      "The source editor caret position was incorrect (3).");
-    is(sources.selectedLabel, "test-script-switching-02.js",
-      "The currently selected source is incorrect (3).");
-    is(stackframes.selectedIndex, 3,
-      "The currently selected stackframe is incorrect (3).");
+    checkState({ frame: 3, source: 1, line: 6 });
+  }
 
-
+  function focusCurrentStackFrame() {
     EventUtils.sendMouseEvent({ type: "mousedown" },
-      stackframes.selectedItem.target,
+      gFrames.selectedItem.target,
       gDebugger);
+  }
 
+  function checkNavigationWhileFocused() {
+    let deferred = promise.defer();
 
     EventUtils.sendKey("UP", gDebugger);
-    is(editor.getCaretPosition().line, 5,
-      "The source editor caret position was incorrect (4).");
-    is(sources.selectedLabel, "test-script-switching-02.js",
-      "The currently selected source is incorrect (4).");
-    is(stackframes.selectedIndex, 2,
-      "The currently selected stackframe is incorrect (4).");
+    checkState({ frame: 2, source: 1, line: 6 });
 
-    gDebugger.addEventListener("Debugger:SourceShown", function _onEvent(aEvent) {
-      gDebugger.removeEventListener(aEvent.type, _onEvent);
-
-      is(editor.getCaretPosition().line, 4,
-        "The source editor caret position was incorrect (5).");
-      is(sources.selectedLabel, "test-script-switching-01.js",
-        "The currently selected source is incorrect (5).");
-      is(stackframes.selectedIndex, 1,
-        "The currently selected stackframe is incorrect (5).");
+    waitForSourceAndCaret(gPanel, "-01.js", 5).then(() => {
+      checkState({ frame: 1, source: 0, line: 5 });
 
       EventUtils.sendKey("UP", gDebugger);
-
-      is(editor.getCaretPosition().line, 4,
-        "The source editor caret position was incorrect (6).");
-      is(sources.selectedLabel, "test-script-switching-01.js",
-        "The currently selected source is incorrect (6).");
-      is(stackframes.selectedIndex, 0,
-        "The currently selected stackframe is incorrect (6).");
-
-      gDebugger.addEventListener("Debugger:SourceShown", function _onEvent(aEvent) {
-        gDebugger.removeEventListener(aEvent.type, _onEvent);
+      checkState({ frame: 0, source: 0, line: 5 });
 
-        is(editor.getCaretPosition().line, 5,
-          "The source editor caret position was incorrect (7).");
-        is(sources.selectedLabel, "test-script-switching-02.js",
-          "The currently selected source is incorrect (7).");
-        is(stackframes.selectedIndex, 3,
-          "The currently selected stackframe is incorrect (7).");
+      waitForSourceAndCaret(gPanel, "-02.js", 6).then(() => {
+        checkState({ frame: 3, source: 1, line: 6 });
 
-        gDebugger.addEventListener("Debugger:SourceShown", function _onEvent(aEvent) {
-          gDebugger.removeEventListener(aEvent.type, _onEvent);
-
-          is(editor.getCaretPosition().line, 4,
-            "The source editor caret position was incorrect (8).");
-          is(sources.selectedLabel, "test-script-switching-01.js",
-            "The currently selected source is incorrect (8).");
-          is(stackframes.selectedIndex, 0,
-            "The currently selected stackframe is incorrect (8).");
-
-          closeDebuggerAndFinish();
+        waitForSourceAndCaret(gPanel, "-01.js", 5).then(() => {
+          checkState({ frame: 0, source: 0, line: 5 });
+          deferred.resolve();
         });
 
-        EventUtils.sendKey("HOME", gDebugger);
+        EventUtils.sendKey("HOME", gDebugger)
       });
 
-      EventUtils.sendKey("END", gDebugger);
+      EventUtils.sendKey("END", gDebugger)
     });
 
-    EventUtils.sendKey("UP", gDebugger);
+    EventUtils.sendKey("UP", gDebugger)
+
+    return deferred.promise;
   }
 
-  registerCleanupFunction(function() {
-    removeTab(gTab);
-    gPane = null;
-    gTab = null;
-    gDebuggee = null;
-    gDebugger = null;
-  });
+  function checkState({ frame, source, line }) {
+    is(gFrames.selectedIndex, frame,
+      "The currently selected stackframe is incorrect.");
+    is(gSources.selectedIndex, source,
+      "The currently selected source is incorrect.");
+    ok(isCaretPos(gPanel, line),
+      "The source editor caret position was incorrect.");
+  }
 }
--- a/browser/devtools/debugger/test/browser_dbg_break-on-dom-event.js
+++ b/browser/devtools/debugger/test/browser_dbg_break-on-dom-event.js
@@ -1,197 +1,230 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that the break-on-dom-events request works.
  */
 
-// Tests that the break-on-dom-events request works.
+const TAB_URL = EXAMPLE_URL + "doc_event-listeners.html";
+
+let gClient, gThreadClient, gInput, gButton;
 
-var gClient = null;
-var gTab = null;
-var gThreadClient = null;
-var gInput = null;
-var gButton = null;
-const DEBUGGER_TAB_URL = EXAMPLE_URL + "test-event-listeners.html";
+function test() {
+  if (!DebuggerServer.initialized) {
+    DebuggerServer.init(() => true);
+    DebuggerServer.addBrowserActors();
+  }
 
-function test()
-{
   let transport = DebuggerServer.connectPipe();
   gClient = new DebuggerClient(transport);
-  gClient.connect(function(type, traits) {
-    gTab = addTab(DEBUGGER_TAB_URL, function() {
-      attach_thread_actor_for_url(gClient,
-                                  DEBUGGER_TAB_URL,
-                                  function(threadClient) {
-        gThreadClient = threadClient;
-        gInput = content.document.querySelector("input");
-        gButton = content.document.querySelector("button");
-        testBreakOnAll();
+  gClient.connect((aType, aTraits) => {
+    is(aType, "browser",
+      "Root actor should identify itself as a browser.");
+
+    addTab(TAB_URL)
+      .then(() => attachThreadActorForUrl(gClient, TAB_URL))
+      .then(setupGlobals)
+      .then(pauseDebuggee)
+      .then(testBreakOnAll)
+      .then(testBreakOnDisabled)
+      .then(testBreakOnNone)
+      .then(testBreakOnClick)
+      .then(closeConnection)
+      .then(finish)
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
       });
-    });
   });
 }
 
+function setupGlobals(aThreadClient) {
+  gThreadClient = aThreadClient;
+  gInput = content.document.querySelector("input");
+  gButton = content.document.querySelector("button");
+}
+
+function pauseDebuggee() {
+  let deferred = promise.defer();
+
+  gClient.addOneTimeListener("paused", (aEvent, aPacket) => {
+    is(aPacket.type, "paused",
+      "We should now be paused.");
+    is(aPacket.why.type, "debuggerStatement",
+      "The debugger statement was hit.");
+
+    deferred.resolve();
+  });
+
+  // Spin the event loop before causing the debuggee to pause, to allow
+  // this function to return first.
+  executeSoon(triggerButtonClick);
+
+  return deferred.promise;
+}
+
 // Test pause on all events.
-function testBreakOnAll()
-{
-  gClient.addOneTimeListener("paused", function(event, packet) {
-    is(packet.why.type, "debuggerStatement", "debugger statement was hit.");
-    // Test calling pauseOnDOMEvents from a paused state.
-    gThreadClient.pauseOnDOMEvents("*", function(packet) {
-      is(packet, undefined, "The pause-on-any-event request completed successfully.");
+function testBreakOnAll() {
+  let deferred = promise.defer();
 
-      gClient.addOneTimeListener("paused", function(event, packet) {
-        is(packet.why.type, "pauseOnDOMEvents", "A hidden breakpoint was hit.");
-        is(packet.frame.callee.name, "keyupHandler", "The keyupHandler is entered.");
+  // Test calling pauseOnDOMEvents from a paused state.
+  gThreadClient.pauseOnDOMEvents("*", (aPacket) => {
+    is(aPacket, undefined,
+      "The pause-on-any-event request completed successfully.");
+
+    gClient.addOneTimeListener("paused", (aEvent, aPacket) => {
+      is(aPacket.why.type, "pauseOnDOMEvents",
+        "A hidden breakpoint was hit.");
+      is(aPacket.frame.callee.name, "keyupHandler",
+        "The keyupHandler is entered.");
 
-        gClient.addOneTimeListener("paused", function(event, packet) {
-          is(packet.why.type, "pauseOnDOMEvents", "A hidden breakpoint was hit.");
-          is(packet.frame.callee.name, "clickHandler", "The clickHandler is entered.");
-
-          gClient.addOneTimeListener("paused", function(event, packet) {
-            is(packet.why.type, "pauseOnDOMEvents", "A hidden breakpoint was hit.");
-            is(packet.frame.callee.name, "onchange", "The onchange handler is entered.");
+      gClient.addOneTimeListener("paused", (aEvent, aPacket) => {
+        is(aPacket.why.type, "pauseOnDOMEvents",
+          "A hidden breakpoint was hit.");
+        is(aPacket.frame.callee.name, "clickHandler",
+          "The clickHandler is entered.");
 
-            gThreadClient.resume(testBreakOnDisabled);
-          });
+        gClient.addOneTimeListener("paused", (aEvent, aPacket) => {
+          is(aPacket.why.type, "pauseOnDOMEvents",
+            "A hidden breakpoint was hit.");
+          is(aPacket.frame.callee.name, "onchange",
+            "The onchange handler is entered.");
 
-          gThreadClient.resume(function() {
-            gInput.focus();
-            gInput.value = "foo";
-            gInput.blur();
-          });
+          gThreadClient.resume(deferred.resolve);
         });
 
-        gThreadClient.resume(function() {
-          EventUtils.sendMouseEvent({ type: "click" }, gButton);
-        });
+        gThreadClient.resume(triggerInputChange);
       });
 
-      gThreadClient.resume(function() {
-        // Make sure that the focus is not on the input box so that a focus event
-        // will be triggered.
-        window.focus();
-        gBrowser.selectedBrowser.focus();
-        gButton.focus();
+      gThreadClient.resume(triggerButtonClick);
+    });
 
-        // Focus the element and wait for focus event.
-        gInput.addEventListener("focus", function onfocus() {
-          gInput.removeEventListener("focus", onfocus, false);
-          executeSoon(function() {
-            EventUtils.synthesizeKey("e", { shiftKey: 1 }, content);
-          });
-        }, false);
-
-        gInput.focus();
-      });
-    });
+    gThreadClient.resume(triggerInputKeyup);
   });
 
-  EventUtils.sendMouseEvent({ type: "click" }, gButton);
+  return deferred.promise;
 }
 
 // Test that removing events from the array disables them.
-function testBreakOnDisabled()
-{
+function testBreakOnDisabled() {
+  let deferred = promise.defer();
+
   // Test calling pauseOnDOMEvents from a running state.
-  gThreadClient.pauseOnDOMEvents(["click"], function(packet) {
-    is(packet.error, undefined, "The pause-on-click-only request completed successfully.");
+  gThreadClient.pauseOnDOMEvents(["click"], (aPacket) => {
+    is(aPacket.error, undefined,
+      "The pause-on-click-only request completed successfully.");
 
     gClient.addListener("paused", unexpectedListener);
 
     // This non-capturing event listener is guaranteed to run after the page's
     // capturing one had a chance to execute and modify window.foobar.
-    gInput.addEventListener("keyup", function tempHandler() {
-      gInput.removeEventListener("keyup", tempHandler, false);
-      is(content.wrappedJSObject.foobar, "keyupHandler", "No hidden breakpoint was hit.");
-      gClient.removeListener("paused", unexpectedListener);
-      testBreakOnNone();
-    }, false);
+    once(gInput, "keyup").then(() => {
+      is(content.wrappedJSObject.foobar, "keyupHandler",
+        "No hidden breakpoint was hit.");
 
-    // Make sure that the focus is not on the input box so that a focus event
-    // will be triggered.
-    window.focus();
-    gBrowser.selectedBrowser.focus();
-    gButton.focus();
+      gClient.removeListener("paused", unexpectedListener);
+      deferred.resolve();
+    });
 
-    // Focus the element and wait for focus event.
-    gInput.addEventListener("focus", function onfocus() {
-      gInput.removeEventListener("focus", onfocus, false);
-      executeSoon(function() {
-        EventUtils.synthesizeKey("e", { shiftKey: 1 }, content);
-      });
-    }, false);
+    triggerInputKeyup();
+  });
 
-    gInput.focus();
-  });
+  return deferred.promise;
 }
 
 // Test that specifying an empty event array clears all hidden breakpoints.
-function testBreakOnNone()
-{
+function testBreakOnNone() {
+  let deferred = promise.defer();
+
   // Test calling pauseOnDOMEvents from a running state.
-  gThreadClient.pauseOnDOMEvents([], function(packet) {
-    is(packet.error, undefined, "The pause-on-none request completed successfully.");
+  gThreadClient.pauseOnDOMEvents([], (aPacket) => {
+    is(aPacket.error, undefined,
+      "The pause-on-none request completed successfully.");
 
     gClient.addListener("paused", unexpectedListener);
 
     // This non-capturing event listener is guaranteed to run after the page's
     // capturing one had a chance to execute and modify window.foobar.
-    gInput.addEventListener("keyup", function tempHandler() {
-      gInput.removeEventListener("keyup", tempHandler, false);
-      is(content.wrappedJSObject.foobar, "keyupHandler", "No hidden breakpoint was hit.");
-      gClient.removeListener("paused", unexpectedListener);
-      testBreakOnClick();
-    }, false);
+    once(gInput, "keyup").then(() => {
+      is(content.wrappedJSObject.foobar, "keyupHandler",
+        "No hidden breakpoint was hit.");
 
-    // Make sure that the focus is not on the input box so that a focus event
-    // will be triggered.
-    window.focus();
-    gBrowser.selectedBrowser.focus();
-    gButton.focus();
+      gClient.removeListener("paused", unexpectedListener);
+      deferred.resolve();
+    });
 
-    // Focus the element and wait for focus event.
-    gInput.addEventListener("focus", function onfocus() {
-      gInput.removeEventListener("focus", onfocus, false);
-      executeSoon(function() {
-        EventUtils.synthesizeKey("g", { shiftKey: 1 }, content);
-      });
-    }, false);
+    triggerInputKeyup();
+  });
 
-    gInput.focus();
-  });
+  return deferred.promise;
 }
 
-function unexpectedListener(event, packet, callback) {
+// Test pause on a single event.
+function testBreakOnClick() {
+  let deferred = promise.defer();
+
+  // Test calling pauseOnDOMEvents from a running state.
+  gThreadClient.pauseOnDOMEvents(["click"], (aPacket) => {
+    is(aPacket.error, undefined,
+      "The pause-on-click request completed successfully.");
+
+    gClient.addOneTimeListener("paused", (aEvent, aPacket) => {
+      is(aPacket.why.type, "pauseOnDOMEvents",
+        "A hidden breakpoint was hit.");
+      is(aPacket.frame.callee.name, "clickHandler",
+        "The clickHandler is entered.");
+
+      gThreadClient.resume(deferred.resolve);
+    });
+
+    triggerButtonClick();
+  });
+
+  return deferred.promise;
+}
+
+function closeConnection() {
+  let deferred = promise.defer();
+  gClient.close(deferred.resolve);
+  return deferred.promise;
+}
+
+function unexpectedListener() {
   gClient.removeListener("paused", unexpectedListener);
   ok(false, "An unexpected hidden breakpoint was hit.");
   gThreadClient.resume(testBreakOnClick);
 }
 
-// Test pause on a single event.
-function testBreakOnClick()
-{
-  // Test calling pauseOnDOMEvents from a running state.
-  gThreadClient.pauseOnDOMEvents(["click"], function(packet) {
-    is(packet.error, undefined, "The pause-on-click request completed successfully.");
+function triggerInputKeyup() {
+  // Make sure that the focus is not on the input box so that a focus event
+  // will be triggered.
+  window.focus();
+  gBrowser.selectedBrowser.focus();
+  gButton.focus();
 
-    gClient.addOneTimeListener("paused", function(event, packet) {
-      is(packet.why.type, "pauseOnDOMEvents", "A hidden breakpoint was hit.");
-      is(packet.frame.callee.name, "clickHandler", "The clickHandler is entered.");
+  // Focus the element and wait for focus event.
+  once(gInput, "focus").then(() => {
+    executeSoon(() => {
+      EventUtils.synthesizeKey("e", { shiftKey: 1 }, content);
+    });
+  });
 
-      gThreadClient.resume(function() {
-        gClient.close(finish);
-      });
-    });
+  gInput.focus();
+}
 
-    EventUtils.sendMouseEvent({ type: "click" }, gButton);
-  });
+function triggerButtonClick() {
+  EventUtils.sendMouseEvent({ type: "click" }, gButton)
+}
+
+function triggerInputChange() {
+  gInput.focus();
+  gInput.value = "foo";
+  gInput.blur();
 }
 
 registerCleanupFunction(function() {
-  removeTab(gTab);
-  gTab = null;
+  removeTab(gBrowser.selectedTab);
   gClient = null;
   gThreadClient = null;
   gInput = null;
   gButton = null;
 });
rename from browser/devtools/debugger/test/browser_dbg_createChrome.js
rename to browser/devtools/debugger/test/browser_dbg_chrome-create.js
--- a/browser/devtools/debugger/test/browser_dbg_createChrome.js
+++ b/browser/devtools/debugger/test/browser_dbg_chrome-create.js
@@ -1,37 +1,31 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that a chrome debugger can be created in a new process.
  */
 
-// Tests that a chrome debugger can be created in a new process.
-
-var gProcess = null;
-var gTab = null;
-var gDebuggee = null;
+let gProcess;
 
 function test() {
   // Windows XP test slaves are terribly slow at this test.
   requestLongerTimeout(4);
 
-  debug_chrome(STACK_URL, aOnClosing, function(aTab, aDebuggee, aProcess) {
-    gTab = aTab;
-    gDebuggee = aDebuggee;
+  initChromeDebugger(aOnClose).then(aProcess => {
     gProcess = aProcess;
 
-    info("Starting test");
-    testSimpleCall();
+    info("Starting test...");
+    performTest();
   });
 }
 
-function testSimpleCall() {
+function performTest() {
   Services.tm.currentThread.dispatch({ run: function() {
-
     ok(gProcess._dbgProcess,
       "The remote debugger process wasn't created properly!");
     ok(gProcess._dbgProcess.isRunning,
       "The remote debugger process isn't running!");
     is(typeof gProcess._dbgProcess.pid, "number",
       "The remote debugger process doesn't have a pid (?!)");
 
     info("process location: " + gProcess._dbgProcess.location);
@@ -63,31 +57,26 @@ function testSimpleCall() {
       "The remote debugger profile doesn't have the correct localDir!");
     is(profile.rootDir.path, gProcess._dbgProfile.rootDir.path,
       "The remote debugger profile doesn't have the correct rootDir!");
 
     gProcess.close();
   }}, 0);
 }
 
-function aOnClosing() {
+function aOnClose() {
   ok(!gProcess._dbgProcess.isRunning,
     "The remote debugger process isn't closed as it should be!");
   is(gProcess._dbgProcess.exitValue, (Services.appinfo.OS == "WINNT" ? 0 : 256),
     "The remote debugger process didn't die cleanly.");
 
   info("process exit value: " + gProcess._dbgProcess.exitValue);
 
   info("profile localDir: " + gProcess._dbgProfile.localDir.path);
   info("profile rootDir: " + gProcess._dbgProfile.rootDir.path);
   info("profile name: " + gProcess._dbgProfile.name);
 
-  executeSoon(function() {
-    finish();
-  });
+  finish();
 }
 
 registerCleanupFunction(function() {
-  removeTab(gTab);
   gProcess = null;
-  gTab = null;
-  gDebuggee = null;
 });
--- a/browser/devtools/debugger/test/browser_dbg_chrome-debugging.js
+++ b/browser/devtools/debugger/test/browser_dbg_chrome-debugging.js
@@ -1,68 +1,92 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that chrome debugging works.
  */
 
-// Tests that chrome debugging works.
+const TAB_URL = EXAMPLE_URL + "doc_inline-debugger-statement.html";
+
+let gClient, gThreadClient;
+let gAttached = promise.defer();
+let gNewGlobal = promise.defer()
+let gNewChromeSource = promise.defer()
 
-var gClient = null;
-var gTab = null;
-var gMozillaTab = null;
-var gThreadClient = null;
-var gNewGlobal = false;
-var gAttached = false;
-var gChromeSource = false;
+function test() {
+  if (!DebuggerServer.initialized) {
+    DebuggerServer.init(() => true);
+    DebuggerServer.addBrowserActors();
+  }
 
-const DEBUGGER_TAB_URL = EXAMPLE_URL + "browser_dbg_debuggerstatement.html";
-
-function test()
-{
   let transport = DebuggerServer.connectPipe();
   gClient = new DebuggerClient(transport);
-  gClient.connect(function(aType, aTraits) {
-    gTab = addTab(DEBUGGER_TAB_URL, function() {
-      gClient.listTabs(function(aResponse) {
-        let dbg = aResponse.chromeDebugger;
-        ok(dbg, "Found a chrome debugging actor.");
+  gClient.connect((aType, aTraits) => {
+    is(aType, "browser",
+      "Root actor should identify itself as a browser.");
 
-        gClient.addOneTimeListener("newGlobal", function() gNewGlobal = true);
-        gClient.addListener("newSource", onNewSource);
+    promise.all([gAttached.promise, gNewGlobal.promise, gNewChromeSource.promise])
+      .then(resumeAndCloseConnection)
+      .then(finish)
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
+
+    testChromeActor();
+  });
+}
 
-        gClient.attachThread(dbg, function(aResponse, aThreadClient) {
-          gThreadClient = aThreadClient;
-          ok(!aResponse.error, "Attached to the chrome debugger.");
-          gAttached = true;
+function testChromeActor() {
+  gClient.listTabs(aResponse => {
+    ok(aResponse.chromeDebugger.contains("chromeDebugger"),
+      "Chrome debugger actor should identify itself accordingly.");
+
+    gClient.addListener("newGlobal", onNewGlobal);
+    gClient.addListener("newSource", onNewSource);
+
+    gClient.attachThread(aResponse.chromeDebugger, (aResponse, aThreadClient) => {
+      gThreadClient = aThreadClient;
 
-          // Ensure that a new global will be created.
-          gMozillaTab = gBrowser.addTab("about:mozilla");
+      if (aResponse.error) {
+        ok(false, "Couldn't attach to the chrome debugger.");
+        gAttached.reject();
+      } else {
+        ok(true, "Attached to the chrome debugger.");
+        gAttached.resolve();
 
-          finish_test();
-        });
-      });
+        // Ensure that a new chrome global will be created.
+        gBrowser.selectedTab = gBrowser.addTab("about:mozilla");
+      }
     });
   });
 }
 
-function onNewSource(aEvent, aPacket)
-{
-  gChromeSource = aPacket.source.url.startsWith("chrome:");
-  finish_test();
+function onNewGlobal() {
+  ok(true, "Received a new chrome global.");
+
+  gClient.removeListener("newGlobal", onNewGlobal);
+  gNewGlobal.resolve();
 }
 
-function finish_test()
-{
-  if (!gAttached || !gChromeSource) {
-    return;
+function onNewSource(aEvent, aPacket) {
+  if (aPacket.source.url.startsWith("chrome:")) {
+    ok(true, "Received a new chrome source: " + aPacket.source.url);
+
+    gClient.removeListener("newSource", onNewSource);
+    gNewChromeSource.resolve();
   }
-  gClient.removeListener("newSource", onNewSource);
-  gThreadClient.resume(function(aResponse) {
-    removeTab(gMozillaTab);
-    removeTab(gTab);
-    gClient.close(function() {
-      ok(gNewGlobal, "Received newGlobal event.");
-      ok(gChromeSource, "Received newSource event for a chrome: script.");
-      finish();
-    });
-  });
+}
+
+function resumeAndCloseConnection() {
+  let deferred = promise.defer();
+  gThreadClient.resume(() => gClient.close(deferred.resolve));
+  return deferred.promise;
 }
+
+registerCleanupFunction(function() {
+  removeTab(gBrowser.selectedTab);
+  gClient = null;
+  gThreadClient = null;
+  gAttached = null;
+  gNewGlobal = null;
+  gNewChromeSource = null;
+});
--- a/browser/devtools/debugger/test/browser_dbg_clean-exit.js
+++ b/browser/devtools/debugger/test/browser_dbg_clean-exit.js
@@ -1,43 +1,39 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Test that closing a tab with the debugger in a paused state exits cleanly.
  */
 
-// Test that closing a tab with the debugger in a paused state exits cleanly.
+let gTab, gDebuggee, gPanel, gDebugger;
 
-var gPane = null;
-var gTab = null;
-var gDebugger = null;
-
-const DEBUGGER_TAB_URL = EXAMPLE_URL + "browser_dbg_debuggerstatement.html";
+const TAB_URL = EXAMPLE_URL + "doc_inline-debugger-statement.html";
 
 function test() {
-  debug_tab_pane(DEBUGGER_TAB_URL, function(aTab, aDebuggee, aPane) {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
+    gDebuggee = aDebuggee;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
 
     testCleanExit();
   });
 }
 
 function testCleanExit() {
-  gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
-    Services.tm.currentThread.dispatch({ run: function() {
+  waitForSourceAndCaretAndScopes(gPanel, ".html", 16).then(() => {
+    is(gDebugger.gThreadClient.paused, true,
+      "Should be paused after the debugger statement.");
 
-      is(gDebugger.DebuggerController.activeThread.paused, true,
-        "Should be paused after the debugger statement.");
-
-      closeDebuggerAndFinish();
-    }}, 0);
+    closeDebuggerAndFinish(gPanel, { whilePaused: true });
   });
 
-  gTab.linkedBrowser.contentWindow.wrappedJSObject.runDebuggerStatement();
+  gDebuggee.runDebuggerStatement();
 }
 
 registerCleanupFunction(function() {
-  removeTab(gTab);
-  gPane = null;
   gTab = null;
+  gDebuggee = null;
+  gPanel = null;
   gDebugger = null;
 });
rename from browser/devtools/debugger/test/browser_dbg_cmd_blackbox.js
rename to browser/devtools/debugger/test/browser_dbg_cmd-blackbox.js
--- a/browser/devtools/debugger/test/browser_dbg_cmd_blackbox.js
+++ b/browser/devtools/debugger/test/browser_dbg_cmd-blackbox.js
@@ -1,173 +1,134 @@
 /* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Tests that the 'dbg blackbox' and 'dbg unblackbox' commands work as they
-// should.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
-const TEST_URL = EXAMPLE_URL + "browser_dbg_blackboxing.html";
-const BLACKBOXME_URL = EXAMPLE_URL + "blackboxing_blackboxme.js";
-const BLACKBOXONE_URL = EXAMPLE_URL + "blackboxing_one.js";
-const BLACKBOXTWO_URL = EXAMPLE_URL + "blackboxing_two.js";
-const BLACKBOXTHREE_URL = EXAMPLE_URL + "blackboxing_three.js";
-
-let gcli = Cu.import("resource://gre/modules/devtools/gcli.jsm", {}).gcli;
-
-let gTarget;
-let gPanel;
-let gOptions;
-let gDebugger;
-let gClient;
-let gThreadClient;
-let gTab;
+/**
+ * Tests that the 'dbg blackbox' and 'dbg unblackbox' commands work as
+ * they should.
+ */
 
-function cmd(typed, expectedNumEvents=1, output=null) {
-  const deferred = promise.defer();
-
-  let timesFired = 0;
-  gThreadClient.addListener("blackboxchange", function _onBlackBoxChange() {
-    if (++timesFired === expectedNumEvents) {
-      gThreadClient.removeListener("blackboxchange", _onBlackBoxChange);
-      deferred.resolve();
-    }
-  });
+const TEST_URL = EXAMPLE_URL + "doc_blackboxing.html";
+const BLACKBOXME_URL = EXAMPLE_URL + "code_blackboxing_blackboxme.js";
+const BLACKBOXONE_URL = EXAMPLE_URL + "code_blackboxing_one.js";
+const BLACKBOXTWO_URL = EXAMPLE_URL + "code_blackboxing_two.js";
+const BLACKBOXTHREE_URL = EXAMPLE_URL + "code_blackboxing_three.js";
 
-  let audit = {
-    setup: typed,
-    exec: {}
-  };
-
-  if (output) {
-    audit.output = output;
-  }
-
-  return helpers.audit(gOptions, [audit]).then(function() {
-    return deferred.promise;
-  });
-}
+let gPanel, gDebugger, gThreadClient;
+let gOptions;
 
 function test() {
-  helpers.addTabWithToolbar(TEST_URL, function(options) {
-    gOptions = options;
-    gTarget = options.target;
-    return gDevTools.showToolbox(options.target, "jsdebugger")
+  helpers.addTabWithToolbar(TEST_URL, function(aOptions) {
+    gOptions = aOptions;
+
+    return gDevTools.showToolbox(aOptions.target, "jsdebugger")
       .then(setupGlobals)
       .then(waitForDebuggerSources)
       .then(testBlackBoxSource)
       .then(testUnBlackBoxSource)
       .then(testBlackBoxGlob)
       .then(testUnBlackBoxGlob)
       .then(testBlackBoxInvert)
       .then(testUnBlackBoxInvert)
-      .then(null, function (error) {
-        ok(false, "Got an error: " + error.message + "\n" + error.stack);
-      })
-      .then(finishUp);
+      .then(() => closeDebuggerAndFinish(gPanel, { noTabRemoval: true }))
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
   });
 }
 
-function setupGlobals(toolbox) {
-  gTab = gBrowser.selectedTab;
-  gPanel = toolbox.getCurrentPanel();
+function setupGlobals(aToolbox) {
+  gPanel = aToolbox.getCurrentPanel();
   gDebugger = gPanel.panelWin;
-  gClient = gDebugger.gClient;
-  gThreadClient = gClient.activeThread;
+  gThreadClient = gDebugger.gThreadClient;
 }
 
 function waitForDebuggerSources() {
-  const deferred = promise.defer();
-  gDebugger.addEventListener("Debugger:SourceShown", function _onSourceShown() {
-    gDebugger.removeEventListener("Debugger:SourceShown", _onSourceShown, false);
-    deferred.resolve();
-  }, false);
-  return deferred.promise;
+  return waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN);
 }
 
 function testBlackBoxSource() {
-  return cmd("dbg blackbox " + BLACKBOXME_URL)
-    .then(function () {
-      const checkbox = getBlackBoxCheckbox(BLACKBOXME_URL);
-      ok(!checkbox.checked,
-         "Should be able to black box a specific source");
-    });
+  return cmd("dbg blackbox " + BLACKBOXME_URL).then(() => {
+    const checkbox = getBlackBoxCheckbox(BLACKBOXME_URL);
+    ok(!checkbox.checked,
+      "Should be able to black box a specific source.");
+  });
 }
 
 function testUnBlackBoxSource() {
-  return cmd("dbg unblackbox " + BLACKBOXME_URL)
-    .then(function () {
-      const checkbox = getBlackBoxCheckbox(BLACKBOXME_URL);
-      ok(checkbox.checked,
-         "Should be able to stop black boxing a specific source");
-    });
+  return cmd("dbg unblackbox " + BLACKBOXME_URL).then(() => {
+    const checkbox = getBlackBoxCheckbox(BLACKBOXME_URL);
+    ok(checkbox.checked,
+      "Should be able to stop black boxing a specific source.");
+  });
 }
 
 function testBlackBoxGlob() {
   return cmd("dbg blackbox --glob *blackboxing_t*.js", 2,
-             [/blackboxing_three\.js/g, /blackboxing_two\.js/g])
-    .then(function () {
-      ok(getBlackBoxCheckbox(BLACKBOXME_URL).checked,
-         "blackboxme should not be black boxed because it doesn't match the glob");
-      ok(getBlackBoxCheckbox(BLACKBOXONE_URL).checked,
-         "blackbox_one should not be black boxed because it doesn't match the glob");
+             [/blackboxing_three\.js/g, /blackboxing_two\.js/g]).then(() => {
+    ok(getBlackBoxCheckbox(BLACKBOXME_URL).checked,
+      "blackboxme should not be black boxed because it doesn't match the glob.");
+    ok(getBlackBoxCheckbox(BLACKBOXONE_URL).checked,
+      "blackbox_one should not be black boxed because it doesn't match the glob.");
 
-      ok(!getBlackBoxCheckbox(BLACKBOXTWO_URL).checked,
-         "blackbox_two should be black boxed because it matches the glob");
-      ok(!getBlackBoxCheckbox(BLACKBOXTHREE_URL).checked,
-         "blackbox_three should be black boxed because it matches the glob");
-    });
+    ok(!getBlackBoxCheckbox(BLACKBOXTWO_URL).checked,
+      "blackbox_two should be black boxed because it matches the glob.");
+    ok(!getBlackBoxCheckbox(BLACKBOXTHREE_URL).checked,
+      "blackbox_three should be black boxed because it matches the glob.");
+  });
 }
 
 function testUnBlackBoxGlob() {
-  return cmd("dbg unblackbox --glob *blackboxing_t*.js", 2)
-    .then(function () {
-      ok(getBlackBoxCheckbox(BLACKBOXTWO_URL).checked,
-         "blackbox_two should be un-black boxed because it matches the glob");
-      ok(getBlackBoxCheckbox(BLACKBOXTHREE_URL).checked,
-         "blackbox_three should be un-black boxed because it matches the glob");
-    });
+  return cmd("dbg unblackbox --glob *blackboxing_t*.js", 2).then(() => {
+    ok(getBlackBoxCheckbox(BLACKBOXTWO_URL).checked,
+      "blackbox_two should be un-black boxed because it matches the glob.");
+    ok(getBlackBoxCheckbox(BLACKBOXTHREE_URL).checked,
+      "blackbox_three should be un-black boxed because it matches the glob.");
+  });
 }
 
 function testBlackBoxInvert() {
   return cmd("dbg blackbox --invert --glob *blackboxing_t*.js", 3,
-             [/blackboxing_three\.js/g, /blackboxing_two\.js/g])
-    .then(function () {
-      ok(!getBlackBoxCheckbox(BLACKBOXME_URL).checked,
-         "blackboxme should be black boxed because it doesn't match the glob");
-      ok(!getBlackBoxCheckbox(BLACKBOXONE_URL).checked,
-         "blackbox_one should be black boxed because it doesn't match the glob");
-      ok(!getBlackBoxCheckbox(TEST_URL).checked,
-         "TEST_URL should be black boxed because it doesn't match the glob");
+             [/blackboxing_three\.js/g, /blackboxing_two\.js/g]).then(() => {
+    ok(!getBlackBoxCheckbox(BLACKBOXME_URL).checked,
+      "blackboxme should be black boxed because it doesn't match the glob.");
+    ok(!getBlackBoxCheckbox(BLACKBOXONE_URL).checked,
+      "blackbox_one should be black boxed because it doesn't match the glob.");
+    ok(!getBlackBoxCheckbox(TEST_URL).checked,
+      "TEST_URL should be black boxed because it doesn't match the glob.");
 
-      ok(getBlackBoxCheckbox(BLACKBOXTWO_URL).checked,
-         "blackbox_two should not be black boxed because it matches the glob");
-      ok(getBlackBoxCheckbox(BLACKBOXTHREE_URL).checked,
-         "blackbox_three should not be black boxed because it matches the glob");
-    });
+    ok(getBlackBoxCheckbox(BLACKBOXTWO_URL).checked,
+      "blackbox_two should not be black boxed because it matches the glob.");
+    ok(getBlackBoxCheckbox(BLACKBOXTHREE_URL).checked,
+      "blackbox_three should not be black boxed because it matches the glob.");
+  });
 }
 
 function testUnBlackBoxInvert() {
-  return cmd("dbg unblackbox --invert --glob *blackboxing_t*.js", 3)
-    .then(function () {
-      ok(getBlackBoxCheckbox(BLACKBOXME_URL).checked,
-         "blackboxme should be un-black boxed because it does not match the glob");
-      ok(getBlackBoxCheckbox(BLACKBOXONE_URL).checked,
-         "blackbox_one should be un-black boxed because it does not match the glob");
-      ok(getBlackBoxCheckbox(TEST_URL).checked,
-         "TEST_URL should be un-black boxed because it doesn't match the glob");
-    });
+  return cmd("dbg unblackbox --invert --glob *blackboxing_t*.js", 3).then(() => {
+    ok(getBlackBoxCheckbox(BLACKBOXME_URL).checked,
+      "blackboxme should be un-black boxed because it does not match the glob.");
+    ok(getBlackBoxCheckbox(BLACKBOXONE_URL).checked,
+      "blackbox_one should be un-black boxed because it does not match the glob.");
+    ok(getBlackBoxCheckbox(TEST_URL).checked,
+      "TEST_URL should be un-black boxed because it doesn't match the glob.");
+  });
 }
 
-function finishUp() {
-  gTarget = null;
-  gPanel = null;
+registerCleanupFunction(function() {
   gOptions = null;
-  gClient = null;
+  gPanel = null;
+  gDebugger = null;
   gThreadClient = null;
-  gDebugger = null;
-  closeDebuggerAndFinish();
+});
+
+function cmd(aTyped, aEventRepeat = 1, aOutput = "") {
+  return promise.all([
+    waitForThreadEvents(gPanel, "blackboxchange", aEventRepeat),
+    helpers.audit(gOptions, [{ setup: aTyped, output: aOutput, exec: {} }])
+  ]);
 }
 
 function getBlackBoxCheckbox(url) {
   return gDebugger.document.querySelector(
-    ".side-menu-widget-item[tooltiptext=\""
-      + url + "\"] .side-menu-widget-item-checkbox");
+    ".side-menu-widget-item[tooltiptext=\"" + url + "\"] " +
+    ".side-menu-widget-item-checkbox");
 }
rename from browser/devtools/debugger/test/browser_dbg_cmd_break.js
rename to browser/devtools/debugger/test/browser_dbg_cmd-break.js
--- a/browser/devtools/debugger/test/browser_dbg_cmd_break.js
+++ b/browser/devtools/debugger/test/browser_dbg_cmd-break.js
@@ -1,220 +1,204 @@
 /* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
-// Tests that the break command works as it should
+/**
+ * Tests that the break commands works as they should.
+ */
 
-const TEST_URI = "http://example.com/browser/browser/devtools/debugger/" +
-                 "test/browser_dbg_cmd_break.html";
+const TAB_URL = EXAMPLE_URL + "doc_cmd-break.html";
 
 function test() {
-  helpers.addTabWithToolbar(TEST_URI, function(options) {
-    // To help us run later commands, and clear up after ourselves
-    let client, line0;
+  let gPanel, gDebugger, gThreadClient;
+  let gLineNumber;
 
-    return helpers.audit(options, [
+  helpers.addTabWithToolbar(TAB_URL, aOptions => {
+    return helpers.audit(aOptions, [
       {
         setup: 'break',
         check: {
           input:  'break',
           hints:       ' add line',
           markup: 'IIIII',
           status: 'ERROR',
-        },
+        }
       },
       {
         setup: 'break add',
         check: {
           input:  'break add',
           hints:           ' line',
           markup: 'IIIIIVIII',
           status: 'ERROR'
-        },
+        }
       },
       {
         setup: 'break add line',
         check: {
           input:  'break add line',
           hints:                ' <file> <line>',
           markup: 'VVVVVVVVVVVVVV',
           status: 'ERROR'
-        },
+        }
       },
       {
         name: 'open toolbox',
         setup: function() {
-          var deferred = promise.defer();
-
-          var openDone = gDevTools.showToolbox(options.target, "jsdebugger");
-          openDone.then(function(toolbox) {
-            let dbg = toolbox.getCurrentPanel();
-            ok(dbg, "DebuggerPanel exists");
+          return initDebugger(gBrowser.selectedTab).then(([aTab, aDebuggee, aPanel]) => {
+            // Spin the event loop before causing the debuggee to pause, to allow
+            // this function to return first.
+            executeSoon(() => aDebuggee.firstCall());
 
-            // Wait for the initial resume...
-            dbg.panelWin.gClient.addOneTimeListener("resumed", function() {
-              info("Starting tests");
-
-              client = dbg.panelWin.gClient;
-              client.activeThread.addOneTimeListener("framesadded", function() {
-                line0 = '' + options.window.wrappedJSObject.line0;
-                deferred.resolve();
-              });
-
-              // Trigger newScript notifications using eval.
-              content.wrappedJSObject.firstCall();
+            return waitForSourceAndCaretAndScopes(aPanel, ".html", 17).then(() => {
+              gPanel = aPanel;
+              gDebugger = gPanel.panelWin;
+              gThreadClient = gPanel.panelWin.gThreadClient;
+              gLineNumber = '' + aOptions.window.wrappedJSObject.gLineNumber;
             });
           });
-
-          return deferred.promise;
         },
         post: function() {
-          ok(client, "Debugger client exists");
-          is(line0, 10, "line0 is 10");
+          ok(gThreadClient, "Debugger client exists.");
+          is(gLineNumber, 14, "gLineNumber is correct.");
         },
       },
       {
-        name: 'break add line .../browser_dbg_cmd_break.html 10',
+        name: 'break add line .../doc_cmd-break.html 14',
         setup: function() {
-          // We have to setup in a function to allow line0 to be initialized
-          let line = 'break add line ' + TEST_URI + ' ' + line0;
-          return helpers.setInput(options, line);
+          // We have to setup in a function to allow gLineNumber to be initialized.
+          let line = 'break add line ' + TAB_URL + ' ' + gLineNumber;
+          return helpers.setInput(aOptions, line);
         },
         check: {
           hints: '',
           status: 'VALID',
           message: '',
           args: {
-            file: { value: TEST_URI, message: '' },
-            line: { value: 10 }
+            file: { value: TAB_URL, message: '' },
+            line: { value: 14 }
           }
         },
         exec: {
           output: 'Added breakpoint',
           completed: false
-        },
+        }
       },
       {
-        setup: 'break add line http://example.com/browser/browser/devtools/debugger/test/browser_dbg_cmd_break.html 13',
+        setup: 'break add line ' + TAB_URL + ' 17',
         check: {
           hints: '',
           status: 'VALID',
           message: '',
           args: {
-            file: { value: TEST_URI, message: '' },
-            line: { value: 13 }
+            file: { value: TAB_URL, message: '' },
+            line: { value: 17 }
           }
         },
         exec: {
           output: 'Added breakpoint',
           completed: false
-        },
+        }
       },
       {
         setup: 'break list',
         check: {
           input:  'break list',
           hints:            '',
           markup: 'VVVVVVVVVV',
           status: 'VALID'
         },
         exec: {
           output: [
             /Source/, /Remove/,
-            /cmd_break\.html:10/,
-            /cmd_break\.html:13/
+            /doc_cmd-break\.html:14/,
+            /doc_cmd-break\.html:17/
           ]
-        },
+        }
       },
       {
         name: 'cleanup',
         setup: function() {
-          // a.k.a "return client.activeThread.resume();"
-          var deferred = promise.defer();
-          client.activeThread.resume(function() {
-            deferred.resolve();
-          });
+          let deferred = promise.defer();
+          gThreadClient.resume(deferred.resolve);
           return deferred.promise;
-        },
+        }
       },
       {
-        setup: 'break del 0',
+        setup: 'break del 14',
         check: {
-          input:  'break del 0',
-          hints:             ' -> browser_dbg_cmd_break.html:10',
-          markup: 'VVVVVVVVVVI',
+          input:  'break del 14',
+          hints:              ' -> doc_cmd-break.html:14',
+          markup: 'VVVVVVVVVVII',
           status: 'ERROR',
           args: {
             breakpoint: {
               status: 'INCOMPLETE',
               message: ''
-            },
+            }
           }
-        },
+        }
       },
       {
-        setup: 'break del browser_dbg_cmd_break.html:10',
+        setup: 'break del doc_cmd-break.html:14',
         check: {
-          input:  'break del browser_dbg_cmd_break.html:10',
-          hints:                                         '',
-          markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV',
+          input:  'break del doc_cmd-break.html:14',
+          hints:                                 '',
+          markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV',
           status: 'VALID',
           args: {
-            breakpoint: { arg: ' browser_dbg_cmd_break.html:10' },
+            breakpoint: { arg: ' doc_cmd-break.html:14' },
           }
         },
         exec: {
           output: 'Breakpoint removed',
           completed: false
-        },
+        }
       },
       {
         setup: 'break list',
         check: {
           input:  'break list',
           hints:            '',
           markup: 'VVVVVVVVVV',
           status: 'VALID'
         },
         exec: {
           output: [
             /Source/, /Remove/,
-            /browser_dbg_cmd_break\.html:13/
+            /doc_cmd-break\.html:17/
           ]
-        },
+        }
       },
       {
-        setup: 'break del browser_dbg_cmd_break.html:13',
+        setup: 'break del doc_cmd-break.html:17',
         check: {
-          input:  'break del browser_dbg_cmd_break.html:13',
-          hints:                                         '',
-          markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV',
+          input:  'break del doc_cmd-break.html:17',
+          hints:                                 '',
+          markup: 'VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV',
           status: 'VALID',
           args: {
-            breakpoint: { arg: ' browser_dbg_cmd_break.html:13' },
+            breakpoint: { arg: ' doc_cmd-break.html:17' },
           }
         },
         exec: {
           output: 'Breakpoint removed',
           completed: false
-        },
+        }
       },
       {
         setup: 'break list',
         check: {
           input:  'break list',
           hints:            '',
           markup: 'VVVVVVVVVV',
           status: 'VALID'
         },
         exec: {
           output: 'No breakpoints set'
         },
         post: function() {
-          client = undefined;
-
-          let toolbox = gDevTools.getToolbox(options.target);
-          return toolbox.destroy();
+          return teardown(gPanel, { noTabRemoval: true });
         }
       },
     ]);
   }).then(finish);
 }
rename from browser/devtools/debugger/test/browser_dbg_cmd.js
rename to browser/devtools/debugger/test/browser_dbg_cmd-dbg.js
--- a/browser/devtools/debugger/test/browser_dbg_cmd.js
+++ b/browser/devtools/debugger/test/browser_dbg_cmd-dbg.js
@@ -1,106 +1,101 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+/**
+ * Tests that the debugger commands work as they should.
+ */
+
+const TEST_URI = EXAMPLE_URL + "doc_cmd-dbg.html";
+
 function test() {
-  let Task = Cu.import("resource://gre/modules/Task.jsm", {}).Task;
-
   return Task.spawn(function() {
-    const TEST_URI = "http://example.com/browser/browser/devtools/debugger/" +
-                     "test/browser_dbg_cmd.html";
-
     let options = yield helpers.openTab(TEST_URI);
     yield helpers.openToolbar(options);
 
     yield helpers.audit(options, [{
       setup: "dbg open",
       exec: { output: "", completed: false }
     }]);
 
-    let toolbox = yield gDevTools.showToolbox(options.target, "jsdebugger");
-    let dbg = toolbox.getCurrentPanel();
-    ok(dbg, "DebuggerPanel exists");
-
-    // Wait for the initial resume...
-    let resumeDeferred = promise.defer();
-    dbg.panelWin.gClient.addOneTimeListener("resumed", () => {
-      resumeDeferred.resolve();
-    });
-    yield resumeDeferred.promise;
+    let [gTab, gDebuggee, gPanel] = yield initDebugger(gBrowser.selectedTab);
+    let gDebugger = gPanel.panelWin;
+    let gThreadClient = gDebugger.gThreadClient;
 
     yield helpers.audit(options, [{
       setup: "dbg list",
-      exec: { output: /browser_dbg_cmd.html/ }
+      exec: { output: /doc_cmd-dbg.html/ }
     }]);
 
-    // exec a command with GCLI to resume the debugger and wait until it stops
-    let cmd = function(typed) {
-      let cmdDeferred = promise.defer();
-      dbg._controller.activeThread.addOneTimeListener("paused", ev => {
-        cmdDeferred.resolve();
-      });
-      helpers.audit(options, [{
-        setup: typed,
-        exec: { output: "" }
-      }]).then(null, cmdDeferred.reject);
-      return cmdDeferred.promise;
+    let button = gDebuggee.document.querySelector("input[type=button]");
+    let output = gDebuggee.document.querySelector("input[type=text]");
+
+    let cmd = function(aTyped, aState) {
+      return promise.all([
+        waitForThreadEvents(gPanel, aState),
+        helpers.audit(options, [{ setup: aTyped, exec: { output: "" } }])
+      ]);
     };
 
-    yield cmd("dbg interrupt");
+    let click = function(aElement, aState) {
+      return promise.all([
+        waitForThreadEvents(gPanel, aState),
+        executeSoon(() => EventUtils.sendMouseEvent({ type: "click" }, aElement, gDebuggee))
+      ]);
+    }
+
+    yield cmd("dbg interrupt", "paused");
+    is(gThreadClient.state, "paused", "Debugger is paused.");
+
+    yield cmd("dbg continue", "resumed");
+    isnot(gThreadClient.state, "paused", "Debugger has continued.");
 
-    let interruptDeferred = promise.defer();
-    ok(true, "debugger is paused");
-    dbg._controller.activeThread.addOneTimeListener("resumed", () => {
-      ok(true, "debugger continued");
-      dbg._controller.activeThread.addOneTimeListener("paused", () => {
-        interruptDeferred.resolve();
-      });
-      let btnDoit = options.window.document.querySelector("input[type=button]");
-      EventUtils.sendMouseEvent({ type:"click" }, btnDoit);
-    });
-    helpers.audit(options, [{
-      setup: "dbg continue",
-      exec: { output: "" }
-    }]);
-    yield interruptDeferred.promise;
+    yield click(button, "paused");
+    is(gThreadClient.state, "paused", "Debugger is paused again.");
+
+    yield cmd("dbg step in", "paused");
+    yield cmd("dbg step in", "paused");
+    yield cmd("dbg step in", "paused");
+    is(output.value, "step in", "Debugger stepped in.");
 
-    yield cmd("dbg step in");
-    yield cmd("dbg step in");
-    yield cmd("dbg step in");
-    let output = options.window.document.querySelector("input[type=text]");
-    is(output.value, "step in", "debugger stepped in");
-    yield cmd("dbg step over");
-    is(output.value, "step over", "debugger stepped over");
-    yield cmd("dbg step out");
-    is(output.value, "step out", "debugger stepped out");
-    yield cmd("dbg continue");
-    is(output.value, "dbg continue", "debugger continued");
+    yield cmd("dbg step over", "paused");
+    is(output.value, "step over", "Debugger stepped over.");
+
+    yield cmd("dbg step out", "paused");
+    is(output.value, "step out", "Debugger stepped out.");
+
+    yield cmd("dbg continue", "paused");
+    is(output.value, "dbg continue", "Debugger continued.");
 
     let closeDebugger = function() {
-      let closeDeferred = promise.defer();
+      let deferred = promise.defer();
+
       helpers.audit(options, [{
         setup: "dbg close",
         completed: false,
         exec: { output: "" }
-      }]).then(function() {
-        let closeToolbox = gDevTools.getToolbox(options.target);
-        if (!closeToolbox) {
+      }])
+      .then(() => {
+        let toolbox = gDevTools.getToolbox(options.target);
+        if (!toolbox) {
           ok(true, "Debugger is closed.");
-          closeDeferred.resolve();
+          deferred.resolve();
         } else {
-          closeToolbox.on("destroyed", () => {
+          toolbox.on("destroyed", () => {
             ok(true, "Debugger just closed.");
-            closeDeferred.resolve();
+            deferred.resolve();
           });
         }
       });
-      return closeDeferred.promise;
+
+      return deferred.promise;
     };
 
     // We close the debugger twice to ensure 'dbg close' doesn't error when
     // toolbox is already closed. See bug 884638 for more info.
     yield closeDebugger();
     yield closeDebugger();
     yield helpers.closeToolbar(options);
     yield helpers.closeTab(options);
+
   }).then(finish, helpers.handleError);
 }
rename from browser/devtools/debugger/test/browser_dbg_debuggerstatement.js
rename to browser/devtools/debugger/test/browser_dbg_debugger-statement.js
--- a/browser/devtools/debugger/test/browser_dbg_debuggerstatement.js
+++ b/browser/devtools/debugger/test/browser_dbg_debugger-statement.js
@@ -1,70 +1,89 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests the behavior of the debugger statement.
  */
 
-// Tests the behavior of the debugger statement.
+const TAB_URL = EXAMPLE_URL + "doc_inline-debugger-statement.html";
+
+let gClient;
 
-var gClient = null;
-var gTab = null;
-const DEBUGGER_TAB_URL = EXAMPLE_URL + "browser_dbg_debuggerstatement.html";
+function test() {
+  if (!DebuggerServer.initialized) {
+    DebuggerServer.init(() => true);
+    DebuggerServer.addBrowserActors();
+  }
 
-function test()
-{
   let transport = DebuggerServer.connectPipe();
   gClient = new DebuggerClient(transport);
-  gClient.connect(function(aType, aTraits) {
-    gTab = addTab(DEBUGGER_TAB_URL, function() {
-      attach_tab_actor_for_url(gClient, DEBUGGER_TAB_URL, function(actor, response) {
-        test_early_debugger_statement(response);
+  gClient.connect((aType, aTraits) => {
+    is(aType, "browser",
+      "Root actor should identify itself as a browser.");
+
+    addTab(TAB_URL)
+      .then(() => attachTabActorForUrl(gClient, TAB_URL))
+      .then(testEarlyDebuggerStatement)
+      .then(testDebuggerStatement)
+      .then(closeConnection)
+      .then(finish)
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
       });
-    });
   });
 }
 
-function test_early_debugger_statement(aActor)
-{
-  let paused = function(aEvent, aPacket) {
-    ok(false, "Pause shouldn't be called before we've attached!\n");
-    finish_test();
+function testEarlyDebuggerStatement([aGrip, aResponse]) {
+  let deferred = promise.defer();
+
+  let onPaused = function(aEvent, aPacket) {
+    ok(false, "Pause shouldn't be called before we've attached!");
+    deferred.reject();
   };
-  gClient.addListener("paused", paused);
+
+  gClient.addListener("paused", onPaused);
+
   // This should continue without nesting an event loop and calling
   // the onPaused hook, because we haven't attached yet.
-  gTab.linkedBrowser.contentWindow.wrappedJSObject.runDebuggerStatement();
+  let debuggee = gBrowser.selectedTab.linkedBrowser.contentWindow.wrappedJSObject;
+  debuggee.runDebuggerStatement();
 
-  gClient.removeListener("paused", paused);
+  gClient.removeListener("paused", onPaused);
 
   // Now attach and resume...
-  gClient.request({ to: aActor.threadActor, type: "attach" }, function(aResponse) {
-    gClient.request({ to: aActor.threadActor, type: "resume" }, function(aResponse) {
-      test_debugger_statement(aActor);
-    });
-  });
-}
-
-function test_debugger_statement(aActor)
-{
-  var stopped = false;
-  gClient.addListener("paused", function(aEvent, aPacket) {
-    stopped = true;
-
-    gClient.request({ to: aActor.threadActor, type: "resume" }, function() {
-      finish_test();
+  gClient.request({ to: aResponse.threadActor, type: "attach" }, () => {
+    gClient.request({ to: aResponse.threadActor, type: "resume" }, () => {
+      ok(true, "Pause wasn't called before we've attached.");
+      deferred.resolve([aGrip, aResponse]);
     });
   });
 
-  // Reach around the debugging protocol and execute the debugger
-  // statement.
-  gTab.linkedBrowser.contentWindow.wrappedJSObject.runDebuggerStatement();
-  ok(stopped, "Should trigger the pause handler on a debugger statement.");
+  return deferred.promise;
 }
 
-function finish_test()
-{
-  removeTab(gTab);
-  gClient.close(function() {
-    finish();
+function testDebuggerStatement([aGrip, aResponse]) {
+  let deferred = promise.defer();
+
+  gClient.addListener("paused", (aEvent, aPacket) => {
+    gClient.request({ to: aResponse.threadActor, type: "resume" }, () => {
+      ok(true, "The pause handler was triggered on a debugger statement.");
+      deferred.resolve();
+    });
   });
+
+  // Reach around the debugging protocol and execute the debugger statement.
+  let debuggee = gBrowser.selectedTab.linkedBrowser.contentWindow.wrappedJSObject;
+  debuggee.runDebuggerStatement();
 }
+
+function closeConnection() {
+  let deferred = promise.defer();
+  gClient.close(deferred.resolve);
+  return deferred.promise;
+}
+
+registerCleanupFunction(function() {
+  removeTab(gBrowser.selectedTab);
+  gClient = null;
+});
+
rename from browser/devtools/debugger/test/browser_dbg_bug731394_editor-contextmenu.js
rename to browser/devtools/debugger/test/browser_dbg_editor-contextmenu.js
--- a/browser/devtools/debugger/test/browser_dbg_bug731394_editor-contextmenu.js
+++ b/browser/devtools/debugger/test/browser_dbg_editor-contextmenu.js
@@ -1,127 +1,78 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
- * Bug 731394: test the debugger source editor default context menu.
+ * Bug 731394: Test the debugger source editor default context menu.
  */
 
-const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
-
-let gPane = null;
-let gTab = null;
-let gDebuggee = null;
-let gDebugger = null;
+const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
 
-function test()
-{
-  let contextMenu = null;
-  let scriptShown = false;
-  let framesAdded = false;
-  let resumed = false;
-  let testStarted = false;
+function test() {
+  let gTab, gDebuggee, gPanel, gDebugger;
+  let gEditor, gSources, gContextMenu;
 
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
     gDebuggee = aDebuggee;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
-    resumed = true;
-
-    gDebugger.addEventListener("Debugger:SourceShown", onSourceShown);
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gEditor = gDebugger.DebuggerView.editor;
+    gSources = gDebugger.DebuggerView.Sources;
+    gContextMenu = gDebugger.document.getElementById("sourceEditorContextMenu");
 
-    gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded",
-                                                                 onFramesAdded);
-
-    executeSoon(function() {
-      gDebuggee.firstCall();
-    });
+    waitForSourceAndCaretAndScopes(gPanel, "-02.js", 6).then(performTest);
+    gDebuggee.firstCall();
   });
 
-  function onFramesAdded(aEvent) {
-    framesAdded = true;
-    executeSoon(startTest);
+  function performTest() {
+    is(gDebugger.gThreadClient.state, "paused",
+      "Should only be getting stack frames while paused.");
+    is(gSources.itemCount, 2,
+      "Found the expected number of sources.");
+    is(gEditor.getText().indexOf("debugger"), 172,
+      "The correct source was loaded initially.");
+    is(gSources.selectedValue, gSources.values[1],
+      "The correct source is selected.");
+
+    is(gEditor.getText().indexOf("\u263a"), 162,
+      "Unicode characters are converted correctly.");
+
+    ok(gContextMenu,
+      "The source editor's context menupopup is available.");
+    ok(gEditor.readOnly,
+      "The source editor is read only.");
+
+    gEditor.focus();
+    gEditor.setSelection(0, 10);
+
+    once(gContextMenu, "popupshown").then(testContextMenu);
+    gContextMenu.openPopup(gEditor.editorElement, "overlap", 0, 0, true, false);
   }
 
-  function onSourceShown(aEvent) {
-    scriptShown = aEvent.detail.url.indexOf("-02.js") != -1;
-    executeSoon(startTest);
-  }
-
-  function startTest()
-  {
-    if (scriptShown && framesAdded && resumed && !testStarted) {
-      testStarted = true;
-      gDebugger.removeEventListener("Debugger:SourceShown", onSourceShown);
-      executeSoon(performTest);
-    }
-  }
-
-  function performTest()
-  {
-    let scripts = gDebugger.DebuggerView.Sources;
-    let editor = gDebugger.editor;
-
-    is(gDebugger.DebuggerController.activeThread.state, "paused",
-      "Should only be getting stack frames while paused.");
-
-    is(scripts.itemCount, 2,
-      "Found the expected number of scripts.");
-
-    isnot(editor.getText().indexOf("debugger"), -1,
-      "The correct script was loaded initially.");
-
-    isnot(editor.getText().indexOf("\u263a"), -1,
-      "Unicode characters are converted correctly.");
-
-    contextMenu = gDebugger.document.getElementById("sourceEditorContextMenu");
-    ok(contextMenu, "source editor context menupopup");
-    ok(editor.readOnly, "editor is read only");
-
-    editor.focus();
-    editor.setSelection(0, 10);
-
-    contextMenu.addEventListener("popupshown", function onPopupShown() {
-      contextMenu.removeEventListener("popupshown", onPopupShown, false);
-      executeSoon(testContextMenu);
-    }, false);
-    contextMenu.openPopup(editor.editorElement, "overlap", 0, 0, true, false);
-  }
-
-  function testContextMenu()
-  {
+  function testContextMenu() {
     let document = gDebugger.document;
 
     ok(document.getElementById("editMenuCommands"),
-       "#editMenuCommands found");
+      "#editMenuCommands found.");
     ok(!document.getElementById("editMenuKeys"),
-       "#editMenuKeys not found");
+      "#editMenuKeys not found.");
     ok(document.getElementById("sourceEditorCommands"),
-       "#sourceEditorCommands found");
+      "#sourceEditorCommands found.");
 
     // Map command ids to their expected disabled state.
     let commands = {"se-cmd-undo": true, "se-cmd-redo": true,
                     "se-cmd-cut": true, "se-cmd-paste": true,
                     "se-cmd-delete": true, "cmd_findAgain": true,
                     "cmd_findPrevious": true, "cmd_find": false,
                     "cmd_gotoLine": false, "cmd_copy": false,
                     "se-cmd-selectAll": false};
 
     for (let id in commands) {
       is(document.getElementById(id).hasAttribute("disabled"), commands[id],
-        id + " hasAttribute('disabled') check");
+        "The element with id: " + id + " hasAttribute('disabled').");
     }
 
-    executeSoon(function() {
-      contextMenu.hidePopup();
-      closeDebuggerAndFinish();
-    });
+    gContextMenu.hidePopup();
+    resumeDebuggerThenCloseAndFinish(gPanel);
   }
-
-  registerCleanupFunction(function() {
-    removeTab(gTab);
-    gPane = null;
-    gTab = null;
-    gDebuggee = null;
-    gDebugger = null;
-  });
 }
--- a/browser/devtools/debugger/test/browser_dbg_event-listeners.js
+++ b/browser/devtools/debugger/test/browser_dbg_event-listeners.js
@@ -1,91 +1,126 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that the eventListeners request works.
  */
 
-// Tests that the eventListeners request works.
+const TAB_URL = EXAMPLE_URL + "doc_event-listeners.html";
+
+let gClient;
 
-var gClient = null;
-var gTab = null;
-var gThreadClient = null;
-const DEBUGGER_TAB_URL = EXAMPLE_URL + "test-event-listeners.html";
+function test() {
+  if (!DebuggerServer.initialized) {
+    DebuggerServer.init(() => true);
+    DebuggerServer.addBrowserActors();
+  }
 
-function test()
-{
   let transport = DebuggerServer.connectPipe();
   gClient = new DebuggerClient(transport);
-  gClient.connect(function(aType, aTraits) {
-    gTab = addTab(DEBUGGER_TAB_URL, function() {
-      attach_thread_actor_for_url(gClient,
-                                  DEBUGGER_TAB_URL,
-                                  function(threadClient) {
-        gThreadClient = threadClient;
-        testEventListeners();
+  gClient.connect((aType, aTraits) => {
+    is(aType, "browser",
+      "Root actor should identify itself as a browser.");
+
+    addTab(TAB_URL)
+      .then(() => attachThreadActorForUrl(gClient, TAB_URL))
+      .then(pauseDebuggee)
+      .then(testEventListeners)
+      .then(closeConnection)
+      .then(finish)
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
       });
-    });
   });
 }
 
-function testEventListeners()
-{
-  gClient.addOneTimeListener("paused", function(aEvent, aPacket) {
-    is(aPacket.why.type, "debuggerStatement", "debugger statement was hit.");
-    gThreadClient.eventListeners(function(aPacket) {
-      is(aPacket.listeners.length, 3, "Found all event listeners.");
-      let types = [];
-      for (let l of aPacket.listeners) {
-        let node = l.node;
-        ok(node, "There is a node property.");
-        ok(node.object, "There is a node object property.");
-        ok(node.selector == "window" ||
-           content.document.querySelectorAll(node.selector).length == 1,
-           "The node property is a unique CSS selector");
-        ok(l.function, "There is a function property.");
-        is(l.function.type, "object", "The function form is of type 'object'.");
-        is(l.function.class, "Function", "The function form is of class 'Function'.");
-        is(l.function.url, DEBUGGER_TAB_URL, "The function url is correct.");
-        is(l.allowsUntrusted, true,
-           "allowsUntrusted property has the right value.");
-        is(l.inSystemEventGroup, false,
-           "inSystemEventGroup property has the right value.");
+function pauseDebuggee(aThreadClient) {
+  let deferred = promise.defer();
+
+  gClient.addOneTimeListener("paused", (aEvent, aPacket) => {
+    is(aPacket.type, "paused",
+      "We should now be paused.");
+    is(aPacket.why.type, "debuggerStatement",
+      "The debugger statement was hit.");
 
-        types.push(l.type);
+    deferred.resolve(aThreadClient);
+  });
 
-        if (l.type == "keyup") {
-          is(l.capturing, true, "Capturing property has the right value.");
-          is(l.isEventHandler, false,
-             "isEventHandler property has the right value.");
-        } else if (l.type == "load") {
-          is(l.capturing, false, "Capturing property has the right value.");
-          is(l.isEventHandler, false,
-             "isEventHandler property has the right value.");
-        } else {
-          is(l.capturing, false, "Capturing property has the right value.");
-          is(l.isEventHandler, true,
-             "isEventHandler property has the right value.");
-        }
-      }
-      ok(types.indexOf("click") != -1, "Found the click handler.");
-      ok(types.indexOf("change") != -1, "Found the change handler.");
-      ok(types.indexOf("keyup") != -1, "Found the keyup handler.");
-      finish_test();
-    });
+  // Spin the event loop before causing the debuggee to pause, to allow
+  // this function to return first.
+  executeSoon(() => {
+    EventUtils.sendMouseEvent({ type: "click" },
+      content.document.querySelector("button"),
+      content);
   });
 
-  EventUtils.sendMouseEvent({ type: "click" },
-    content.document.querySelector("button"));
+  return deferred.promise;
 }
 
-function finish_test()
-{
-  gThreadClient.resume(function() {
-    gClient.close(finish);
+function testEventListeners(aThreadClient) {
+  let deferred = promise.defer();
+
+  aThreadClient.eventListeners(aPacket => {
+    is(aPacket.listeners.length, 3,
+      "Found all event listeners.");
+
+    let types = [];
+
+    for (let l of aPacket.listeners) {
+      let node = l.node;
+      ok(node, "There is a node property.");
+      ok(node.object, "There is a node object property.");
+      ok(node.selector == "window" ||
+        content.document.querySelectorAll(node.selector).length == 1,
+        "The node property is a unique CSS selector.");
+
+      let func = l.function;
+      ok(func, "There is a function property.");
+      is(func.type, "object", "The function form is of type 'object'.");
+      is(func.class, "Function", "The function form is of class 'Function'.");
+      is(func.url, TAB_URL, "The function url is correct.");
+
+      is(l.allowsUntrusted, true,
+        "'allowsUntrusted' property has the right value.");
+      is(l.inSystemEventGroup, false,
+        "'inSystemEventGroup' property has the right value.");
+
+      types.push(l.type);
+
+      if (l.type == "keyup") {
+        is(l.capturing, true,
+          "Capturing property has the right value.");
+        is(l.isEventHandler, false,
+          "'isEventHandler' property has the right value.");
+      } else if (l.type == "load") {
+        is(l.capturing, false,
+          "Capturing property has the right value.");
+        is(l.isEventHandler, false,
+          "'isEventHandler' property has the right value.");
+      } else {
+        is(l.capturing, false,
+          "Capturing property has the right value.");
+        is(l.isEventHandler, true,
+          "'isEventHandler' property has the right value.");
+      }
+    }
+
+    ok(types.indexOf("click") != -1, "Found the click handler.");
+    ok(types.indexOf("change") != -1, "Found the change handler.");
+    ok(types.indexOf("keyup") != -1, "Found the keyup handler.");
+
+    aThreadClient.resume(deferred.resolve);
   });
+
+  return deferred.promise;
+}
+
+function closeConnection() {
+  let deferred = promise.defer();
+  gClient.close(deferred.resolve);
+  return deferred.promise;
 }
 
 registerCleanupFunction(function() {
-  removeTab(gTab);
-  gTab = null;
+  removeTab(gBrowser.selectedTab);
   gClient = null;
-  gThreadClient = null;
 });
rename from browser/devtools/debugger/test/browser_dbg_displayName.js
rename to browser/devtools/debugger/test/browser_dbg_function-display-name.js
--- a/browser/devtools/debugger/test/browser_dbg_displayName.js
+++ b/browser/devtools/debugger/test/browser_dbg_function-display-name.js
@@ -1,78 +1,63 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that anonymous functions appear in the stack frame list with either
+ * their displayName property or a SpiderMonkey-inferred name.
  */
 
-// Tests that anonymous functions appear in the stack frame list with either
-// their displayName property or a SpiderMonkey-inferred name.
+const TAB_URL = EXAMPLE_URL + "doc_function-display-name.html";
 
-var gPane = null;
-var gTab = null;
-var gDebuggee = null;
-var gDebugger = null;
-
-const TAB_URL = EXAMPLE_URL + "browser_dbg_displayName.html";
+let gTab, gDebuggee, gPanel, gDebugger;
 
 function test() {
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
     gDebuggee = aDebuggee;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
 
     testAnonCall();
   });
 }
 
 function testAnonCall() {
-  gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
-    Services.tm.currentThread.dispatch({ run: function() {
-
-      let frames = gDebugger.DebuggerView.StackFrames.widget._list;
-
-      is(gDebugger.DebuggerController.activeThread.state, "paused",
-        "Should only be getting stack frames while paused.");
+  waitForSourceAndCaretAndScopes(gPanel, ".html", 15).then(() => {
+    ok(isCaretPos(gPanel, 15),
+      "The source editor caret position was incorrect.");
+    is(gDebugger.gThreadClient.state, "paused",
+      "Should only be getting stack frames while paused.");
+    is(gDebugger.document.querySelectorAll(".dbg-stackframe").length, 3,
+      "Should have three frames.");
+    is(gDebugger.document.querySelector("#stackframe-0 .dbg-stackframe-title").getAttribute("value"),
+      "anonFunc", "Frame name should be 'anonFunc'.");
 
-      is(frames.querySelectorAll(".dbg-stackframe").length, 3,
-        "Should have three frames.");
-
-      is(frames.querySelector("#stackframe-0 .dbg-stackframe-title").getAttribute("value"),
-        "anonFunc", "Frame name should be anonFunc");
-
-      testInferredName();
-    }}, 0);
+    testInferredName();
   });
 
   gDebuggee.evalCall();
 }
 
 function testInferredName() {
-  gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
-    Services.tm.currentThread.dispatch({ run: function() {
-
-      let frames = gDebugger.DebuggerView.StackFrames.widget._list;
-
-      is(gDebugger.DebuggerController.activeThread.state, "paused",
-        "Should only be getting stack frames while paused.");
+  waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
+    ok(isCaretPos(gPanel, 15),
+      "The source editor caret position was incorrect.");
+    is(gDebugger.gThreadClient.state, "paused",
+      "Should only be getting stack frames while paused.");
+    is(gDebugger.document.querySelectorAll(".dbg-stackframe").length, 3,
+      "Should have three frames.");
+    is(gDebugger.document.querySelector("#stackframe-0 .dbg-stackframe-title").getAttribute("value"),
+      "a/<", "Frame name should be 'a/<'.");
 
-      is(frames.querySelectorAll(".dbg-stackframe").length, 3,
-        "Should have three frames.");
-
-      is(frames.querySelector("#stackframe-0 .dbg-stackframe-title").getAttribute("value"),
-        "a/<", "Frame name should be a/<");
-
-      resumeAndFinish();
-    }}, 0);
+    resumeDebuggerThenCloseAndFinish(gPanel);
   });
 
-  gDebugger.DebuggerController.activeThread.resume();
+  gDebugger.gThreadClient.resume();
 }
 
-function resumeAndFinish() {
-  gDebugger.DebuggerController.activeThread.resume(function() {
-    removeTab(gTab);
-    gPane = null;
-    gDebuggee = null;
-    finish();
-  });
-}
+registerCleanupFunction(function() {
+  gTab = null;
+  gDebuggee = null;
+  gPanel = null;
+  gDebugger = null;
+});
rename from browser/devtools/debugger/test/browser_dbg_globalactor-01.js
rename to browser/devtools/debugger/test/browser_dbg_globalactor.js
--- a/browser/devtools/debugger/test/browser_dbg_globalactor-01.js
+++ b/browser/devtools/debugger/test/browser_dbg_globalactor.js
@@ -1,65 +1,73 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Check extension-added global actor API.
  */
 
-var gClient = null;
+const CHROME_URL = "chrome://mochitests/content/browser/browser/devtools/debugger/test/"
+const ACTORS_URL = CHROME_URL + "testactors.js";
+
+function test() {
+  let gClient;
 
-function test()
-{
-  DebuggerServer.addActors("chrome://mochitests/content/browser/browser/devtools/debugger/test/testactors.js");
+  if (!DebuggerServer.initialized) {
+    DebuggerServer.init(() => true);
+    DebuggerServer.addBrowserActors();
+  }
+
+  DebuggerServer.addActors(ACTORS_URL);
 
   let transport = DebuggerServer.connectPipe();
   gClient = new DebuggerClient(transport);
-  gClient.connect(function(aType, aTraits) {
-    is(aType, "browser", "Root actor should identify itself as a browser.");
-    gClient.listTabs(function(aResponse) {
+  gClient.connect((aType, aTraits) => {
+    is(aType, "browser",
+      "Root actor should identify itself as a browser.");
+
+    gClient.listTabs(aResponse => {
       let globalActor = aResponse.testGlobalActor1;
       ok(globalActor, "Found the test tab actor.")
-      ok(globalActor.indexOf("testone") >= 0,
-         "testTabActor's actorPrefix should be used.");
-      gClient.request({ to: globalActor, type: "ping" }, function(aResponse) {
+      ok(globalActor.contains("test_one"),
+        "testGlobalActor1's actorPrefix should be used.");
+
+      gClient.request({ to: globalActor, type: "ping" }, aResponse => {
         is(aResponse.pong, "pong", "Actor should respond to requests.");
+
         // Send another ping to see if the same actor is used.
-        gClient.request({ to: globalActor, type: "ping" }, function(aResponse) {
+        gClient.request({ to: globalActor, type: "ping" }, aResponse => {
           is(aResponse.pong, "pong", "Actor should respond to requests.");
 
           // Make sure that lazily-created actors are created only once.
           let conn = transport._serverConnection;
+
           // First we look for the pool of global actors.
           let extraPools = conn._extraPools;
+          let globalPool;
 
-          let globalPool;
           for (let pool of extraPools) {
-            if (Object.keys(pool._actors).some(function(elem) {
+            if (Object.keys(pool._actors).some(e => {
               // Tab actors are in the global pool.
               let re = new RegExp(conn._prefix + "tab", "g");
-              return elem.match(re) !== null;
+              return e.match(re) !== null;
             })) {
               globalPool = pool;
               break;
             }
           }
+
           // Then we look if the global pool contains only one test actor.
-          let actorPrefix = conn._prefix + "testone";
+          let actorPrefix = conn._prefix + "test_one";
           let actors = Object.keys(globalPool._actors).join();
           info("Global actors: " + actors);
-          isnot(actors.indexOf(actorPrefix), -1, "The test actor exists in the pool.");
+
+          isnot(actors.indexOf(actorPrefix), -1,
+            "The test actor exists in the pool.");
           is(actors.indexOf(actorPrefix), actors.lastIndexOf(actorPrefix),
-             "Only one actor exists in the pool.");
+            "Only one actor exists in the pool.");
 
-          finish_test();
+          gClient.close(finish);
         });
       });
     });
   });
 }
-
-function finish_test()
-{
-  gClient.close(function() {
-    finish();
-  });
-}
--- a/browser/devtools/debugger/test/browser_dbg_iframes.js
+++ b/browser/devtools/debugger/test/browser_dbg_iframes.js
@@ -1,67 +1,67 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that iframes can be added as debuggees.
  */
 
-// Tests that iframes can be added as debuggees.
-
-var gPane = null;
-var gTab = null;
-var gDebugger = null;
-
-const TEST_URL = EXAMPLE_URL + "browser_dbg_iframes.html";
+const TAB_URL = EXAMPLE_URL + "doc_iframes.html";
 
 function test() {
-  debug_tab_pane(TEST_URL, function(aTab, aDebuggee, aPane) {
-    gTab = aTab;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
+  let gTab, gDebuggee, gPanel, gDebugger;
+  let gIframe, gEditor, gSources, gFrames;
 
-    is(gDebugger.DebuggerController.activeThread.paused, false,
-      "Should be running after debug_tab_pane.");
-
-    gDebugger.DebuggerController.activeThread.addOneTimeListener("framesadded", function() {
-      Services.tm.currentThread.dispatch({ run: function() {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
+    gTab = aTab;
+    gDebuggee = aDebuggee;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gIframe = gDebuggee.frames[0];
+    gEditor = gDebugger.DebuggerView.editor;
+    gSources = gDebugger.DebuggerView.Sources;
+    gFrames = gDebugger.DebuggerView.StackFrames;
 
-        let frames = gDebugger.DebuggerView.StackFrames.widget._list;
-        let childNodes = frames.childNodes;
-
-        is(gDebugger.DebuggerController.activeThread.paused, true,
-          "Should be paused after an interrupt request.");
+    waitForSourceShown(gPanel, "inline-debugger-statement.html")
+      .then(checkIframeSource)
+      .then(checkIframePause)
+      .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
+  });
 
-        is(frames.querySelectorAll(".dbg-stackframe").length, 1,
-          "Should have one frame in the stack.");
-
-        gDebugger.DebuggerController.activeThread.addOneTimeListener("resumed", function() {
-          Services.tm.currentThread.dispatch({ run: function() {
-            closeDebuggerAndFinish();
-          }}, 0);
-        });
+  function checkIframeSource() {
+    is(gDebugger.gThreadClient.paused, false,
+      "Should be running after starting the test.");
 
-        EventUtils.sendMouseEvent({ type: "mousedown" },
-          gDebugger.document.getElementById("resume"),
-          gDebugger);
-      }}, 0);
-    });
+    ok(isCaretPos(gPanel, 1),
+      "The source editor caret position was incorrect.");
+    is(gFrames.itemCount, 0,
+      "Should have only no frames.");
 
-    let iframe = gTab.linkedBrowser.contentWindow.wrappedJSObject.frames[0];
-    is(iframe.document.title, "Browser Debugger Test Tab", "Found the iframe");
+    is(gSources.itemCount, 1,
+      "Found the expected number of entries in the sources widget.");
+    is(gEditor.getText().indexOf("debugger"), 348,
+      "The correct source was loaded initially.");
+    is(gSources.selectedLabel, "doc_inline-debugger-statement.html",
+      "The currently selected source label is incorrect.");
+    is(gSources.selectedValue, gSources.values[0],
+      "The currently selected source value is incorrect.");
+  }
 
-    function handler() {
-      if (iframe.document.readyState != "complete") {
-        return;
-      }
-      iframe.window.removeEventListener("load", handler, false);
-      executeSoon(iframe.runDebuggerStatement);
-    };
-    iframe.window.addEventListener("load", handler, false);
-    handler();
-  });
+  function checkIframePause() {
+    // Spin the event loop before causing the debuggee to pause, to allow
+    // this function to return first.
+    executeSoon(() => gIframe.runDebuggerStatement());
+
+    return waitForCaretAndScopes(gPanel, 16).then(() => {
+      is(gDebugger.gThreadClient.paused, true,
+        "Should be paused after an interrupt request.");
+
+      ok(isCaretPos(gPanel, 16),
+        "The source editor caret position was incorrect.");
+      is(gFrames.itemCount, 1,
+        "Should have only one frame.");
+    });
+  }
 }
-
-registerCleanupFunction(function() {
-  removeTab(gTab);
-  gPane = null;
-  gTab = null;
-  gDebugger = null;
-});
rename from browser/devtools/debugger/test/browser_dbg_pane-collapse.js
rename to browser/devtools/debugger/test/browser_dbg_instruments-pane-collapse.js
--- a/browser/devtools/debugger/test/browser_dbg_pane-collapse.js
+++ b/browser/devtools/debugger/test/browser_dbg_instruments-pane-collapse.js
@@ -1,99 +1,102 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that the debugger panes collapse properly.
  */
 
-// Tests that the debugger panes collapse properly.
+const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
 
-var gPane = null;
-var gTab = null;
-var gDebuggee = null;
-var gDebugger = null;
-var gView = null;
+let gTab, gDebuggee, gPanel, gDebugger;
+let gPrefs, gOptions;
 
 function test() {
-  debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
     gDebuggee = aDebuggee;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
-    gView = gDebugger.DebuggerView;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gPrefs = gDebugger.Prefs;
+    gOptions = gDebugger.DebuggerView.Options;
 
     testPanesState();
 
-    gView.toggleInstrumentsPane({ visible: true, animated: false });
+    gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false });
+
     testInstrumentsPaneCollapse();
     testPanesStartupPref();
+
+    closeDebuggerAndFinish(gPanel);
   });
 }
 
 function testPanesState() {
   let instrumentsPane =
     gDebugger.document.getElementById("instruments-pane");
   let instrumentsPaneToggleButton =
     gDebugger.document.getElementById("instruments-pane-toggle");
 
   ok(instrumentsPane.hasAttribute("pane-collapsed") &&
      instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
     "The debugger view instruments pane should initially be hidden.");
-  is(gDebugger.Prefs.panesVisibleOnStartup, false,
+  is(gPrefs.panesVisibleOnStartup, false,
     "The debugger view instruments pane should initially be preffed as hidden.");
-  isnot(gDebugger.DebuggerView.Options._showPanesOnStartupItem.getAttribute("checked"), "true",
+  isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
     "The options menu item should not be checked.");
 }
 
 function testInstrumentsPaneCollapse() {
   let instrumentsPane =
     gDebugger.document.getElementById("instruments-pane");
   let instrumentsPaneToggleButton =
     gDebugger.document.getElementById("instruments-pane-toggle");
 
   let width = parseInt(instrumentsPane.getAttribute("width"));
-  is(width, gDebugger.Prefs.instrumentsWidth,
+  is(width, gPrefs.instrumentsWidth,
     "The instruments pane has an incorrect width.");
   is(instrumentsPane.style.marginLeft, "0px",
     "The instruments pane has an incorrect left margin.");
   is(instrumentsPane.style.marginRight, "0px",
     "The instruments pane has an incorrect right margin.");
   ok(!instrumentsPane.hasAttribute("animated"),
     "The instruments pane has an incorrect animated attribute.");
   ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
      !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
     "The instruments pane should at this point be visible.");
 
-  gView.toggleInstrumentsPane({ visible: false, animated: true });
+  gDebugger.DebuggerView.toggleInstrumentsPane({ visible: false, animated: true });
 
-  is(gDebugger.Prefs.panesVisibleOnStartup, false,
+  is(gPrefs.panesVisibleOnStartup, false,
     "The debugger view panes should still initially be preffed as hidden.");
-  isnot(gDebugger.DebuggerView.Options._showPanesOnStartupItem.getAttribute("checked"), "true",
+  isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
     "The options menu item should still not be checked.");
 
   let margin = -(width + 1) + "px";
-  is(width, gDebugger.Prefs.instrumentsWidth,
+  is(width, gPrefs.instrumentsWidth,
     "The instruments pane has an incorrect width after collapsing.");
   is(instrumentsPane.style.marginLeft, margin,
     "The instruments pane has an incorrect left margin after collapsing.");
   is(instrumentsPane.style.marginRight, margin,
     "The instruments pane has an incorrect right margin after collapsing.");
   ok(instrumentsPane.hasAttribute("animated"),
     "The instruments pane has an incorrect attribute after an animated collapsing.");
   ok(instrumentsPane.hasAttribute("pane-collapsed") &&
      instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
     "The instruments pane should not be visible after collapsing.");
 
-  gView.toggleInstrumentsPane({ visible: true, animated: false });
+  gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false });
 
-  is(gDebugger.Prefs.panesVisibleOnStartup, false,
+  is(gPrefs.panesVisibleOnStartup, false,
     "The debugger view panes should still initially be preffed as hidden.");
-  isnot(gDebugger.DebuggerView.Options._showPanesOnStartupItem.getAttribute("checked"), "true",
+  isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
     "The options menu item should still not be checked.");
 
-  is(width, gDebugger.Prefs.instrumentsWidth,
+  is(width, gPrefs.instrumentsWidth,
     "The instruments pane has an incorrect width after uncollapsing.");
   is(instrumentsPane.style.marginLeft, "0px",
     "The instruments pane has an incorrect left margin after uncollapsing.");
   is(instrumentsPane.style.marginRight, "0px",
     "The instruments pane has an incorrect right margin after uncollapsing.");
   ok(!instrumentsPane.hasAttribute("animated"),
     "The instruments pane has an incorrect attribute after an unanimated uncollapsing.");
   ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
@@ -102,58 +105,50 @@ function testInstrumentsPaneCollapse() {
 }
 
 function testPanesStartupPref() {
   let instrumentsPane =
     gDebugger.document.getElementById("instruments-pane");
   let instrumentsPaneToggleButton =
     gDebugger.document.getElementById("instruments-pane-toggle");
 
-  is(gDebugger.Prefs.panesVisibleOnStartup, false,
+  is(gPrefs.panesVisibleOnStartup, false,
     "The debugger view panes should still initially be preffed as hidden.");
 
   ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
      !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
     "The debugger instruments pane should at this point be visible.");
-  is(gDebugger.Prefs.panesVisibleOnStartup, false,
+  is(gPrefs.panesVisibleOnStartup, false,
     "The debugger view panes should initially be preffed as hidden.");
-  isnot(gDebugger.DebuggerView.Options._showPanesOnStartupItem.getAttribute("checked"), "true",
+  isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
     "The options menu item should still not be checked.");
 
-  gDebugger.DebuggerView.Options._showPanesOnStartupItem.setAttribute("checked", "true");
-  gDebugger.DebuggerView.Options._toggleShowPanesOnStartup();
+  gOptions._showPanesOnStartupItem.setAttribute("checked", "true");
+  gOptions._toggleShowPanesOnStartup();
 
-  executeSoon(function() {
-    ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
-       !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
-      "The debugger instruments pane should at this point be visible.");
-    is(gDebugger.Prefs.panesVisibleOnStartup, true,
-      "The debugger view panes should now be preffed as visible.");
-    is(gDebugger.DebuggerView.Options._showPanesOnStartupItem.getAttribute("checked"), "true",
-      "The options menu item should now be checked.");
-
-    gDebugger.DebuggerView.Options._showPanesOnStartupItem.setAttribute("checked", "false");
-    gDebugger.DebuggerView.Options._toggleShowPanesOnStartup();
+  ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
+     !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
+    "The debugger instruments pane should at this point be visible.");
+  is(gPrefs.panesVisibleOnStartup, true,
+    "The debugger view panes should now be preffed as visible.");
+  is(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
+    "The options menu item should now be checked.");
 
-    executeSoon(function() {
-      ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
-         !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
-        "The debugger instruments pane should at this point be visible.");
-      is(gDebugger.Prefs.panesVisibleOnStartup, false,
-        "The debugger view panes should now be preffed as hidden.");
-      isnot(gDebugger.DebuggerView.Options._showPanesOnStartupItem.getAttribute("checked"), "true",
-        "The options menu item should now be unchecked.");
+  gOptions._showPanesOnStartupItem.setAttribute("checked", "false");
+  gOptions._toggleShowPanesOnStartup();
 
-      executeSoon(function() {
-        closeDebuggerAndFinish();
-      });
-    });
-  });
+  ok(!instrumentsPane.hasAttribute("pane-collapsed") &&
+     !instrumentsPaneToggleButton.hasAttribute("pane-collapsed"),
+    "The debugger instruments pane should at this point be visible.");
+  is(gPrefs.panesVisibleOnStartup, false,
+    "The debugger view panes should now be preffed as hidden.");
+  isnot(gOptions._showPanesOnStartupItem.getAttribute("checked"), "true",
+    "The options menu item should now be unchecked.");
 }
 
 registerCleanupFunction(function() {
-  removeTab(gTab);
-  gPane = null;
   gTab = null;
   gDebuggee = null;
+  gPanel = null;
   gDebugger = null;
-  gView = null;
+  gPrefs = null;
+  gOptions = null;
 });
--- a/browser/devtools/debugger/test/browser_dbg_listaddons.js
+++ b/browser/devtools/debugger/test/browser_dbg_listaddons.js
@@ -1,100 +1,114 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-// Make sure the listAddons request works as specified.
-
-var gAddon1 = null;
-var gAddon1Actor = null;
+/**
+ * Make sure the listAddons request works as specified.
+ */
+const ADDON1_URL = EXAMPLE_URL + "addon1.xpi";
+const ADDON2_URL = EXAMPLE_URL + "addon2.xpi";
 
-var gAddon2 = null;
-var gAddon2Actor = null;
+let gAddon1, gAddon1Actor, gAddon2, gAddon2Actor, gClient;
 
-var gClient = null;
+function test() {
+  if (!DebuggerServer.initialized) {
+    DebuggerServer.init(() => true);
+    DebuggerServer.addBrowserActors();
+  }
 
-function test()
-{
   let transport = DebuggerServer.connectPipe();
   gClient = new DebuggerClient(transport);
-  gClient.connect(function (aType, aTraits) {
-    is(aType, "browser", "Root actor should identify itself as a browser.");
-    test_first_addon();
-  })
+  gClient.connect((aType, aTraits) => {
+    is(aType, "browser",
+      "Root actor should identify itself as a browser.");
+
+    promise.resolve(null)
+      .then(testFirstAddon)
+      .then(testSecondAddon)
+      .then(testRemoveFirstAddon)
+      .then(testRemoveSecondAddon)
+      .then(closeConnection)
+      .then(finish)
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
+  });
 }
 
-function test_first_addon()
-{
+function testFirstAddon() {
   let addonListChanged = false;
-  gClient.addOneTimeListener("addonListChanged", function () {
+  gClient.addOneTimeListener("addonListChanged", () => {
     addonListChanged = true;
   });
-  addAddon(ADDON1_URL, function(aAddon) {
+
+  return addAddon(ADDON1_URL).then(aAddon => {
     gAddon1 = aAddon;
-    gClient.listAddons(function(aResponse) {
-      for each (let addon in aResponse.addons) {
-        if (addon.url == ADDON1_URL) {
-          gAddon1Actor = addon.actor;
-        }
-      }
+
+    return getAddonActorForUrl(gClient, ADDON1_URL).then(aGrip => {
       ok(!addonListChanged, "Should not yet be notified that list of addons changed.");
-      ok(gAddon1Actor, "Should find an addon actor for addon1.");
-      test_second_addon();
+      ok(aGrip, "Should find an addon actor for addon1.");
+      gAddon1Actor = aGrip.actor;
     });
   });
 }
 
-function test_second_addon()
-{
+function testSecondAddon() {
   let addonListChanged = false;
   gClient.addOneTimeListener("addonListChanged", function () {
     addonListChanged = true;
   });
-  addAddon(ADDON2_URL, function(aAddon) {
+
+  return addAddon(ADDON2_URL).then(aAddon => {
     gAddon2 = aAddon;
-    gClient.listAddons(function(aResponse) {
-      let foundAddon1 = false;
-      for each (let addon in aResponse.addons) {
-        if (addon.url == ADDON1_URL) {
-          is(addon.actor, gAddon1Actor, "Addon1's actor shouldn't have changed.");
-          foundAddon1 = true;
-        }
-        if (addon.url == ADDON2_URL) {
-          gAddon2Actor = addon.actor;
-        }
-      }
-      ok(addonListChanged, "Should be notified that list of addons changed.");
-      ok(foundAddon1, "Should find an addon actor for addon1.");
-      ok(gAddon2Actor, "Should find an actor for addon2.");
-      test_remove_addon();
+
+    return getAddonActorForUrl(gClient, ADDON1_URL).then(aFirstGrip => {
+      return getAddonActorForUrl(gClient, ADDON2_URL).then(aSecondGrip => {
+        ok(addonListChanged, "Should be notified that list of addons changed.");
+        is(aFirstGrip.actor, gAddon1Actor, "First addon's actor shouldn't have changed.");
+        ok(aSecondGrip, "Should find a addon actor for the second addon.");
+        gAddon2Actor = aSecondGrip.actor;
+      });
     });
   });
 }
 
-function test_remove_addon()
-{
+function testRemoveFirstAddon() {
+  let addonListChanged = false;
+  gClient.addOneTimeListener("addonListChanged", function () {
+    addonListChanged = true;
+  });
+
+  removeAddon(gAddon1).then(() => {
+    return getAddonActorForUrl(gClient, ADDON1_URL).then(aGrip => {
+      ok(addonListChanged, "Should be notified that list of addons changed.");
+      ok(!aGrip, "Shouldn't find a addon actor for the first addon anymore.");
+    });
+  });
+}
+
+function testRemoveSecondAddon() {
   let addonListChanged = false;
   gClient.addOneTimeListener("addonListChanged", function () {
     addonListChanged = true;
   });
-  removeAddon(gAddon1, function() {
-    gClient.listAddons(function(aResponse) {
-      let foundAddon1 = false;
-      for each (let addon in aResponse.addons) {
-        if (addon.url == ADDON1_URL) {
-          foundAddon1 = true;
-        }
-      }
+
+  removeAddon(gAddon2).then(() => {
+    return getAddonActorForUrl(gClient, ADDON2_URL).then(aGrip => {
       ok(addonListChanged, "Should be notified that list of addons changed.");
-      ok(!foundAddon1, "Addon1 should be gone");
-      finish_test();
+      ok(!aGrip, "Shouldn't find a addon actor for the second addon anymore.");
     });
   });
 }
 
-function finish_test()
-{
-  removeAddon(gAddon2, function() {
-    gClient.close(function() {
-      finish();
-    });
-  });
+function closeConnection() {
+  let deferred = promise.defer();
+  gClient.close(deferred.resolve);
+  return deferred.promise;
 }
+
+registerCleanupFunction(function() {
+  gAddon1 = null;
+  gAddon1Actor = null;
+  gAddon2 = null;
+  gAddon2Actor = null;
+  gClient = null;
+});
--- a/browser/devtools/debugger/test/browser_dbg_listtabs-01.js
+++ b/browser/devtools/debugger/test/browser_dbg_listtabs-01.js
@@ -1,102 +1,101 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-// Make sure the listTabs request works as specified.
+/**
+ * Make sure the listTabs request works as specified.
+ */
 
-var gTab1 = null;
-var gTab1Actor = null;
+const TAB1_URL = EXAMPLE_URL + "doc_empty-tab-01.html";
+const TAB2_URL = EXAMPLE_URL + "doc_empty-tab-02.html";
 
-var gTab2 = null;
-var gTab2Actor = null;
+let gTab1, gTab1Actor, gTab2, gTab2Actor, gClient;
 
-var gClient = null;
+function test() {
+  if (!DebuggerServer.initialized) {
+    DebuggerServer.init(() => true);
+    DebuggerServer.addBrowserActors();
+  }
 
-function test()
-{
   let transport = DebuggerServer.connectPipe();
   gClient = new DebuggerClient(transport);
-  gClient.connect(function(aType, aTraits) {
-    is(aType, "browser", "Root actor should identify itself as a browser.");
-    test_first_tab();
+  gClient.connect((aType, aTraits) => {
+    is(aType, "browser",
+      "Root actor should identify itself as a browser.");
+
+    promise.resolve(null)
+      .then(testFirstTab)
+      .then(testSecondTab)
+      .then(testRemoveTab)
+      .then(testAttachRemovedTab)
+      .then(closeConnection)
+      .then(finish)
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
   });
 }
 
-/**
- * Verify that a new tab shows up in a listTabs call.
- */
-function test_first_tab()
-{
-  gTab1 = addTab(TAB1_URL, function() {
-    gClient.listTabs(function(aResponse) {
-      for each (let tab in aResponse.tabs) {
-        if (tab.url == TAB1_URL) {
-          gTab1Actor = tab.actor;
-        }
-      }
-      ok(gTab1Actor, "Should find a tab actor for tab1.");
-      test_second_tab();
+function testFirstTab() {
+  return addTab(TAB1_URL).then(aTab => {
+    gTab1 = aTab;
+
+    return getTabActorForUrl(gClient, TAB1_URL).then(aGrip => {
+      ok(aGrip, "Should find a tab actor for the first tab.");
+      gTab1Actor = aGrip.actor;
     });
   });
 }
 
-function test_second_tab()
-{
-  gTab2 = addTab(TAB2_URL, function() {
-    gClient.listTabs(function(aResponse) {
-      // Verify that tab1 has the same actor it used to.
-      let foundTab1 = false;
-      for each (let tab in aResponse.tabs) {
-        if (tab.url == TAB1_URL) {
-          is(tab.actor, gTab1Actor, "Tab1's actor shouldn't have changed.");
-          foundTab1 = true;
-        }
-        if (tab.url == TAB2_URL) {
-          gTab2Actor = tab.actor;
-        }
-      }
-      ok(foundTab1, "Should have found an actor for tab 1.");
-      ok(gTab2Actor != null, "Should find an actor for tab2.");
+function testSecondTab() {
+  return addTab(TAB2_URL).then(aTab => {
+    gTab2 = aTab;
 
-      test_remove_tab();
+    return getTabActorForUrl(gClient, TAB1_URL).then(aFirstGrip => {
+      return getTabActorForUrl(gClient, TAB2_URL).then(aSecondGrip => {
+        is(aFirstGrip.actor, gTab1Actor, "First tab's actor shouldn't have changed.");
+        ok(aSecondGrip, "Should find a tab actor for the second tab.");
+        gTab2Actor = aSecondGrip.actor;
+      });
+    });
+  });
+}
+
+function testRemoveTab() {
+  return removeTab(gTab1).then(() => {
+    return getTabActorForUrl(gClient, TAB1_URL).then(aGrip => {
+      ok(!aGrip, "Shouldn't find a tab actor for the first tab anymore.");
     });
   });
 }
 
-function test_remove_tab()
-{
-  removeTab(gTab1);
-  gTab1 = null;
-  gClient.listTabs(function(aResponse) {
-    // Verify that tab1 is no longer included in listTabs.
-    let foundTab1 = false;
-    for each (let tab in aResponse.tabs) {
-      if (tab.url == TAB1_URL) {
-        ok(false, "Tab1 should be gone.");
-      }
-    }
-    ok(!foundTab1, "Tab1 should be gone.");
-    test_attach_removed_tab();
+function testAttachRemovedTab() {
+  return removeTab(gTab2).then(() => {
+    let deferred = promise.defer();
+
+    gClient.addListener("paused", (aEvent, aPacket) => {
+      ok(false, "Attaching to an exited tab actor shouldn't generate a pause.");
+      deferred.reject();
+    });
+
+    gClient.request({ to: gTab2Actor, type: "attach" }, aResponse => {
+      is(aResponse.type, "exited", "Tab should consider itself exited.");
+      deferred.resolve();
+    });
+
+    return deferred.promise;
   });
 }
 
-function test_attach_removed_tab()
-{
-  removeTab(gTab2);
-  gTab2 = null;
-  gClient.addListener("paused", function(aEvent, aPacket) {
-    ok(false, "Attaching to an exited tab actor shouldn't generate a pause.");
-    finish_test();
-  });
-
-  gClient.request({ to: gTab2Actor, type: "attach" }, function(aResponse) {
-    is(aResponse.type, "exited", "Tab should consider itself exited.");
-    finish_test();
-  });
+function closeConnection() {
+  let deferred = promise.defer();
+  gClient.close(deferred.resolve);
+  return deferred.promise;
 }
 
-function finish_test()
-{
-  gClient.close(function() {
-    finish();
-  });
-}
+registerCleanupFunction(function() {
+  gTab1 = null;
+  gTab1Actor = null;
+  gTab2 = null;
+  gTab2Actor = null;
+  gClient = null;
+});
--- a/browser/devtools/debugger/test/browser_dbg_listtabs-02.js
+++ b/browser/devtools/debugger/test/browser_dbg_listtabs-02.js
@@ -1,162 +1,210 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
-// Make sure the root actor's live tab list implementation works as specified.
+/**
+ * Make sure the root actor's live tab list implementation works as specified.
+ */
 
-let testPage = ("data:text/html;charset=utf-8,"
-                + encodeURIComponent("<title>JS Debugger BrowserTabList test page</title>" +
-                                     "<body>Yo.</body>"));
+let gTestPage = "data:text/html;charset=utf-8," + encodeURIComponent(
+  "<title>JS Debugger BrowserTabList test page</title><body>Yo.</body>");
+
 // The tablist object whose behavior we observe.
-let tabList;
-let firstActor, actorA;
-let tabA, tabB, tabC;
-let newWin;
+let gTabList;
+let gFirstActor, gActorA;
+let gTabA, gTabB, gTabC;
+let gNewWindow;
+
 // Stock onListChanged handler.
 let onListChangedCount = 0;
 function onListChangedHandler() {
   onListChangedCount++;
 }
 
 function test() {
-  tabList = new DebuggerServer.BrowserTabList("fake DebuggerServerConnection");
-  tabList._testing = true;
-  tabList.onListChanged = onListChangedHandler;
-  checkSingleTab(function () {
-    is(onListChangedCount, 0, "onListChanged handler call count");
-    tabA = addTab(testPage, onTabA);
-  });
+  if (!DebuggerServer.initialized) {
+    DebuggerServer.init(() => true);
+    DebuggerServer.addBrowserActors();
+  }
+
+  gTabList = new DebuggerServer.BrowserTabList("fake DebuggerServerConnection");
+  gTabList._testing = true;
+  gTabList.onListChanged = onListChangedHandler;
+
+  checkSingleTab()
+    .then(addTabA)
+    .then(testTabA)
+    .then(addTabB)
+    .then(testTabB)
+    .then(removeTabA)
+    .then(testTabClosed)
+    .then(addTabC)
+    .then(testTabC)
+    .then(removeTabC)
+    .then(testNewWindow)
+    .then(removeNewWindow)
+    .then(testWindowClosed)
+    .then(removeTabB)
+    .then(checkSingleTab)
+    .then(finish);
 }
 
-function checkSingleTab(callback) {
-  tabList.getList().then(function (tabActors) {
-    is(tabActors.length, 1, "initial tab list: contains initial tab");
-    firstActor = tabActors[0];
-    is(firstActor.url, "about:blank", "initial tab list: initial tab URL is 'about:blank'");
-    is(firstActor.title, "New Tab", "initial tab list: initial tab title is 'New Tab'");
-    callback();
+function checkSingleTab() {
+  return gTabList.getList().then(aTabActors => {
+    is(aTabActors.length, 1, "initial tab list: contains initial tab");
+    gFirstActor = aTabActors[0];
+    is(gFirstActor.url, "about:blank", "initial tab list: initial tab URL is 'about:blank'");
+    is(gFirstActor.title, "New Tab", "initial tab list: initial tab title is 'New Tab'");
   });
 }
 
-function onTabA() {
-  is(onListChangedCount, 1, "onListChanged handler call count");
-
-  tabList.getList().then(function (tabActors) {
-    tabActors = new Set(tabActors);
-    is(tabActors.size, 2, "tabA opened: two tabs in list");
-    ok(tabActors.has(firstActor), "tabA opened: initial tab present");
-
-    info("actors: " + [a.url for (a of tabActors)]);
-    actorA = [a for (a of tabActors) if (a !== firstActor)][0];
-    ok(actorA.url.match(/^data:text\/html;/), "tabA opened: new tab URL");
-    is(actorA.title, "JS Debugger BrowserTabList test page", "tabA opened: new tab title");
-
-    tabB = addTab(testPage, onTabB);
+function addTabA() {
+  return addTab(gTestPage).then(aTab => {
+    gTabA = aTab;
   });
 }
 
-function onTabB() {
+function testTabA() {
+  is(onListChangedCount, 1, "onListChanged handler call count");
+
+  return gTabList.getList().then(aTabActors => {
+    let tabActors = new Set(aTabActors);
+    is(tabActors.size, 2, "gTabA opened: two tabs in list");
+    ok(tabActors.has(gFirstActor), "gTabA opened: initial tab present");
+
+    info("actors: " + [a.url for (a of tabActors)]);
+    gActorA = [a for (a of tabActors) if (a !== gFirstActor)][0];
+    ok(gActorA.url.match(/^data:text\/html;/), "gTabA opened: new tab URL");
+    is(gActorA.title, "JS Debugger BrowserTabList test page", "gTabA opened: new tab title");
+  });
+}
+
+function addTabB() {
+  return addTab(gTestPage).then(aTab => {
+    gTabB = aTab;
+  });
+}
+
+function testTabB() {
   is(onListChangedCount, 2, "onListChanged handler call count");
 
-  tabList.getList().then(function (tabActors) {
-    tabActors = new Set(tabActors);
-    is(tabActors.size, 3, "tabB opened: three tabs in list");
-
-    // Test normal close.
-    gBrowser.tabContainer.addEventListener("TabClose", function onClose(aEvent) {
-      gBrowser.tabContainer.removeEventListener("TabClose", onClose, false);
-      ok(!aEvent.detail, "This was a normal tab close");
-      // Let the actor's TabClose handler finish first.
-      executeSoon(testTabClose);
-    }, false);
-    gBrowser.removeTab(tabA);
+  return gTabList.getList().then(aTabActors => {
+    let tabActors = new Set(aTabActors);
+    is(tabActors.size, 3, "gTabB opened: three tabs in list");
   });
 }
 
-function testTabClose() {
+function removeTabA() {
+  let deferred = promise.defer();
+
+  once(gBrowser.tabContainer, "TabClose").then(aEvent => {
+    ok(!aEvent.detail, "This was a normal tab close");
+
+    // Let the actor's TabClose handler finish first.
+    executeSoon(deferred.resolve);
+  }, false);
+
+  removeTab(gTabA);
+  return deferred.promise;
+}
+
+function testTabClosed() {
   is(onListChangedCount, 3, "onListChanged handler call count");
 
-  tabList.getList().then(function (tabActors) {
-    tabActors = new Set(tabActors);
-    is(tabActors.size, 2, "tabA closed: two tabs in list");
-    ok(tabActors.has(firstActor), "tabA closed: initial tab present");
+  gTabList.getList().then(aTabActors => {
+    let tabActors = new Set(aTabActors);
+    is(tabActors.size, 2, "gTabA closed: two tabs in list");
+    ok(tabActors.has(gFirstActor), "gTabA closed: initial tab present");
 
     info("actors: " + [a.url for (a of tabActors)]);
-    actorA = [a for (a of tabActors) if (a !== firstActor)][0];
-    ok(actorA.url.match(/^data:text\/html;/), "tabA closed: new tab URL");
-    is(actorA.title, "JS Debugger BrowserTabList test page", "tabA closed: new tab title");
-
-    // Test tab close by moving tab to a window.
-    tabC = addTab(testPage, onTabC);
+    gActorA = [a for (a of tabActors) if (a !== gFirstActor)][0];
+    ok(gActorA.url.match(/^data:text\/html;/), "gTabA closed: new tab URL");
+    is(gActorA.title, "JS Debugger BrowserTabList test page", "gTabA closed: new tab title");
   });
 }
 
-function onTabC() {
+function addTabC() {
+  return addTab(gTestPage).then(aTab => {
+    gTabC = aTab;
+  });
+}
+
+function testTabC() {
   is(onListChangedCount, 4, "onListChanged handler call count");
 
-  tabList.getList().then(function (tabActors) {
-    tabActors = new Set(tabActors);
-    is(tabActors.size, 3, "tabC opened: three tabs in list");
-
-    gBrowser.tabContainer.addEventListener("TabClose", function onClose2(aEvent) {
-      gBrowser.tabContainer.removeEventListener("TabClose", onClose2, false);
-      ok(aEvent.detail, "This was a tab closed by moving");
-      // Let the actor's TabClose handler finish first.
-      executeSoon(testWindowClose);
-    }, false);
-    newWin = gBrowser.replaceTabWithWindow(tabC);
+  gTabList.getList().then(aTabActors => {
+    let tabActors = new Set(aTabActors);
+    is(tabActors.size, 3, "gTabC opened: three tabs in list");
   });
 }
 
-function testWindowClose() {
+function removeTabC() {
+  let deferred = promise.defer();
+
+  once(gBrowser.tabContainer, "TabClose").then(aEvent => {
+    ok(aEvent.detail, "This was a tab closed by moving");
+
+    // Let the actor's TabClose handler finish first.
+    executeSoon(deferred.resolve);
+  }, false);
+
+  gNewWindow = gBrowser.replaceTabWithWindow(gTabC);
+  return deferred.promise;
+}
+
+function testNewWindow() {
   is(onListChangedCount, 5, "onListChanged handler call count");
 
-  tabList.getList().then(function (tabActors) {
-    tabActors = new Set(tabActors);
-    is(tabActors.size, 3, "tabC closed: three tabs in list");
-    ok(tabActors.has(firstActor), "tabC closed: initial tab present");
+  return gTabList.getList().then(aTabActors => {
+    let tabActors = new Set(aTabActors);
+    is(tabActors.size, 3, "gTabC closed: three tabs in list");
+    ok(tabActors.has(gFirstActor), "gTabC closed: initial tab present");
 
     info("actors: " + [a.url for (a of tabActors)]);
-    actorA = [a for (a of tabActors) if (a !== firstActor)][0];
-    ok(actorA.url.match(/^data:text\/html;/), "tabC closed: new tab URL");
-    is(actorA.title, "JS Debugger BrowserTabList test page", "tabC closed: new tab title");
-
-    // Cleanup.
-    newWin.addEventListener("unload", function onUnload(aEvent) {
-      newWin.removeEventListener("unload", onUnload, false);
-      ok(!aEvent.detail, "This was a normal window close");
-      // Let the actor's TabClose handler finish first.
-      executeSoon(checkWindowClose);
-    }, false);
-    newWin.close();
+    gActorA = [a for (a of tabActors) if (a !== gFirstActor)][0];
+    ok(gActorA.url.match(/^data:text\/html;/), "gTabC closed: new tab URL");
+    is(gActorA.title, "JS Debugger BrowserTabList test page", "gTabC closed: new tab title");
   });
 }
 
-function checkWindowClose() {
+function removeNewWindow() {
+  let deferred = promise.defer();
+
+  once(gNewWindow, "unload").then(aEvent => {
+    ok(!aEvent.detail, "This was a normal window close");
+
+    // Let the actor's TabClose handler finish first.
+    executeSoon(deferred.resolve);
+  }, false);
+
+  gNewWindow.close();
+  return deferred.promise;
+}
+
+function testWindowClosed() {
   is(onListChangedCount, 6, "onListChanged handler call count");
 
-  // Check that closing a XUL window leaves the other actors intact.
-  tabList.getList().then(function (tabActors) {
-    tabActors = new Set(tabActors);
-    is(tabActors.size, 2, "newWin closed: two tabs in list");
-    ok(tabActors.has(firstActor), "newWin closed: initial tab present");
+  return gTabList.getList().then(aTabActors => {
+    let tabActors = new Set(aTabActors);
+    is(tabActors.size, 2, "gNewWindow closed: two tabs in list");
+    ok(tabActors.has(gFirstActor), "gNewWindow closed: initial tab present");
 
     info("actors: " + [a.url for (a of tabActors)]);
-    actorA = [a for (a of tabActors) if (a !== firstActor)][0];
-    ok(actorA.url.match(/^data:text\/html;/), "newWin closed: new tab URL");
-    is(actorA.title, "JS Debugger BrowserTabList test page", "newWin closed: new tab title");
-
-    // Test normal close.
-    gBrowser.tabContainer.addEventListener("TabClose", function onClose(aEvent) {
-      gBrowser.tabContainer.removeEventListener("TabClose", onClose, false);
-      ok(!aEvent.detail, "This was a normal tab close");
-      // Let the actor's TabClose handler finish first.
-      executeSoon(finishTest);
-    }, false);
-    gBrowser.removeTab(tabB);
+    gActorA = [a for (a of tabActors) if (a !== gFirstActor)][0];
+    ok(gActorA.url.match(/^data:text\/html;/), "gNewWindow closed: new tab URL");
+    is(gActorA.title, "JS Debugger BrowserTabList test page", "gNewWindow closed: new tab title");
   });
 }
 
-function finishTest() {
-  checkSingleTab(finish);
+function removeTabB() {
+  let deferred = promise.defer();
+
+  once(gBrowser.tabContainer, "TabClose").then(aEvent => {
+    ok(!aEvent.detail, "This was a normal tab close");
+
+    // Let the actor's TabClose handler finish first.
+    executeSoon(deferred.resolve);
+  }, false);
+
+  removeTab(gTabB);
+  return deferred.promise;
 }
--- a/browser/devtools/debugger/test/browser_dbg_multiple-windows.js
+++ b/browser/devtools/debugger/test/browser_dbg_multiple-windows.js
@@ -1,142 +1,164 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
-// Make sure that the debugger attaches to the right tab when multiple windows
-// are open.
+/**
+ * Make sure that the debugger attaches to the right tab when multiple windows
+ * are open.
+ */
 
-var gTab1 = null;
-var gTab1Actor = null;
+const TAB1_URL = EXAMPLE_URL + "doc_script-switching-01.html";
+const TAB2_URL = EXAMPLE_URL + "doc_script-switching-02.html";
 
-var gSecondWindow = null;
+let gNewTab, gNewWindow;
+let gClient;
 
-var gClient = null;
-var windowMediator = Cc["@mozilla.org/appshell/window-mediator;1"]
-                     .getService(Ci.nsIWindowMediator);
+function test() {
+  if (!DebuggerServer.initialized) {
+    DebuggerServer.init(() => true);
+    DebuggerServer.addBrowserActors();
+  }
 
-function test()
-{
   let transport = DebuggerServer.connectPipe();
   gClient = new DebuggerClient(transport);
-  gClient.connect(function(aType, aTraits) {
-    is(aType, "browser", "Root actor should identify itself as a browser.");
-    test_first_tab();
-  });
-}
+  gClient.connect((aType, aTraits) => {
+    is(aType, "browser",
+      "Root actor should identify itself as a browser.");
 
-function test_first_tab()
-{
-  gTab1 = addTab(TAB1_URL, function() {
-    gClient.listTabs(function(aResponse) {
-      for each (let tab in aResponse.tabs) {
-        if (tab.url == TAB1_URL) {
-          gTab1Actor = tab.actor;
-        }
-      }
-      ok(gTab1Actor, "Should find a tab actor for tab1.");
-      is(aResponse.selected, 1, "Tab1 is selected.");
-      test_open_window();
-    });
+    promise.resolve(null)
+      .then(() => addTab(TAB1_URL))
+      .then(testFirstTab)
+      .then(() => addWindow(TAB2_URL))
+      .then(testNewWindow)
+      .then(testFocusFirst)
+      .then(testRemoveTab)
+      .then(closeConnection)
+      .then(finish)
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
   });
 }
 
-function test_open_window()
-{
-  gSecondWindow = window.open(TAB2_URL, "secondWindow");
-  ok(!!gSecondWindow, "Second window created.");
-  gSecondWindow.focus();
-  let top = windowMediator.getMostRecentWindow("navigator:browser");
-  var main2 = gSecondWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-                   .getInterface(Components.interfaces.nsIWebNavigation)
-                   .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
-                   .rootTreeItem
-                   .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-                   .getInterface(Components.interfaces.nsIDOMWindow);
-  is(top, main2, "The second window is on top.");
-  let gotLoad = false;
-  let gotActivate = (Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager).activeWindow == main2);
-  function maybeWindowLoadedAndActive() {
-    if (gotLoad && gotActivate) {
-      top.BrowserChromeTest.runWhenReady(function() {
-        executeSoon(function() {
-          gClient.listTabs(function(aResponse) {
-            is(aResponse.selected, 2, "Tab2 is selected.");
-            test_focus_first();
-          });
-        });
-      })
-    }
-  }
+function testFirstTab(aTab) {
+  let deferred = promise.defer();
+
+  gNewTab = aTab;
+  ok(!!gNewTab, "Second tab created.");
+
+  gClient.listTabs(aResponse => {
+    let tabActor = aResponse.tabs.filter(aGrip => aGrip.url == TAB1_URL).pop();
+    ok(tabActor,
+      "Should find a tab actor for the first tab.");
+
+    is(aResponse.selected, 1,
+      "The first tab is selected.");
+
+    deferred.resolve();
+  });
+
+  return deferred.promise;
+}
+
+function testNewWindow(aWindow) {
+  let deferred = promise.defer();
 
-  if (!gotActivate) {
-    main2.addEventListener("activate", function() {
-        main2.removeEventListener("activate", arguments.callee, true);
-        gotActivate = true;
-        maybeWindowLoadedAndActive();
-      },
-      true
-    );
-  }
-  main2.document.addEventListener("load", function(e) {
-      if (e.target.documentURI != TAB2_URL) {
+  gNewWindow = aWindow;
+  ok(!!gNewWindow, "Second window created.");
+
+  gNewWindow.focus();
+
+  let topWindow = Services.wm.getMostRecentWindow("navigator:browser");
+  is(topWindow, gNewWindow,
+    "The second window is on top.");
+
+  let isActive = promise.defer();
+  let isLoaded = promise.defer();
+
+  promise.all([isActive.promise, isLoaded.promise]).then(() => {
+    gNewWindow.BrowserChromeTest.runWhenReady(() => {
+      gClient.listTabs(aResponse => {
+        is(aResponse.selected, 2,
+          "The second tab is selected.");
+
+        deferred.resolve();
+      });
+    });
+  });
+
+  let focusManager = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
+  if (focusManager.activeWindow != gNewWindow) {
+    gNewWindow.addEventListener("activate", function onActivate(aEvent) {
+      if (aEvent.target != gNewWindow) {
         return;
       }
-      main2.document.removeEventListener("load", arguments.callee, true);
-      gotLoad = true;
-      maybeWindowLoadedAndActive();
-    },
-    true
-  );
+      gNewWindow.removeEventListener("activate", onActivate, true);
+      isActive.resolve();
+    }, true);
+  } else {
+    isActive.resolve();
+  }
+
+  let contentLocation = gNewWindow.content.location.href;
+  if (contentLocation != TAB2_URL) {
+    gNewWindow.document.addEventListener("load", function onLoad(aEvent) {
+      if (aEvent.target.documentURI != TAB2_URL) {
+        return;
+      }
+      gNewWindow.document.removeEventListener("load", onLoad, true);
+      isLoaded.resolve();
+    }, true);
+  } else {
+    isLoaded.resolve();
+  }
+
+  return deferred.promise;
 }
 
-function test_focus_first()
-{
-  window.content.addEventListener("focus", function onFocus() {
-    window.content.removeEventListener("focus", onFocus, false);
-    let top = windowMediator.getMostRecentWindow("navigator:browser");
-    var main1 = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-                     .getInterface(Components.interfaces.nsIWebNavigation)
-                     .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
-                     .rootTreeItem
-                     .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
-                     .getInterface(Components.interfaces.nsIDOMWindow);
-    is(top, main1, "The first window is on top.");
+function testFocusFirst() {
+  let deferred = promise.defer();
+
+  once(window.content, "focus").then(() => {
+    let topWindow = Services.wm.getMostRecentWindow("navigator:browser");
+    is(top, getDOMWindow(window),
+      "The first window is on top.");
 
-    gClient.listTabs(function(aResponse) {
-      is(aResponse.selected, 1, "Tab1 is selected after focusing on it.");
+    gClient.listTabs(aResponse => {
+      is(aResponse.selected, 1,
+        "The first tab is selected after focusing on it.");
 
-      test_remove_tab();
+      deferred.resolve();
     });
-  }, false);
+  });
+
   window.content.focus();
+
+  return deferred.promise;
 }
 
-function test_remove_tab()
-{
-  gSecondWindow.close();
-  gSecondWindow = null;
-  removeTab(gTab1);
-  gTab1 = null;
-  gClient.listTabs(function(aResponse) {
+function testRemoveTab() {
+  gNewWindow.close();
+  removeTab(gNewTab);
+
+  gClient.listTabs(aResponse => {
     // Verify that tabs are no longer included in listTabs.
-    let foundTab1 = false;
-    let foundTab2 = false;
-    for (let tab of aResponse.tabs) {
-      if (tab.url == TAB1_URL) {
-        foundTab1 = true;
-      } else if (tab.url == TAB2_URL) {
-        foundTab2 = true;
-      }
-    }
+    let foundTab1 = aResponse.tabs.some(aGrip => aGrip.url == TAB1_URL);
+    let foundTab2 = aResponse.tabs.some(aGrip => aGrip.url == TAB2_URL);
     ok(!foundTab1, "Tab1 should be gone.");
     ok(!foundTab2, "Tab2 should be gone.");
-    is(aResponse.selected, 0, "The original tab is selected.");
-    finish_test();
+
+    is(aResponse.selected, 0,
+      "The original tab is selected.");
   });
 }
 
-function finish_test()
-{
-  gClient.close(function() {
-    finish();
-  });
+function closeConnection() {
+  let deferred = promise.defer();
+  gClient.close(deferred.resolve);
+  return deferred.promise;
 }
+
+registerCleanupFunction(function() {
+  gNewTab = null;
+  gNewWindow = null;
+  gClient = null;
+});
rename from browser/devtools/debugger/test/browser_dbg_nav-01.js
rename to browser/devtools/debugger/test/browser_dbg_navigation.js
--- a/browser/devtools/debugger/test/browser_dbg_nav-01.js
+++ b/browser/devtools/debugger/test/browser_dbg_navigation.js
@@ -1,54 +1,71 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Check tab attach/navigation.
  */
 
-var gTab1 = null;
-var gTab1Actor = null;
+const TAB1_URL = EXAMPLE_URL + "doc_empty-tab-01.html";
+const TAB2_URL = EXAMPLE_URL + "doc_empty-tab-02.html";
+
+let gClient;
 
-var gClient = null;
+function test() {
+  if (!DebuggerServer.initialized) {
+    DebuggerServer.init(() => true);
+    DebuggerServer.addBrowserActors();
+  }
 
-function test()
-{
   let transport = DebuggerServer.connectPipe();
   gClient = new DebuggerClient(transport);
-  gClient.connect(function(aType, aTraits) {
-    is(aType, "browser", "Root actor should identify itself as a browser.");
-    get_tab();
+  gClient.connect((aType, aTraits) => {
+    is(aType, "browser",
+      "Root actor should identify itself as a browser.");
+
+    addTab(TAB1_URL)
+      .then(() => attachTabActorForUrl(gClient, TAB1_URL))
+      .then(testNavigate)
+      .then(testDetach)
+      .then(finish)
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
   });
 }
 
-function get_tab()
-{
-  gTab1 = addTab(TAB1_URL, function() {
-    get_tab_actor_for_url(gClient, TAB1_URL, function(aGrip) {
-      gTab1Actor = aGrip.actor;
-      gClient.request({ to: aGrip.actor, type: "attach" }, function(aResponse) {
-        gClient.addListener("tabNavigated", function onTabNavigated(aEvent, aPacket) {
-          dump("onTabNavigated state " + aPacket.state + "\n");
-          if (aPacket.state == "start") {
-            return;
-          }
-          gClient.removeListener("tabNavigated", onTabNavigated);
+function testNavigate() {
+  let outstanding = [promise.defer(), promise.defer()];
+
+  gClient.addListener("tabNavigated", function onTabNavigated(aEvent, aPacket) {
+    is(aPacket.url, TAB2_URL,
+      "Got a tab navigation notification.");
 
-          is(aPacket.url, TAB2_URL, "Got a tab navigation notification.");
-          gClient.addOneTimeListener("tabDetached", function (aEvent, aPacket) {
-            ok(true, "Got a tab detach notification.");
-            finish_test();
-          });
-          removeTab(gTab1);
-        });
-        gTab1.linkedBrowser.loadURI(TAB2_URL);
-      });
-    });
+    if (aPacket.state == "start") {
+      ok(true, "Tab started to navigate.");
+      outstanding[0].resolve();
+    } else {
+      ok(true, "Tab finished navigating.");
+      gClient.removeListener("tabNavigated", onTabNavigated);
+      outstanding[1].resolve();
+    }
   });
+
+  gBrowser.selectedTab.linkedBrowser.loadURI(TAB2_URL);
+  return promise.all(outstanding.map(e => e.promise));
 }
 
-function finish_test()
-{
-  gClient.close(function() {
-    finish();
+function testDetach() {
+  let deferred = promise.defer();
+
+  gClient.addOneTimeListener("tabDetached", () => {
+    ok(true, "Got a tab detach notification.");
+    gClient.close(deferred.resolve);
   });
+
+  removeTab(gBrowser.selectedTab);
+  return deferred.promise;
 }
+
+registerCleanupFunction(function() {
+  gClient = null;
+});
rename from browser/devtools/debugger/test/browser_dbg_bug868163_highight_on_pause.js
rename to browser/devtools/debugger/test/browser_dbg_on-pause-highlight.js
--- a/browser/devtools/debugger/test/browser_dbg_bug868163_highight_on_pause.js
+++ b/browser/devtools/debugger/test/browser_dbg_on-pause-highlight.js
@@ -1,78 +1,75 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that debugger's tab is highlighted when it is paused and not the
+ * currently selected tool.
  */
 
-// Tests that debugger's tab is highlighted when it is paused and not the
-// currently selected tool.
+const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
 
-var gTab = null;
-var gDebugger = null;
-var gToolbox = null;
-var gToolboxTab = null;
+let gTab, gDebuggee, gPanel, gDebugger;
+let gToolbox, gToolboxTab;
 
 function test() {
-  debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
-    gDebugger = aPane.panelWin;
-    gToolbox = aPane._toolbox;
+    gDebuggee = aDebuggee;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gToolbox = gPanel._toolbox;
     gToolboxTab = gToolbox.doc.getElementById("toolbox-tab-jsdebugger");
-    testPause();
+
+    waitForSourceShown(gPanel, ".html").then(testPause);
   });
 }
 
 function testPause() {
-  is(gDebugger.DebuggerController.activeThread.paused, false,
-    "Should be running after debug_tab_pane.");
-
-  gDebugger.DebuggerController.activeThread.addOneTimeListener("paused", function() {
-    Services.tm.currentThread.dispatch({ run: function() {
+  is(gDebugger.gThreadClient.paused, false,
+    "Should be running after starting test.");
 
-      gToolbox.selectTool("webconsole").then(() => {
-        ok(gToolboxTab.classList.contains("highlighted"),
-           "The highlighted class is present");
-        ok(!gToolboxTab.hasAttribute("selected") ||
-           gToolboxTab.getAttribute("selected") != "true",
-           "The tab is not selected");
-      }).then(() => gToolbox.selectTool("jsdebugger")).then(() => {
-        ok(gToolboxTab.classList.contains("highlighted"),
-           "The highlighted class is present");
-        ok(gToolboxTab.hasAttribute("selected") &&
-           gToolboxTab.getAttribute("selected") == "true",
-           "and the tab is selected, so the orange glow will not be present.");
-      }).then(testResume);
-    }}, 0);
+  gDebugger.gThreadClient.addOneTimeListener("paused", () => {
+    gToolbox.selectTool("webconsole").then(() => {
+      ok(gToolboxTab.classList.contains("highlighted"),
+        "The highlighted class is present");
+      ok(!gToolboxTab.hasAttribute("selected") ||
+          gToolboxTab.getAttribute("selected") != "true",
+        "The tab is not selected");
+    }).then(() => gToolbox.selectTool("jsdebugger")).then(() => {
+      ok(gToolboxTab.classList.contains("highlighted"),
+        "The highlighted class is present");
+      ok(gToolboxTab.hasAttribute("selected") &&
+         gToolboxTab.getAttribute("selected") == "true",
+        "...and the tab is selected, so the glow will not be present.");
+    }).then(testResume);
   });
 
   EventUtils.sendMouseEvent({ type: "mousedown" },
     gDebugger.document.getElementById("resume"),
     gDebugger);
 }
 
 function testResume() {
-  gDebugger.DebuggerController.activeThread.addOneTimeListener("resumed", function() {
-    Services.tm.currentThread.dispatch({ run: function() {
-
-      gToolbox.selectTool("webconsole").then(() => {
-        ok(!gToolboxTab.classList.contains("highlighted"),
-           "The highlighted class is not present now after the resume");
-        ok(!gToolboxTab.hasAttribute("selected") ||
-           gToolboxTab.getAttribute("selected") != "true",
-           "The tab is not selected");
-      }).then(closeDebuggerAndFinish);
-    }}, 0);
+  gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
+    gToolbox.selectTool("webconsole").then(() => {
+      ok(!gToolboxTab.classList.contains("highlighted"),
+        "The highlighted class is not present now after the resume");
+      ok(!gToolboxTab.hasAttribute("selected") ||
+          gToolboxTab.getAttribute("selected") != "true",
+        "The tab is not selected");
+    }).then(() => closeDebuggerAndFinish(gPanel));
   });
 
   EventUtils.sendMouseEvent({ type: "mousedown" },
     gDebugger.document.getElementById("resume"),
     gDebugger);
 }
 
 registerCleanupFunction(function() {
-  removeTab(gTab);
   gTab = null;
+  gDebuggee = null;
+  gPanel = null;
   gDebugger = null;
   gToolbox = null;
   gToolboxTab = null;
 });
rename from browser/devtools/debugger/test/browser_dbg_bug883220_raise_on_pause.js
rename to browser/devtools/debugger/test/browser_dbg_on-pause-raise.js
--- a/browser/devtools/debugger/test/browser_dbg_bug883220_raise_on_pause.js
+++ b/browser/devtools/debugger/test/browser_dbg_on-pause-raise.js
@@ -1,134 +1,141 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that the toolbox is raised when the debugger gets paused.
  */
 
-// Tests that debugger's tab is highlighted when it is paused and not the
-// currently selected tool.
+const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
 
-var gTab = null;
-var gTab2 = null;
-var gDebugger = null;
-var gToolbox = null;
-var gToolboxTab = null;
-var gFocusedWindow = null;
-promise._reportErrors = true;
+let gTab, gDebuggee, gPanel, gDebugger;
+let gNewTab, gFocusedWindow, gToolbox, gToolboxTab;
 
 function test() {
-  debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
-    gDebugger = aPane.panelWin;
-    gToolbox = aPane._toolbox;
+    gDebuggee = aDebuggee;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gToolbox = gPanel._toolbox;
     gToolboxTab = gToolbox.doc.getElementById("toolbox-tab-jsdebugger");
-    gBrowser.selectedTab = gTab2 = gBrowser.addTab();
-    executeSoon(function() {
-      is(gBrowser.selectedTab, gTab2, "Debugger's tab is not the selected tab.");
-      gFocusedWindow = window;
-      testPause();
-    });
+
+    waitForSourceShown(gPanel, ".html").then(performTest);
+  });
+}
+
+function performTest() {
+  addTab(TAB_URL).then(aTab => {
+    isnot(aTab, gTab,
+      "The newly added tab is different from the debugger's tab.");
+    is(gBrowser.selectedTab, aTab,
+      "Debugger's tab is not the selected tab.");
+
+    gNewTab = aTab;
+    gFocusedWindow = window;
+    testPause();
   });
 }
 
 function focusMainWindow() {
   // Make sure toolbox is not focused.
   window.addEventListener("focus", onFocus, true);
+  info("Focusing main window.")
 
-  // execute soon to avoid any race conditions between toolbox and main window
+  // Execute soon to avoid any race conditions between toolbox and main window
   // getting focused.
   executeSoon(() => {
     window.focus();
   });
 }
 
 function onFocus() {
   window.removeEventListener("focus", onFocus, true);
-  info("main window focused.")
+  info("Main window focused.")
+
   gFocusedWindow = window;
   testPause();
 }
 
 function testPause() {
-  is(gDebugger.DebuggerController.activeThread.paused, false,
-    "Should be running after debug_tab_pane.");
+  is(gDebugger.gThreadClient.paused, false,
+    "Should be running after starting the test.");
 
-  is(gFocusedWindow, window, "Main window is the top level window before pause");
+  is(gFocusedWindow, window,
+    "Main window is the top level window before pause.");
 
   if (gToolbox.hostType == devtools.Toolbox.HostType.WINDOW) {
     gToolbox._host._window.onfocus = () => {
       gFocusedWindow = gToolbox._host._window;
     };
   }
 
-  gDebugger.DebuggerController.activeThread.addOneTimeListener("paused", function() {
-    Services.tm.currentThread.dispatch({ run: function() {
-
-      if (gToolbox.hostType == devtools.Toolbox.HostType.WINDOW) {
-        is(gFocusedWindow, gToolbox._host._window,
-           "Toolbox window is the top level window on pause.");
-      }
-      else {
-        is(gBrowser.selectedTab, gTab, "Debugger's tab got selected.");
-      }
-      gToolbox.selectTool("webconsole").then(() => {
-        ok(gToolboxTab.classList.contains("highlighted"),
-           "The highlighted class is present");
-        ok(!gToolboxTab.hasAttribute("selected") ||
-           gToolboxTab.getAttribute("selected") != "true",
-           "The tab is not selected");
-      }).then(() => gToolbox.selectTool("jsdebugger")).then(() => {
-        ok(gToolboxTab.classList.contains("highlighted"),
-           "The highlighted class is present");
-        ok(gToolboxTab.hasAttribute("selected") &&
-           gToolboxTab.getAttribute("selected") == "true",
-           "and the tab is selected, so the orange glow will not be present.");
-      }).then(testResume);
-    }}, 0);
+  gDebugger.gThreadClient.addOneTimeListener("paused", () => {
+    if (gToolbox.hostType == devtools.Toolbox.HostType.WINDOW) {
+      is(gFocusedWindow, gToolbox._host._window,
+         "Toolbox window is the top level window on pause.");
+    } else {
+      is(gBrowser.selectedTab, gTab,
+        "Debugger's tab got selected.");
+    }
+    gToolbox.selectTool("webconsole").then(() => {
+      ok(gToolboxTab.classList.contains("highlighted"),
+        "The highlighted class is present");
+      ok(!gToolboxTab.hasAttribute("selected") ||
+          gToolboxTab.getAttribute("selected") != "true",
+        "The tab is not selected");
+    }).then(() => gToolbox.selectTool("jsdebugger")).then(() => {
+      ok(gToolboxTab.classList.contains("highlighted"),
+        "The highlighted class is present");
+      ok(gToolboxTab.hasAttribute("selected") &&
+         gToolboxTab.getAttribute("selected") == "true",
+        "...and the tab is selected, so the glow will not be present.");
+    }).then(testResume);
   });
 
   EventUtils.sendMouseEvent({ type: "mousedown" },
     gDebugger.document.getElementById("resume"),
     gDebugger);
 }
 
 function testResume() {
-  gDebugger.DebuggerController.activeThread.addOneTimeListener("resumed", function() {
-    Services.tm.currentThread.dispatch({ run: function() {
-
-      gToolbox.selectTool("webconsole").then(() => {
-        ok(!gToolboxTab.classList.contains("highlighted"),
-           "The highlighted class is not present now after the resume");
-        ok(!gToolboxTab.hasAttribute("selected") ||
-           gToolboxTab.getAttribute("selected") != "true",
-           "The tab is not selected");
-      }).then(maybeEndTest);
-    }}, 0);
+  gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
+    gToolbox.selectTool("webconsole").then(() => {
+      ok(!gToolboxTab.classList.contains("highlighted"),
+        "The highlighted class is not present now after the resume");
+      ok(!gToolboxTab.hasAttribute("selected") ||
+          gToolboxTab.getAttribute("selected") != "true",
+        "The tab is not selected");
+    }).then(maybeEndTest);
   });
 
   EventUtils.sendMouseEvent({ type: "mousedown" },
     gDebugger.document.getElementById("resume"),
     gDebugger);
 }
 
 function maybeEndTest() {
-  if (gToolbox.hostType == devtools.Toolbox.HostType.WINDOW) {
-    gToolbox.switchHost(devtools.Toolbox.HostType.BOTTOM)
-            .then(closeDebuggerAndFinish);
-  }
-  else {
-    info("switching to toolbox window.")
-    gToolbox.switchHost(devtools.Toolbox.HostType.WINDOW).then(focusMainWindow).then(null, console.error);
+  if (gToolbox.hostType == devtools.Toolbox.HostType.BOTTOM) {
+    info("Switching to a toolbox window host.");
+    gToolbox.switchHost(devtools.Toolbox.HostType.WINDOW).then(focusMainWindow);
+  } else {
+    info("Switching to main window host.");
+    gToolbox.switchHost(devtools.Toolbox.HostType.BOTTOM).then(() => closeDebuggerAndFinish(gPanel));
   }
 }
 
 registerCleanupFunction(function() {
+  // Revert to the default toolbox host, so that the following tests proceed
+  // normally and not inside a non-default host.
   Services.prefs.setCharPref("devtools.toolbox.host", devtools.Toolbox.HostType.BOTTOM);
-  removeTab(gTab);
-  removeTab(gTab2);
+
   gTab = null;
-  gTab2 = null;
+  gDebuggee = null;
+  gPanel = null;
   gDebugger = null;
+
+  removeTab(gNewTab);
+  gNewTab = null;
+  gFocusedWindow = null;
   gToolbox = null;
   gToolboxTab = null;
-  gFocusedWindow = null;
 });
rename from browser/devtools/debugger/test/browser_dbg_panesize-inner.js
rename to browser/devtools/debugger/test/browser_dbg_panel-size.js
--- a/browser/devtools/debugger/test/browser_dbg_panesize-inner.js
+++ b/browser/devtools/debugger/test/browser_dbg_panel-size.js
@@ -1,77 +1,83 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Test that the sources and instruments panels widths are properly
+ * remembered when the debugger closes.
  */
 
+const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
+
 function test() {
-  var tab1 = addTab(TAB1_URL, function() {
-    gBrowser.selectedTab = tab1;
-    let target1 = TargetFactory.forTab(tab1);
-
-    ok(!gDevTools.getToolbox(target1),
-      "Shouldn't have a debugger panel for this tab yet.");
+  let gTab, gDebuggee, gPanel, gDebugger;
+  let gPrefs, gSources, gInstruments;
 
-    gDevTools.showToolbox(target1, "jsdebugger").then(function(toolbox) {
-      let dbg = toolbox.getCurrentPanel();
-      ok(dbg, "We should have a debugger panel.");
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
+    gTab = aTab;
+    gDebuggee = aDebuggee;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gPrefs = gDebugger.Prefs;
+    gSources = gDebugger.document.getElementById("sources-pane");
+    gInstruments = gDebugger.document.getElementById("instruments-pane");
 
-      let preferredSw = Services.prefs.getIntPref("devtools.debugger.ui.panes-sources-width");
-      let preferredIw = Services.prefs.getIntPref("devtools.debugger.ui.panes-instruments-width");
-      let someWidth1, someWidth2;
+    waitForSourceShown(gPanel, ".html").then(performTest);
+  });
 
-      do {
-        someWidth1 = parseInt(Math.random() * 200) + 100;
-        someWidth2 = parseInt(Math.random() * 200) + 100;
-      } while (someWidth1 == preferredSw ||
-               someWidth2 == preferredIw)
+  function performTest() {
+    let preferredSw = Services.prefs.getIntPref("devtools.debugger.ui.panes-sources-width");
+    let preferredIw = Services.prefs.getIntPref("devtools.debugger.ui.panes-instruments-width");
+    let someWidth1, someWidth2;
 
-      let someWidth1 = parseInt(Math.random() * 200) + 100;
-      let someWidth2 = parseInt(Math.random() * 200) + 100;
+    do {
+      someWidth1 = parseInt(Math.random() * 200) + 100;
+      someWidth2 = parseInt(Math.random() * 300) + 100;
+    } while ((someWidth1 == preferredSw) || (someWidth2 == preferredIw));
 
-      info("Preferred sources width: " + preferredSw);
-      info("Preferred instruments width: " + preferredIw);
-      info("Generated sources width: " + someWidth1);
-      info("Generated instruments width: " + someWidth2);
+    info("Preferred sources width: " + preferredSw);
+    info("Preferred instruments width: " + preferredIw);
+    info("Generated sources width: " + someWidth1);
+    info("Generated instruments width: " + someWidth2);
 
-      let content = dbg.panelWin;
-      let sources;
-      let instruments;
+    ok(gPrefs.sourcesWidth,
+      "The debugger preferences should have a saved sourcesWidth value.");
+    ok(gPrefs.instrumentsWidth,
+      "The debugger preferences should have a saved instrumentsWidth value.");
 
-      wait_for_connect_and_resume(function() {
-        ok(content.Prefs.sourcesWidth,
-          "The debugger preferences should have a saved sourcesWidth value.");
-        ok(content.Prefs.instrumentsWidth,
-          "The debugger preferences should have a saved instrumentsWidth value.");
+    is(gPrefs.sourcesWidth, preferredSw,
+      "The debugger preferences should have a correct sourcesWidth value.");
+    is(gPrefs.instrumentsWidth, preferredIw,
+      "The debugger preferences should have a correct instrumentsWidth value.");
 
-        sources = content.document.getElementById("sources-pane");
-        instruments = content.document.getElementById("instruments-pane");
+    is(gSources.getAttribute("width"), gPrefs.sourcesWidth,
+      "The sources pane width should be the same as the preferred value.");
+    is(gInstruments.getAttribute("width"), gPrefs.instrumentsWidth,
+      "The instruments pane width should be the same as the preferred value.");
 
-        is(content.Prefs.sourcesWidth, sources.getAttribute("width"),
-          "The sources pane width should be the same as the preferred value.");
-        is(content.Prefs.instrumentsWidth, instruments.getAttribute("width"),
-          "The instruments pane width should be the same as the preferred value.");
+    gSources.setAttribute("width", someWidth1);
+    gInstruments.setAttribute("width", someWidth2);
 
-        sources.setAttribute("width", someWidth1);
-        instruments.setAttribute("width", someWidth2);
+    is(gPrefs.sourcesWidth, preferredSw,
+      "The sources pane width pref should still be the same as the preferred value.");
+    is(gPrefs.instrumentsWidth, preferredIw,
+      "The instruments pane width pref should still be the same as the preferred value.");
 
-        removeTab(tab1);
-      }, tab1);
-
-      window.addEventListener("Debugger:Shutdown", function dbgShutdown() {
-        window.removeEventListener("Debugger:Shutdown", dbgShutdown, true);
+    isnot(gSources.getAttribute("width"), gPrefs.sourcesWidth,
+      "The sources pane width should not be the preferred value anymore.");
+    isnot(gInstruments.getAttribute("width"), gPrefs.instrumentsWidth,
+      "The instruments pane width should not be the preferred value anymore.");
 
-        is(content.Prefs.sourcesWidth, sources.getAttribute("width"),
-          "The sources pane width should have been saved by now.");
-        is(content.Prefs.instrumentsWidth, instruments.getAttribute("width"),
-          "The instruments pane width should have been saved by now.");
+    teardown(gPanel).then(() => {
+      is(gPrefs.sourcesWidth, someWidth1,
+        "The sources pane width should have been saved by now.");
+      is(gPrefs.instrumentsWidth, someWidth2,
+        "The instruments pane width should have been saved by now.");
 
-        // Cleanup after ourselves!
-        Services.prefs.setIntPref("devtools.debugger.ui.panes-sources-width", preferredSw);
-        Services.prefs.setIntPref("devtools.debugger.ui.panes-instruments-width", preferredIw);
+      // Cleanup after ourselves!
+      Services.prefs.setIntPref("devtools.debugger.ui.panes-sources-width", preferredSw);
+      Services.prefs.setIntPref("devtools.debugger.ui.panes-instruments-width", preferredIw);
 
-        finish();
-      }, true);
+      finish();
     });
-  });
+  }
 }
rename from browser/devtools/debugger/test/browser_dbg_pause-exceptions.js
rename to browser/devtools/debugger/test/browser_dbg_pause-exceptions-01.js
--- a/browser/devtools/debugger/test/browser_dbg_pause-exceptions.js
+++ b/browser/devtools/debugger/test/browser_dbg_pause-exceptions-01.js
@@ -1,142 +1,245 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
- * Make sure that the pause-on-exceptions toggle works.
+ * Make sure that pausing on exceptions works.
  */
 
-const TAB_URL = EXAMPLE_URL + "browser_dbg_pause-exceptions.html";
+const TAB_URL = EXAMPLE_URL + "doc_pause-exceptions.html";
+
+let gTab, gDebuggee, gPanel, gDebugger;
+let gFrames, gVariables, gPrefs, gOptions;
 
-var gPane = null;
-var gTab = null;
-var gDebugger = null;
-var gPrevPref = null;
-
-requestLongerTimeout(2);
+function test() {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
+    gTab = aTab;
+    gDebuggee = aDebuggee;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gFrames = gDebugger.DebuggerView.StackFrames;
+    gVariables = gDebugger.DebuggerView.Variables;
+    gPrefs = gDebugger.Prefs;
+    gOptions = gDebugger.DebuggerView.Options;
 
-function test()
-{
-  gPrevPref = Services.prefs.getBoolPref(
-    "devtools.debugger.pause-on-exceptions");
-  Services.prefs.setBoolPref(
-    "devtools.debugger.pause-on-exceptions", true);
+    is(gPrefs.pauseOnExceptions, false,
+      "The pause-on-exceptions pref should be disabled by default.");
+    isnot(gOptions._pauseOnExceptionsItem.getAttribute("checked"), "true",
+      "The pause-on-exceptions menu item should not be checked.");
 
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
-    gTab = aTab;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
-
-    gDebugger.DebuggerController.StackFrames.autoScopeExpand = true;
-    gDebugger.DebuggerView.Variables.nonEnumVisible = false;
-    testWithFrame();
+    testPauseOnExceptionsDisabled()
+      .then(enablePauseOnExceptions)
+      .then(disableIgnoreCaughtExceptions)
+      .then(testPauseOnExceptionsEnabled)
+      .then(disablePauseOnExceptions)
+      .then(enableIgnoreCaughtExceptions)
+      .then(() => closeDebuggerAndFinish(gPanel))
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
   });
 }
 
-function testWithFrame()
-{
-  let count = 0;
-  gPane.panelWin.gClient.addOneTimeListener("paused", function() {
-    gDebugger.addEventListener("Debugger:FetchedVariables", function testA() {
-      // We expect 2 Debugger:FetchedVariables events, one from the global object
-      // scope and the regular one.
-      if (++count < 2) {
-        is(count, 1, "A. First Debugger:FetchedVariables event received.");
-        return;
-      }
-      is(count, 2, "A. Second Debugger:FetchedVariables event received.");
-      gDebugger.removeEventListener("Debugger:FetchedVariables", testA, false);
+function testPauseOnExceptionsDisabled() {
+  let finished = waitForCaretAndScopes(gPanel, 26).then(() => {
+    info("Testing disabled pause-on-exceptions.");
+
+    is(gDebugger.gThreadClient.state, "paused",
+      "Should only be getting stack frames while paused (1).");
+    ok(isCaretPos(gPanel, 26),
+      "Should be paused on the debugger statement (1).");
+
+    let innerScope = gVariables.getScopeAtIndex(0);
+    let innerNodes = innerScope.target.querySelector(".variables-view-element-details").childNodes;
+
+    is(gFrames.itemCount, 1,
+      "Should have one frame.");
+    is(gVariables._store.length, 3,
+      "Should have three scopes.");
+
+    is(innerNodes[0].querySelector(".name").getAttribute("value"), "this",
+      "Should have the right property name for 'this'.");
+    is(innerNodes[0].querySelector(".value").getAttribute("value"), "HTMLButtonElement",
+      "Should have the right property value for 'this'.");
 
-      is(gDebugger.DebuggerController.activeThread.state, "paused",
-        "Should be paused now.");
+    let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.AFTER_FRAMES_CLEARED).then(() => {
+      isnot(gDebugger.gThreadClient.state, "paused",
+        "Should not be paused after resuming.");
+      ok(isCaretPos(gPanel, 26),
+        "Should be idle on the debugger statement.");
+
+      ok(true, "Frames were cleared, debugger didn't pause again.");
+    });
 
-      // Pause on exceptions should be already enabled.
-      is(gPrevPref, false,
-        "The pause-on-exceptions functionality should be disabled by default.");
-      is(gDebugger.Prefs.pauseOnExceptions, true,
-        "The pause-on-exceptions pref should be true from startup.");
-      is(gDebugger.DebuggerView.Options._pauseOnExceptionsItem.getAttribute("checked"), "true",
-        "Pause on exceptions should be enabled from startup. ")
+    EventUtils.sendMouseEvent({ type: "mousedown" },
+      gDebugger.document.getElementById("resume"),
+      gDebugger);
+
+    return finished;
+  });
 
-      // Disable ignore caught exceptions
-      gDebugger.DebuggerView.Options._ignoreCaughtExceptionsItem.setAttribute("checked", "false");
-      gDebugger.DebuggerView.Options._toggleIgnoreCaughtExceptions();
+  EventUtils.sendMouseEvent({ type: "click" },
+    gDebuggee.document.querySelector("button"),
+    gDebuggee);
+
+  return finished;
+}
 
-      count = 0;
-      gPane.panelWin.gClient.addOneTimeListener("resumed", function() {
-        gDebugger.addEventListener("Debugger:FetchedVariables", function testB() {
-          // We expect 2 Debugger:FetchedVariables events, one from the global object
-          // scope and the regular one.
-          if (++count < 2) {
-            is(count, 1, "B. First Debugger:FetchedVariables event received.");
-            return;
-          }
-          is(count, 2, "B. Second Debugger:FetchedVariables event received.");
-          gDebugger.removeEventListener("Debugger:FetchedVariables", testB, false);
-          Services.tm.currentThread.dispatch({ run: function() {
+function testPauseOnExceptionsEnabled() {
+  let finished = waitForCaretAndScopes(gPanel, 19).then(() => {
+    info("Testing enabled pause-on-exceptions.");
+
+    is(gDebugger.gThreadClient.state, "paused",
+      "Should only be getting stack frames while paused.");
+    ok(isCaretPos(gPanel, 19),
+      "Should be paused on the debugger statement.");
+
+    let innerScope = gVariables.getScopeAtIndex(0);
+    let innerNodes = innerScope.target.querySelector(".variables-view-element-details").childNodes;
 
-            var frames = gDebugger.DebuggerView.StackFrames.widget._list,
-                scopes = gDebugger.DebuggerView.Variables._list,
-                innerScope = scopes.firstChild,
-                innerNodes = innerScope.querySelector(".variables-view-element-details").childNodes;
+    is(gFrames.itemCount, 1,
+      "Should have one frame.");
+    is(gVariables._store.length, 3,
+      "Should have three scopes.");
 
-            is(gDebugger.DebuggerController.activeThread.state, "paused",
-              "Should only be getting stack frames while paused.");
+    is(innerNodes[0].querySelector(".name").getAttribute("value"), "<exception>",
+      "Should have the right property name for <exception>.");
+    is(innerNodes[0].querySelector(".value").getAttribute("value"), "Error",
+      "Should have the right property value for <exception>.");
+
+    let finished = waitForCaretAndScopes(gPanel, 26).then(() => {
+      info("Testing enabled pause-on-exceptions and resumed after pause.");
 
-            is(frames.querySelectorAll(".dbg-stackframe").length, 1,
-              "Should have one frame.");
-
-            is(scopes.children.length, 3, "Should have 3 variable scopes.");
+      is(gDebugger.gThreadClient.state, "paused",
+        "Should only be getting stack frames while paused.");
+      ok(isCaretPos(gPanel, 26),
+        "Should be paused on the debugger statement.");
 
-            is(innerNodes[0].querySelector(".name").getAttribute("value"), "<exception>",
-              "Should have the right property name for the exception.");
+      let innerScope = gVariables.getScopeAtIndex(0);
+      let innerNodes = innerScope.target.querySelector(".variables-view-element-details").childNodes;
 
-            is(innerNodes[0].querySelector(".value").getAttribute("value"), "Error",
-              "Should have the right property value for the exception.");
+      is(gFrames.itemCount, 1,
+        "Should have one frame.");
+      is(gVariables._store.length, 3,
+        "Should have three scopes.");
 
-            // Disable pause on exceptions.
-            gDebugger.DebuggerView.Options._pauseOnExceptionsItem.setAttribute("checked", "false");
-            gDebugger.DebuggerView.Options._togglePauseOnExceptions();
-
-            gDebugger.DebuggerView.Options._ignoreCaughtExceptionsItem.setAttribute("checked", "true");
-            gDebugger.DebuggerView.Options._toggleIgnoreCaughtExceptions();
+      is(innerNodes[0].querySelector(".name").getAttribute("value"), "this",
+        "Should have the right property name for 'this'.");
+      is(innerNodes[0].querySelector(".value").getAttribute("value"), "HTMLButtonElement",
+        "Should have the right property value for 'this'.");
 
-            is(gDebugger.Prefs.pauseOnExceptions, false,
-              "The pause-on-exceptions pref should have been set to false.");
+      let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.AFTER_FRAMES_CLEARED).then(() => {
+        isnot(gDebugger.gThreadClient.state, "paused",
+          "Should not be paused after resuming.");
+        ok(isCaretPos(gPanel, 26),
+          "Should be idle on the debugger statement.");
 
-            resumeAndFinish();
-
-          }}, 0);
-        }, false);
+        ok(true, "Frames were cleared, debugger didn't pause again.");
       });
 
       EventUtils.sendMouseEvent({ type: "mousedown" },
         gDebugger.document.getElementById("resume"),
         gDebugger);
-    }, false);
+
+      return finished;
+    });
+
+    EventUtils.sendMouseEvent({ type: "mousedown" },
+      gDebugger.document.getElementById("resume"),
+      gDebugger);
+
+    return finished;
   });
 
   EventUtils.sendMouseEvent({ type: "click" },
-    content.document.querySelector("button"),
-    content.window);
+    gDebuggee.document.querySelector("button"),
+    gDebuggee);
+
+  return finished;
+}
+
+function enablePauseOnExceptions() {
+  let deferred = promise.defer();
+
+  gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
+    is(gPrefs.pauseOnExceptions, true,
+      "The pause-on-exceptions pref should now be enabled.");
+    is(gOptions._pauseOnExceptionsItem.getAttribute("checked"), "true",
+      "The pause-on-exceptions menu item should now be checked.");
+
+    ok(true, "Pausing on exceptions was enabled.");
+    deferred.resolve();
+  });
+
+  gOptions._pauseOnExceptionsItem.setAttribute("checked", "true");
+  gOptions._togglePauseOnExceptions();
+
+  return deferred.promise;
 }
 
-function resumeAndFinish() {
-  gPane.panelWin.gClient.addOneTimeListener("resumed", function() {
-    Services.tm.currentThread.dispatch({ run: function() {
+function disablePauseOnExceptions() {
+  let deferred = promise.defer();
 
-      closeDebuggerAndFinish();
+  gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
+    is(gPrefs.pauseOnExceptions, false,
+      "The pause-on-exceptions pref should now be disabled.");
+    isnot(gOptions._pauseOnExceptionsItem.getAttribute("checked"), "true",
+      "The pause-on-exceptions menu item should now be unchecked.");
 
-    }}, 0);
+    ok(true, "Pausing on exceptions was disabled.");
+    deferred.resolve();
   });
 
-  // Resume to let the exception reach it's catch clause.
-  gDebugger.DebuggerController.activeThread.resume();
+  gOptions._pauseOnExceptionsItem.setAttribute("checked", "false");
+  gOptions._togglePauseOnExceptions();
+
+  return deferred.promise;
+}
+
+function enableIgnoreCaughtExceptions() {
+  let deferred = promise.defer();
+
+  gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
+    is(gPrefs.ignoreCaughtExceptions, true,
+      "The ignore-caught-exceptions pref should now be enabled.");
+    is(gOptions._ignoreCaughtExceptionsItem.getAttribute("checked"), "true",
+      "The ignore-caught-exceptions menu item should now be checked.");
+
+    ok(true, "Ignore caught exceptions was enabled.");
+    deferred.resolve();
+  });
+
+  gOptions._ignoreCaughtExceptionsItem.setAttribute("checked", "true");
+  gOptions._toggleIgnoreCaughtExceptions();
+
+  return deferred.promise;
+}
+
+function disableIgnoreCaughtExceptions() {
+  let deferred = promise.defer();
+
+  gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
+    is(gPrefs.ignoreCaughtExceptions, false,
+      "The ignore-caught-exceptions pref should now be disabled.");
+    isnot(gOptions._ignoreCaughtExceptionsItem.getAttribute("checked"), "true",
+      "The ignore-caught-exceptions menu item should now be unchecked.");
+
+    ok(true, "Ignore caught exceptions was disabled.");
+    deferred.resolve();
+  });
+
+  gOptions._ignoreCaughtExceptionsItem.setAttribute("checked", "false");
+  gOptions._toggleIgnoreCaughtExceptions();
+
+  return deferred.promise;
 }
 
 registerCleanupFunction(function() {
-  removeTab(gTab);
-  gPane = null;
   gTab = null;
+  gDebuggee = null;
+  gPanel = null;
   gDebugger = null;
+  gFrames = null;
+  gVariables = null;
+  gPrefs = null;
+  gOptions = null;
 });
rename from browser/devtools/debugger/test/browser_dbg_pause-exceptions-reload.js
rename to browser/devtools/debugger/test/browser_dbg_pause-exceptions-02.js
--- a/browser/devtools/debugger/test/browser_dbg_pause-exceptions-reload.js
+++ b/browser/devtools/debugger/test/browser_dbg_pause-exceptions-02.js
@@ -1,130 +1,201 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Make sure that pausing on exceptions works after reload.
  */
 
-const TAB_URL = EXAMPLE_URL + "test-pause-exceptions-reload.html";
+const TAB_URL = EXAMPLE_URL + "doc_pause-exceptions.html";
+
+let gTab, gDebuggee, gPanel, gDebugger;
+let gFrames, gVariables, gPrefs, gOptions;
 
-var gPane = null;
-var gTab = null;
-var gDebugger = null;
-var gPrevPref = null;
+function test() {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
+    gTab = aTab;
+    gDebuggee = aDebuggee;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gFrames = gDebugger.DebuggerView.StackFrames;
+    gVariables = gDebugger.DebuggerView.Variables;
+    gPrefs = gDebugger.Prefs;
+    gOptions = gDebugger.DebuggerView.Options;
 
-function test()
-{
-  gPrevPref = Services.prefs.getBoolPref(
-    "devtools.debugger.pause-on-exceptions");
-  Services.prefs.setBoolPref(
-    "devtools.debugger.pause-on-exceptions", true);
+    is(gPrefs.pauseOnExceptions, false,
+      "The pause-on-exceptions pref should be disabled by default.");
+    isnot(gOptions._pauseOnExceptionsItem.getAttribute("checked"), "true",
+      "The pause-on-exceptions menu item should not be checked.");
 
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
-    gTab = aTab;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
-
-    gDebugger.DebuggerController.StackFrames.autoScopeExpand = true;
-    gDebugger.DebuggerView.Variables.nonEnumVisible = false;
-    testWithFrame();
+    enablePauseOnExceptions()
+      .then(disableIgnoreCaughtExceptions)
+      .then(() => reloadActiveTab(gPanel, gDebugger.EVENTS.SOURCE_SHOWN))
+      .then(() => ensureThreadClientState(gPanel, "resumed"))
+      .then(testPauseOnExceptionsAfterReload)
+      .then(disablePauseOnExceptions)
+      .then(enableIgnoreCaughtExceptions)
+      .then(() => closeDebuggerAndFinish(gPanel))
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
   });
 }
 
-function testWithFrame()
-{
-  // Pause on exceptions should be already enabled.
-  is(gDebugger.Prefs.pauseOnExceptions, true,
-    "The pause-on-exceptions pref should be true from startup.");
-  is(gDebugger.DebuggerView.Options._pauseOnExceptionsItem.getAttribute("checked"), "true",
-    "Pause on exceptions should be enabled from startup. ")
+function testPauseOnExceptionsAfterReload() {
+  let finished = waitForCaretAndScopes(gPanel, 19).then(() => {
+    info("Testing enabled pause-on-exceptions.");
 
-  // Disable ignore caught exceptions
-  gDebugger.DebuggerView.Options._ignoreCaughtExceptionsItem.setAttribute("checked", "false");
-  gDebugger.DebuggerView.Options._toggleIgnoreCaughtExceptions();
+    is(gDebugger.gThreadClient.state, "paused",
+      "Should only be getting stack frames while paused.");
+    ok(isCaretPos(gPanel, 19),
+      "Should be paused on the debugger statement.");
+
+    let innerScope = gVariables.getScopeAtIndex(0);
+    let innerNodes = innerScope.target.querySelector(".variables-view-element-details").childNodes;
 
-  let count = 0;
-  gPane.panelWin.gClient.addOneTimeListener("paused", function() {
-    gDebugger.addEventListener("Debugger:FetchedVariables", function testA() {
-      // We expect 2 Debugger:FetchedVariables events, one from the global object
-      // scope and the regular one.
-      if (++count < 2) {
-        is(count, 1, "A. First Debugger:FetchedVariables event received.");
-        return;
-      }
-      is(count, 2, "A. Second Debugger:FetchedVariables event received.");
-      gDebugger.removeEventListener("Debugger:FetchedVariables", testA, false);
+    is(gFrames.itemCount, 1,
+      "Should have one frame.");
+    is(gVariables._store.length, 3,
+      "Should have three scopes.");
 
-      is(gDebugger.DebuggerController.activeThread.state, "paused",
-        "Should be paused now.");
+    is(innerNodes[0].querySelector(".name").getAttribute("value"), "<exception>",
+      "Should have the right property name for <exception>.");
+    is(innerNodes[0].querySelector(".value").getAttribute("value"), "Error",
+      "Should have the right property value for <exception>.");
+
+    let finished = waitForCaretAndScopes(gPanel, 26).then(() => {
+      info("Testing enabled pause-on-exceptions and resumed after pause.");
 
-      count = 0;
-      gPane.panelWin.gClient.addOneTimeListener("paused", function() {
-        gDebugger.addEventListener("Debugger:FetchedVariables", function testB() {
-          // We expect 2 Debugger:FetchedVariables events, one from the global object
-          // scope and the regular one.
-          if (++count < 2) {
-            is(count, 1, "B. First Debugger:FetchedVariables event received.");
-            return;
-          }
-          is(count, 2, "B. Second Debugger:FetchedVariables event received.");
-          gDebugger.removeEventListener("Debugger:FetchedVariables", testB, false);
-          Services.tm.currentThread.dispatch({ run: function() {
+      is(gDebugger.gThreadClient.state, "paused",
+        "Should only be getting stack frames while paused.");
+      ok(isCaretPos(gPanel, 26),
+        "Should be paused on the debugger statement.");
 
-            var frames = gDebugger.DebuggerView.StackFrames.widget._list,
-                scopes = gDebugger.DebuggerView.Variables._list,
-                innerScope = scopes.firstChild,
-                innerNodes = innerScope.querySelector(".variables-view-element-details").childNodes;
+      let innerScope = gVariables.getScopeAtIndex(0);
+      let innerNodes = innerScope.target.querySelector(".variables-view-element-details").childNodes;
+
+      is(gFrames.itemCount, 1,
+        "Should have one frame.");
+      is(gVariables._store.length, 3,
+        "Should have three scopes.");
 
-            is(gDebugger.DebuggerController.activeThread.state, "paused",
-              "Should be paused again.");
-
-            is(frames.querySelectorAll(".dbg-stackframe").length, 2,
-              "Should have two frames.");
-
-            is(scopes.children.length, 2, "Should have 2 variable scopes.");
+      is(innerNodes[0].querySelector(".name").getAttribute("value"), "this",
+        "Should have the right property name for 'this'.");
+      is(innerNodes[0].querySelector(".value").getAttribute("value"), "HTMLButtonElement",
+        "Should have the right property value for 'this'.");
 
-            is(innerNodes[0].querySelector(".name").getAttribute("value"), "<exception>",
-              "Should have the right property name for the exception.");
+      let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.AFTER_FRAMES_CLEARED).then(() => {
+        isnot(gDebugger.gThreadClient.state, "paused",
+          "Should not be paused after resuming.");
+        ok(isCaretPos(gPanel, 26),
+          "Should be idle on the debugger statement.");
 
-            is(innerNodes[0].querySelector(".value").getAttribute("value"), "Error",
-              "Should have the right property value for the exception.");
-
-            resumeAndFinish();
-
-          }}, 0);
-        }, false);
+        ok(true, "Frames were cleared, debugger didn't pause again.");
       });
 
-      content.window.location.reload();
-    }, false);
+      EventUtils.sendMouseEvent({ type: "mousedown" },
+        gDebugger.document.getElementById("resume"),
+        gDebugger);
+
+      return finished;
+    });
+
+    EventUtils.sendMouseEvent({ type: "mousedown" },
+      gDebugger.document.getElementById("resume"),
+      gDebugger);
+
+    return finished;
   });
 
-  content.window.location.reload();
+  EventUtils.sendMouseEvent({ type: "click" },
+    gDebuggee.document.querySelector("button"),
+    gDebuggee.window);
+
+  return finished;
+}
+
+function enablePauseOnExceptions() {
+  let deferred = promise.defer();
+
+  gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
+    is(gPrefs.pauseOnExceptions, true,
+      "The pause-on-exceptions pref should now be enabled.");
+    is(gOptions._pauseOnExceptionsItem.getAttribute("checked"), "true",
+      "The pause-on-exceptions menu item should now be checked.");
+
+    ok(true, "Pausing on exceptions was enabled.");
+    deferred.resolve();
+  });
+
+  gOptions._pauseOnExceptionsItem.setAttribute("checked", "true");
+  gOptions._togglePauseOnExceptions();
+
+  return deferred.promise;
 }
 
-function resumeAndFinish() {
-  // Disable pause on exceptions.
-  gDebugger.DebuggerView.Options._pauseOnExceptionsItem.setAttribute("checked", "false");
-  gDebugger.DebuggerView.Options._togglePauseOnExceptions();
+function disablePauseOnExceptions() {
+  let deferred = promise.defer();
 
-  // Enable ignore caught exceptions
-  gDebugger.DebuggerView.Options._ignoreCaughtExceptionsItem.setAttribute("checked", "true");
-  gDebugger.DebuggerView.Options._toggleIgnoreCaughtExceptions();
+  gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
+    is(gPrefs.pauseOnExceptions, false,
+      "The pause-on-exceptions pref should now be disabled.");
+    isnot(gOptions._pauseOnExceptionsItem.getAttribute("checked"), "true",
+      "The pause-on-exceptions menu item should now be unchecked.");
 
-  is(gDebugger.Prefs.pauseOnExceptions, false,
-    "The pause-on-exceptions pref should have been set to false.");
-
-  gPane.panelWin.gClient.addOneTimeListener("resumed", function() {
-    Services.tm.currentThread.dispatch({ run: closeDebuggerAndFinish }, 0);
+    ok(true, "Pausing on exceptions was disabled.");
+    deferred.resolve();
   });
 
-  // Resume to let the exception reach it's catch clause.
-  gDebugger.DebuggerController.activeThread.resume();
+  gOptions._pauseOnExceptionsItem.setAttribute("checked", "false");
+  gOptions._togglePauseOnExceptions();
+
+  return deferred.promise;
+}
+
+function enableIgnoreCaughtExceptions() {
+  let deferred = promise.defer();
+
+  gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
+    is(gPrefs.ignoreCaughtExceptions, true,
+      "The ignore-caught-exceptions pref should now be enabled.");
+    is(gOptions._ignoreCaughtExceptionsItem.getAttribute("checked"), "true",
+      "The ignore-caught-exceptions menu item should now be checked.");
+
+    ok(true, "Ignore caught exceptions was enabled.");
+    deferred.resolve();
+  });
+
+  gOptions._ignoreCaughtExceptionsItem.setAttribute("checked", "true");
+  gOptions._toggleIgnoreCaughtExceptions();
+
+  return deferred.promise;
+}
+
+function disableIgnoreCaughtExceptions() {
+  let deferred = promise.defer();
+
+  gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
+    is(gPrefs.ignoreCaughtExceptions, false,
+      "The ignore-caught-exceptions pref should now be disabled.");
+    isnot(gOptions._ignoreCaughtExceptionsItem.getAttribute("checked"), "true",
+      "The ignore-caught-exceptions menu item should now be unchecked.");
+
+    ok(true, "Ignore caught exceptions was disabled.");
+    deferred.resolve();
+  });
+
+  gOptions._ignoreCaughtExceptionsItem.setAttribute("checked", "false");
+  gOptions._toggleIgnoreCaughtExceptions();
+
+  return deferred.promise;
 }
 
 registerCleanupFunction(function() {
-  removeTab(gTab);
-  gPane = null;
   gTab = null;
+  gDebuggee = null;
+  gPanel = null;
   gDebugger = null;
+  gFrames = null;
+  gVariables = null;
+  gPrefs = null;
+  gOptions = null;
 });
--- a/browser/devtools/debugger/test/browser_dbg_pause-resume.js
+++ b/browser/devtools/debugger/test/browser_dbg_pause-resume.js
@@ -1,93 +1,78 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests if pausing and resuming in the main loop works properly.
  */
 
-var gPane = null;
-var gTab = null;
-var gDebugger = null;
-var gView = null;
-var gDH = null;
-var gL10N = null;
+const TAB_URL = EXAMPLE_URL + "doc_pause-exceptions.html";
+
+let gTab, gDebuggee, gPanel, gDebugger;
+let gResumeButton, gResumeKey, gFrames;
 
 function test() {
-  debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
-    gView = gDebugger.DebuggerView;
-    gDH = gDebugger.DevtoolsHelpers;
-    gL10N = gDebugger.L10N;
+    gDebuggee = aDebuggee;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gResumeButton = gDebugger.document.getElementById("resume");
+    gResumeKey = gDebugger.document.getElementById("resumeKey");
+    gFrames = gDebugger.DebuggerView.StackFrames;
 
     testPause();
   });
 }
 
 function testPause() {
-  is(gDebugger.DebuggerController.activeThread.paused, false,
-    "Should be running after debug_tab_pane.");
+  is(gDebugger.gThreadClient.paused, false,
+    "Should be running after starting the test.");
 
-  let button = gDebugger.document.getElementById("resume");
-  is(button.getAttribute("tooltiptext"),
-     gL10N.getFormatStr("pauseButtonTooltip",
-      gDH.prettyKey(gDebugger.document.getElementById("resumeKey"))),
-    "Button tooltip should be pause when running.");
-
-  gDebugger.DebuggerController.activeThread.addOneTimeListener("paused", function() {
-    Services.tm.currentThread.dispatch({ run: function() {
+  is(gResumeButton.getAttribute("tooltiptext"),
+     gDebugger.L10N.getFormatStr("pauseButtonTooltip",
+      gDebugger.DevtoolsHelpers.prettyKey(gResumeKey)),
+    "Button tooltip should be 'pause' when running.");
 
-      let frames = gDebugger.DebuggerView.StackFrames.widget._list;
-      let childNodes = frames.childNodes;
-
-      is(gDebugger.DebuggerController.activeThread.paused, true,
-        "Should be paused after an interrupt request.");
+  gDebugger.gThreadClient.addOneTimeListener("paused", () => {
+    is(gDebugger.gThreadClient.paused, true,
+      "Should be paused after an interrupt request.");
 
-      is(button.getAttribute("tooltiptext"),
-         gL10N.getFormatStr("resumeButtonTooltip",
-          gDH.prettyKey(gDebugger.document.getElementById("resumeKey"))),
-        "Button tooltip should be resume when paused.");
+    is(gResumeButton.getAttribute("tooltiptext"),
+       gDebugger.L10N.getFormatStr("resumeButtonTooltip",
+        gDebugger.DevtoolsHelpers.prettyKey(gResumeKey)),
+      "Button tooltip should be 'resume' when paused.");
 
-      is(frames.querySelectorAll(".dbg-stackframe").length, 0,
-        "Should have no frames when paused in the main loop.");
+    is(gFrames.itemCount, 0,
+      "Should have no frames when paused in the main loop.");
 
-      testResume();
-    }}, 0);
+    testResume();
   });
 
-  EventUtils.sendMouseEvent({ type: "mousedown" },
-    gDebugger.document.getElementById("resume"),
-    gDebugger);
+  EventUtils.sendMouseEvent({ type: "mousedown" }, gResumeButton, gDebugger);
 }
 
 function testResume() {
-  gDebugger.DebuggerController.activeThread.addOneTimeListener("resumed", function() {
-    Services.tm.currentThread.dispatch({ run: function() {
-
-      is(gDebugger.DebuggerController.activeThread.paused, false,
-        "Should be paused after an interrupt request.");
+  gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
+    is(gDebugger.gThreadClient.paused, false,
+      "Should be paused after an interrupt request.");
 
-      let button = gDebugger.document.getElementById("resume");
-      is(button.getAttribute("tooltiptext"),
-         gL10N.getFormatStr("pauseButtonTooltip",
-          gDH.prettyKey(gDebugger.document.getElementById("resumeKey"))),
-        "Button tooltip should be pause when running.");
+    is(gResumeButton.getAttribute("tooltiptext"),
+       gDebugger.L10N.getFormatStr("pauseButtonTooltip",
+        gDebugger.DevtoolsHelpers.prettyKey(gResumeKey)),
+      "Button tooltip should be pause when running.");
 
-      closeDebuggerAndFinish();
-    }}, 0);
+    closeDebuggerAndFinish(gPanel);
   });
 
-  EventUtils.sendMouseEvent({ type: "mousedown" },
-    gDebugger.document.getElementById("resume"),
-    gDebugger);
+  EventUtils.sendMouseEvent({ type: "mousedown" }, gResumeButton, gDebugger);
 }
 
 registerCleanupFunction(function() {
-  removeTab(gTab);
-  gPane = null;
   gTab = null;
+  gDebuggee = null;
+  gPanel = null;
   gDebugger = null;
-  gView = null;
-  gDH = null;
-  gL10N = null;
+  gResumeButton = null;
+  gResumeKey = null;
+  gFrames = null;
 });
--- a/browser/devtools/debugger/test/browser_dbg_pause-warning.js
+++ b/browser/devtools/debugger/test/browser_dbg_pause-warning.js
@@ -1,97 +1,98 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests if a warning is shown in the inspector when debugger is paused.
  */
 
-var gPane = null;
-var gTab = null;
-var gDebugger = null;
-var gView = null;
-var gToolbox = null;
-var gTarget = null;
+const TAB_URL = EXAMPLE_URL + "doc_inline-script.html";
+
+let gTab, gDebuggee, gPanel, gDebugger;
+let gTarget, gToolbox;
 
 function test() {
-  debug_tab_pane(STACK_URL, function(aTab, aDebuggee, aPane) {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
-    gView = gDebugger.DebuggerView;
-
-    gTarget = TargetFactory.forTab(gBrowser.selectedTab);
-    gToolbox = gDevTools.getToolbox(gTarget);
+    gDebuggee = aDebuggee;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gTarget = gPanel.target;
+    gToolbox = gPanel._toolbox;
 
     testPause();
   });
 }
 
 function testPause() {
-  let button = gDebugger.document.getElementById("resume");
+  gDebugger.gThreadClient.addOneTimeListener("paused", () => {
+    ok(gTarget.isThreadPaused,
+      "target.isThreadPaused has been updated to true.");
 
-  gDebugger.DebuggerController.activeThread.addOneTimeListener("paused", function() {
-    Services.tm.currentThread.dispatch({ run: function() {
-      is(gDebugger.DebuggerController.activeThread.paused, true,
-        "Debugger is paused.");
-
-      ok(gTarget.isThreadPaused, "target.isThreadPaused has been updated");
-
-      gToolbox.once("inspector-selected", testNotificationIsUp1);
-      gToolbox.selectTool("inspector");
-    }}, 0);
+    gToolbox.once("inspector-selected", testNotificationIsUp1);
+    gToolbox.selectTool("inspector");
   });
 
   EventUtils.sendMouseEvent({ type: "mousedown" },
     gDebugger.document.getElementById("resume"),
     gDebugger);
 }
 
 function testNotificationIsUp1() {
   let notificationBox = gToolbox.getNotificationBox();
   let notification = notificationBox.getNotificationWithValue("inspector-script-paused");
-  ok(notification, "Notification is present");
+
+  ok(notification,
+    "Inspector notification is present (1).");
+
   gToolbox.once("jsdebugger-selected", testNotificationIsHidden);
   gToolbox.selectTool("jsdebugger");
 }
 
 function testNotificationIsHidden() {
   let notificationBox = gToolbox.getNotificationBox();
   let notification = notificationBox.getNotificationWithValue("inspector-script-paused");
-  ok(!notification, "Notification is hidden");
+
+  ok(!notification,
+    "Inspector notification is hidden (2).");
+
   gToolbox.once("inspector-selected", testNotificationIsUp2);
   gToolbox.selectTool("inspector");
 }
 
 function testNotificationIsUp2() {
   let notificationBox = gToolbox.getNotificationBox();
   let notification = notificationBox.getNotificationWithValue("inspector-script-paused");
-  ok(notification, "Notification is present");
+
+  ok(notification,
+    "Inspector notification is present again (3).");
+
   testResume();
 }
 
 function testResume() {
-  gDebugger.DebuggerController.activeThread.addOneTimeListener("resumed", function() {
-    Services.tm.currentThread.dispatch({ run: function() {
+  gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
+    ok(!gTarget.isThreadPaused,
+      "target.isThreadPaused has been updated to false.");
 
-      ok(!gTarget.isThreadPaused, "target.isThreadPaused has been updated");
-      let notificationBox = gToolbox.getNotificationBox();
-      let notification = notificationBox.getNotificationWithValue("inspector-script-paused");
-      ok(!notification, "No notification once debugger resumed");
+    let notificationBox = gToolbox.getNotificationBox();
+    let notification = notificationBox.getNotificationWithValue("inspector-script-paused");
 
-      closeDebuggerAndFinish();
-    }}, 0);
+    ok(!notification,
+      "Inspector notification was removed once debugger resumed.");
+
+    closeDebuggerAndFinish(gPanel);
   });
 
   EventUtils.sendMouseEvent({ type: "mousedown" },
     gDebugger.document.getElementById("resume"),
     gDebugger);
 }
 
 registerCleanupFunction(function() {
-  removeTab(gTab);
-  gPane = null;
   gTab = null;
+  gDebuggee = null;
+  gPanel = null;
   gDebugger = null;
-  gView = null;
+  gTarget = null;
   gToolbox = null;
-  gTarget = null;
 });
--- a/browser/devtools/debugger/test/browser_dbg_progress-listener-bug.js
+++ b/browser/devtools/debugger/test/browser_dbg_progress-listener-bug.js
@@ -1,45 +1,58 @@
-/*
- * Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that the debugger does show up even if a progress listener reads the
+ * WebProgress argument's DOMWindow property in onStateChange() (bug 771655).
  */
 
-// Tests that the debugger does show up even if a progress listener reads the
-// WebProgress argument's DOMWindow property in onStateChange() (bug 771655).
+let gTab, gDebuggee, gPanel, gDebugger;
+let gOldListener;
 
-var gPane = null;
-var gTab = null;
-var gOldListener = null;
-
-const TEST_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
+const TAB_URL = EXAMPLE_URL + "doc_inline-script.html";
 
 function test() {
   installListener();
 
-  debug_tab_pane(TEST_URL, function(aTab, aDebuggee, aPane) {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
-    gPane = aPane;
-    let gDebugger = gPane.panelWin;
+    gDebuggee = aDebuggee;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+
+    is(!!gDebugger.DebuggerController._startup, true,
+      "Controller should be initialized after starting the test.");
+    is(!!gDebugger.DebuggerView._startup, true,
+      "View should be initialized after starting the test.");
 
-    is(gDebugger.DebuggerController._isInitialized, true,
-      "Controller should be initialized after debug_tab_pane.");
-    is(gDebugger.DebuggerView._isInitialized, true,
-      "View should be initialized after debug_tab_pane.");
+    testPause();
+  });
+}
 
-    closeDebuggerAndFinish();
+function testPause() {
+  waitForSourceAndCaretAndScopes(gPanel, ".html", 16).then(() => {
+    is(gDebugger.gThreadClient.state, "paused",
+      "The debugger statement was reached.");
+
+    resumeDebuggerThenCloseAndFinish(gPanel);
   });
+
+  gDebuggee.runDebuggerStatement();
 }
 
 // This is taken almost verbatim from bug 771655.
 function installListener() {
   if ("_testPL" in window) {
     gOldListener = _testPL;
-    Cc['@mozilla.org/docloaderservice;1'].getService(Ci.nsIWebProgress)
-                                         .removeProgressListener(_testPL);
+
+    Cc['@mozilla.org/docloaderservice;1']
+      .getService(Ci.nsIWebProgress)
+      .removeProgressListener(_testPL);
   }
 
   window._testPL = {
     START_DOC: Ci.nsIWebProgressListener.STATE_START |
                Ci.nsIWebProgressListener.STATE_IS_DOCUMENT,
     onStateChange: function(wp, req, stateFlags, status) {
       if ((stateFlags & this.START_DOC) === this.START_DOC) {
         // This DOMWindow access triggers the unload event.
@@ -49,22 +62,26 @@ function installListener() {
     QueryInterface: function(iid) {
       if (iid.equals(Ci.nsISupportsWeakReference) ||
           iid.equals(Ci.nsIWebProgressListener))
         return this;
       throw Cr.NS_ERROR_NO_INTERFACE;
     }
   }
 
-  Cc['@mozilla.org/docloaderservice;1'].getService(Ci.nsIWebProgress)
+  Cc['@mozilla.org/docloaderservice;1']
+    .getService(Ci.nsIWebProgress)
     .addProgressListener(_testPL, Ci.nsIWebProgress.NOTIFY_STATE_REQUEST);
 }
 
 registerCleanupFunction(function() {
   if (gOldListener) {
     window._testPL = gOldListener;
   } else {
     delete window._testPL;
   }
-  removeTab(gTab);
-  gPane = null;
+
   gTab = null;
+  gDebuggee = null;
+  gPanel = null;
+  gDebugger = null;
+  gOldListener = null;
 });
deleted file mode 100644
--- a/browser/devtools/debugger/test/browser_dbg_propertyview-filter-04.js
+++ /dev/null
@@ -1,93 +0,0 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/**
- * Make sure that the property view filter prefs work properly.
- */
-
-const TAB_URL = EXAMPLE_URL + "browser_dbg_with-frame.html";
-
-var gPane = null;
-var gTab = null;
-var gDebugger = null;
-var gDebuggee = null;
-var gPrevPref = null;
-
-function test()
-{
-  gPrevPref = Services.prefs.getBoolPref(
-    "devtools.debugger.ui.variables-searchbox-visible");
-  Services.prefs.setBoolPref(
-    "devtools.debugger.ui.variables-searchbox-visible", true);
-
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
-    gTab = aTab;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
-    gDebuggee = aDebuggee;
-
-    testSearchbox();
-    testPref();
-  });
-}
-
-function testSearchbox()
-{
-  ok(gDebugger.DebuggerView.Variables._searchboxNode,
-    "There should initially be a searchbox available in the variables view.");
-  ok(gDebugger.DebuggerView.Variables._parent.parentNode.querySelector(".variables-view-searchinput"),
-    "There searchbox element should be found.");
-}
-
-function testPref()
-{
-  is(gDebugger.Prefs.variablesSearchboxVisible, true,
-    "The debugger searchbox should be preffed as visible.");
-  is(gDebugger.DebuggerView.Options._showVariablesFilterBoxItem.getAttribute("checked"), "true",
-    "The options menu item should be checked.");
-
-  gDebugger.DebuggerView.Options._showVariablesFilterBoxItem.setAttribute("checked", "false");
-  gDebugger.DebuggerView.Options._toggleShowVariablesFilterBox();
-
-  executeSoon(function() {
-    ok(!gDebugger.DebuggerView.Variables._searchboxNode,
-      "There should not be a searchbox available in the variables view.");
-    ok(!gDebugger.DebuggerView.Variables._parent.parentNode.querySelector(".variables-view-searchinput"),
-      "There searchbox element should not be found.");
-    is(gDebugger.Prefs.variablesSearchboxVisible, false,
-      "The debugger searchbox should now be preffed as hidden.");
-    isnot(gDebugger.DebuggerView.Options._showVariablesFilterBoxItem.getAttribute("checked"), "true",
-      "The options menu item should now be unchecked.");
-
-    gDebugger.DebuggerView.Options._showVariablesFilterBoxItem.setAttribute("checked", "true");
-    gDebugger.DebuggerView.Options._toggleShowVariablesFilterBox();
-
-    executeSoon(function() {
-      ok(gDebugger.DebuggerView.Variables._searchboxNode,
-        "There should be a searchbox available in the variables view.");
-      ok(gDebugger.DebuggerView.Variables._parent.parentNode.querySelector(".variables-view-searchinput"),
-        "There searchbox element should be found.");
-      is(gDebugger.Prefs.variablesSearchboxVisible, true,
-        "The debugger searchbox should now be preffed as visible.");
-      is(gDebugger.DebuggerView.Options._showVariablesFilterBoxItem.getAttribute("checked"), "true",
-        "The options menu item should now be checked.");
-
-      executeSoon(function() {
-        Services.prefs.setBoolPref(
-          "devtools.debugger.ui.variables-searchbox-visible", gPrevPref);
-
-        closeDebuggerAndFinish();
-      });
-    });
-  });
-}
-
-registerCleanupFunction(function() {
-  removeTab(gTab);
-  gPane = null;
-  gTab = null;
-  gDebugger = null;
-  gDebuggee = null;
-  gPrevPref = null;
-});
deleted file mode 100644
--- a/browser/devtools/debugger/test/browser_dbg_propertyview-filter-07.js
+++ /dev/null
@@ -1,254 +0,0 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-/**
- * Make sure that the property view correctly filters nodes.
- */
-
-const TAB_URL = EXAMPLE_URL + "browser_dbg_with-frame.html";
-
-var gPane = null;
-var gTab = null;
-var gDebugger = null;
-var gDebuggee = null;
-var gSearchBox = null;
-
-requestLongerTimeout(2);
-
-function test()
-{
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
-    gTab = aTab;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
-    gDebuggee = aDebuggee;
-
-    gDebugger.DebuggerController.StackFrames.autoScopeExpand = true;
-    gDebugger.DebuggerView.Variables.delayedSearch = false;
-    prepareVariables(testVariablesFiltering);
-  });
-}
-
-function testVariablesFiltering()
-{
-  let f = {
-    test1: function()
-    {
-      assertExpansion(1, [true, false, false, false, false]);
-      clear();
-    },
-    test2: function()
-    {
-      assertExpansion(2, [true, false, false, false, false]);
-      EventUtils.sendKey("RETURN", gDebugger);
-    },
-    test3: function()
-    {
-      assertExpansion(3, [true, false, false, false, false]);
-      gDebugger.editor.focus();
-    },
-    test4: function()
-    {
-      assertExpansion(4, [true, false, false, false, false]);
-      write("*");
-    },
-    test5: function() {
-      assertExpansion(5, [true, true, true, true, true]);
-      EventUtils.sendKey("RETURN", gDebugger);
-    },
-    test6: function() {
-      assertExpansion(6, [true, true, true, true, true]);
-      gDebugger.editor.focus();
-    },
-    test7: function() {
-      assertExpansion(7, [true, true, true, true, true]);
-      backspace(1);
-    },
-    test8: function() {
-      assertExpansion(8, [true, true, true, true, true]);
-      EventUtils.sendKey("RETURN", gDebugger);
-    },
-    test9: function() {
-      assertExpansion(9, [true, true, true, true, true]);
-      gDebugger.editor.focus();
-    },
-    test10: function() {
-      assertExpansion(10, [true, true, true, true, true]);
-      innerScopeItem.collapse();
-      mathScopeItem.collapse();
-      testScopeItem.collapse();
-      loadScopeItem.collapse();
-      globalScopeItem.collapse();
-    },
-    test11: function() {
-      assertExpansion(11, [false, false, false, false, false]);
-      clear();
-    },
-    test12: function() {
-      assertExpansion(12, [false, false, false, false, false]);
-      EventUtils.sendKey("RETURN", gDebugger);
-    },
-    test13: function() {
-      assertExpansion(13, [false, false, false, false, false]);
-      gDebugger.editor.focus();
-    },
-    test14: function() {
-      assertExpansion(14, [false, false, false, false, false]);
-      write("*");
-    },
-    test15: function() {
-      assertExpansion(15, [true, true, true, true, true]);
-      EventUtils.sendKey("RETURN", gDebugger);
-    },
-    test16: function() {
-      assertExpansion(16, [true, true, true, true, true]);
-      gDebugger.editor.focus();
-    },
-    test17: function() {
-      assertExpansion(17, [true, true, true, true, true]);
-      backspace(1);
-    },
-    test18: function() {
-      assertExpansion(18, [true, true, true, true, true]);
-      EventUtils.sendKey("RETURN", gDebugger);
-    },
-    test19: function() {
-      assertExpansion(19, [true, true, true, true, true]);
-      gDebugger.editor.focus();
-    },
-    test20: function() {
-      assertExpansion(20, [true, true, true, true, true]);
-    }
-  };
-
-  function assertExpansion(n, array) {
-    is(innerScopeItem.expanded, array[0],
-      "The innerScope should " + (array[0] ? "" : "not ") +
-       "be expanded at this point (" + n + ")");
-
-    is(mathScopeItem.expanded, array[1],
-      "The mathScope should " + (array[1] ? "" : "not ") +
-       "be expanded at this point (" + n + ")");
-
-    is(testScopeItem.expanded, array[2],
-      "The testScope should " + (array[2] ? "" : "not ") +
-       "be expanded at this point (" + n + ")");
-
-    is(loadScopeItem.expanded, array[3],
-      "The loadScope should " + (array[3] ? "" : "not ") +
-       "be expanded at this point (" + n + ")");
-
-    is(globalScopeItem.expanded, array[4],
-      "The globalScope should " + (array[4] ? "" : "not ") +
-       "be expanded at this point (" + n + ")");
-  }
-
-  var scopes = gDebugger.DebuggerView.Variables._list,
-      innerScope = scopes.querySelectorAll(".variables-view-scope")[0],
-      mathScope = scopes.querySelectorAll(".variables-view-scope")[1],
-      testScope = scopes.querySelectorAll(".variables-view-scope")[2],
-      loadScope = scopes.querySelectorAll(".variables-view-scope")[3],
-      globalScope = scopes.querySelectorAll(".variables-view-scope")[4];
-
-  let innerScopeItem = gDebugger.DebuggerView.Variables._currHierarchy.get(
-    innerScope.querySelector(".name").getAttribute("value"));
-  let mathScopeItem = gDebugger.DebuggerView.Variables._currHierarchy.get(
-    mathScope.querySelector(".name").getAttribute("value"));
-  let testScopeItem = gDebugger.DebuggerView.Variables._currHierarchy.get(
-    testScope.querySelector(".name").getAttribute("value"));
-  let loadScopeItem = gDebugger.DebuggerView.Variables._currHierarchy.get(
-    loadScope.querySelector(".name").getAttribute("value"));
-  let globalScopeItem = gDebugger.DebuggerView.Variables._currHierarchy.get(
-    globalScope.querySelector(".name").getAttribute("value"));
-
-  gSearchBox = gDebugger.DebuggerView.Filtering._searchbox;
-
-  executeSoon(function() {
-    for (let i = 1; i <= Object.keys(f).length; i++) {
-      f["test" + i]();
-    }
-    closeDebuggerAndFinish();
-  });
-}
-
-function prepareVariables(aCallback)
-{
-  let count = 0;
-  gDebugger.addEventListener("Debugger:FetchedVariables", function test() {
-    // We expect 2 Debugger:FetchedVariables events, one from the inner object
-    // scope and the regular one.
-    if (++count < 2) {
-      info("Number of received Debugger:FetchedVariables events: " + count);
-      return;
-    }
-    gDebugger.removeEventListener("Debugger:FetchedVariables", test, false);
-    Services.tm.currentThread.dispatch({ run: function() {
-
-      var frames = gDebugger.DebuggerView.StackFrames.widget._list,
-          scopes = gDebugger.DebuggerView.Variables._list,
-          innerScope = scopes.querySelectorAll(".variables-view-scope")[0],
-          mathScope = scopes.querySelectorAll(".variables-view-scope")[1],
-          testScope = scopes.querySelectorAll(".variables-view-scope")[2],
-          loadScope = scopes.querySelectorAll(".variables-view-scope")[3],
-          globalScope = scopes.querySelectorAll(".variables-view-scope")[4];
-
-      let innerScopeItem = gDebugger.DebuggerView.Variables._currHierarchy.get(
-        innerScope.querySelector(".name").getAttribute("value"));
-      let mathScopeItem = gDebugger.DebuggerView.Variables._currHierarchy.get(
-        mathScope.querySelector(".name").getAttribute("value"));
-      let testScopeItem = gDebugger.DebuggerView.Variables._currHierarchy.get(
-        testScope.querySelector(".name").getAttribute("value"));
-      let loadScopeItem = gDebugger.DebuggerView.Variables._currHierarchy.get(
-        loadScope.querySelector(".name").getAttribute("value"));
-      let globalScopeItem = gDebugger.DebuggerView.Variables._currHierarchy.get(
-        globalScope.querySelector(".name").getAttribute("value"));
-
-      EventUtils.sendMouseEvent({ type: "mousedown" }, mathScope.querySelector(".arrow"), gDebugger);
-      EventUtils.sendMouseEvent({ type: "mousedown" }, testScope.querySelector(".arrow"), gDebugger);
-      EventUtils.sendMouseEvent({ type: "mousedown" }, loadScope.querySelector(".arrow"), gDebugger);
-      EventUtils.sendMouseEvent({ type: "mousedown" }, globalScope.querySelector(".arrow"), gDebugger);
-
-      executeSoon(function() {
-        aCallback();
-      });
-    }}, 0);
-  }, false);
-
-  EventUtils.sendMouseEvent({ type: "click" },
-    gDebuggee.document.querySelector("button"),
-    gDebuggee.window);
-}
-
-function clear() {
-  gSearchBox.focus();
-  gSearchBox.value = "";
-}
-
-function write(text) {
-  clear();
-  append(text);
-}
-
-function backspace(times) {
-  for (let i = 0; i < times; i++) {
-    EventUtils.sendKey("BACK_SPACE", gDebugger);
-  }
-}
-
-function append(text) {
-  gSearchBox.focus();
-
-  for (let i = 0; i < text.length; i++) {
-    EventUtils.sendChar(text[i], gDebugger);
-  }
-}
-
-registerCleanupFunction(function() {
-  removeTab(gTab);
-  gPane = null;
-  gTab = null;
-  gDebugger = null;
-  gDebuggee = null;
-  gSearchBox = null;
-});
rename from browser/devtools/debugger/test/browser_dbg_reload-preferred-script.js
rename to browser/devtools/debugger/test/browser_dbg_reload-preferred-script-01.js
--- a/browser/devtools/debugger/test/browser_dbg_reload-preferred-script.js
+++ b/browser/devtools/debugger/test/browser_dbg_reload-preferred-script-01.js
@@ -1,79 +1,49 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
- * Tests if the preferred script is shown when a page is loaded.
+ * Tests if the preferred source is shown when a page is loaded and
+ * the preferred source is specified before any other source was shown.
  */
 
-const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
-
-let gPane = null;
-let gTab = null;
-let gDebuggee = null;
-let gDebugger = null;
-let gView = null;
-
-requestLongerTimeout(2);
+const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
+const PREFERRED_URL = EXAMPLE_URL + "code_script-switching-02.js";
 
-function test()
-{
-  let expectedScript = "test-script-switching-02.js";
-  let expectedScriptShown = false;
-  let scriptShownUrl = null;
-  let resumed = false;
-  let testStarted = false;
+let gTab, gDebuggee, gPanel, gDebugger;
+let gSources;
 
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
+function test() {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
     gDebuggee = aDebuggee;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
-    gView = gDebugger.DebuggerView;
-    resumed = true;
-
-    gDebugger.addEventListener("Debugger:SourceShown", onScriptShown);
-
-    gView.Sources.preferredSource = EXAMPLE_URL + expectedScript;
-    startTest();
-  });
-
-  function onScriptShown(aEvent)
-  {
-    expectedScriptShown = aEvent.detail.url.indexOf(expectedScript) != -1;
-    scriptShownUrl = aEvent.detail.url;
-    startTest();
-  }
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gSources = gDebugger.DebuggerView.Sources;
 
-  function startTest()
-  {
-    if (expectedScriptShown && resumed && !testStarted) {
-      gDebugger.removeEventListener("Debugger:SourceShown", onScriptShown);
-      testStarted = true;
-      Services.tm.currentThread.dispatch({ run: performTest }, 0);
-    }
-  }
-
-  function performTest()
-  {
-    info("Currently preferred script: " + gView.Sources.preferredValue);
-    info("Currently selected script: " + gView.Sources.selectedValue);
-
-    isnot(gView.Sources.preferredValue.indexOf(expectedScript), -1,
-      "The preferred script url wasn't set correctly.");
-    isnot(gView.Sources.selectedValue.indexOf(expectedScript), -1,
-      "The selected script isn't the correct one.");
-    is(gView.Sources.selectedValue, scriptShownUrl,
-      "The shown script is not the the correct one.");
-
-    closeDebuggerAndFinish();
-  }
-
-  registerCleanupFunction(function() {
-    removeTab(gTab);
-    gPane = null;
-    gTab = null;
-    gDebuggee = null;
-    gDebugger = null;
-    gView = null;
+    waitForSourceShown(gPanel, PREFERRED_URL).then(finishTest);
   });
 }
+
+function finishTest() {
+  info("Currently preferred source: " + gSources.preferredValue);
+  info("Currently selected source: " + gSources.selectedValue);
+
+  is(gSources.preferredValue, PREFERRED_URL,
+    "The preferred source url wasn't set correctly.");
+  is(gSources.selectedValue, PREFERRED_URL,
+    "The selected source isn't the correct one.");
+
+  closeDebuggerAndFinish(gPanel);
+}
+
+function prepareDebugger(aPanel) {
+  aPanel._view.Sources.preferredSource = PREFERRED_URL;
+}
+
+registerCleanupFunction(function() {
+  gTab = null;
+  gDebuggee = null;
+  gPanel = null;
+  gDebugger = null;
+  gSources = null;
+});
--- a/browser/devtools/debugger/test/browser_dbg_reload-same-script.js
+++ b/browser/devtools/debugger/test/browser_dbg_reload-same-script.js
@@ -1,218 +1,78 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
- * Tests if the same script is shown after a page is reloaded.
+ * Tests if the same source is shown after a page is reloaded.
  */
 
-const TAB_URL = EXAMPLE_URL + "browser_dbg_script-switching.html";
-
-let gPane = null;
-let gTab = null;
-let gDebuggee = null;
-let gDebugger = null;
-let gView = null;
-
-requestLongerTimeout(2);
+const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
+const FIRST_URL = EXAMPLE_URL + "code_script-switching-01.js";
+const SECOND_URL = EXAMPLE_URL + "code_script-switching-02.js";
 
-function test()
-{
-  let step = 0;
-  let expectedScript = "";
-  let expectedScriptShown = false;
-  let scriptShownUrl = null;
-  let resumed = false;
-  let testStarted = false;
+function test() {
+  // Debug test slaves are a bit slow at this test.
+  requestLongerTimeout(2);
 
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
+  let gTab, gDebuggee, gPanel, gDebugger;
+  let gSources, gStep;
+
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
     gDebuggee = aDebuggee;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
-    gView = gDebugger.DebuggerView;
-    resumed = true;
+    gPanel = aPanel;
+    gDebugger = aPanel.panelWin;
+    gSources = gDebugger.DebuggerView.Sources;
+    gStep = 0;
 
-    gDebugger.addEventListener("Debugger:SourceShown", onScriptShown);
-
-    startTest();
+    waitForSourceShown(gPanel, FIRST_URL).then(performTest);
   });
 
-  function onScriptShown(aEvent)
-  {
-    expectedScriptShown = aEvent.detail.url.indexOf("-01.js") != -1;
-    scriptShownUrl = aEvent.detail.url;
-    startTest();
-  }
-
-  function onUlteriorScriptShown(aEvent)
-  {
-    ok(expectedScript,
-      "The expected script to show up should have been specified.");
-
-    info("The expected script for this ScriptShown event is: " + expectedScript);
-    info("The current script for this ScriptShown event is: " + aEvent.detail.url);
-
-    expectedScriptShown = aEvent.detail.url.indexOf(expectedScript) != -1;
-    scriptShownUrl = aEvent.detail.url;
-    testScriptShown();
-  }
-
-  function startTest()
-  {
-    if (expectedScriptShown && resumed && !testStarted) {
-      gDebugger.removeEventListener("Debugger:SourceShown", onScriptShown);
-      gDebugger.addEventListener("Debugger:SourceShown", onUlteriorScriptShown);
-      testStarted = true;
-      Services.tm.currentThread.dispatch({ run: performTest }, 0);
-    }
-  }
-
-  function finishTest()
-  {
-    if (expectedScriptShown && resumed && testStarted) {
-      gDebugger.removeEventListener("Debugger:SourceShown", onUlteriorScriptShown);
-      closeDebuggerAndFinish();
+  function performTest() {
+    switch (gStep++) {
+      case 0:
+        testCurrentSource(FIRST_URL, "");
+        reload().then(performTest);
+        break;
+      case 1:
+        testCurrentSource(FIRST_URL);
+        reload().then(performTest);
+        break;
+      case 2:
+        testCurrentSource(FIRST_URL);
+        switchAndReload(SECOND_URL).then(performTest);
+        break;
+      case 3:
+        testCurrentSource(SECOND_URL);
+        reload().then(performTest);
+        break;
+      case 4:
+        testCurrentSource(SECOND_URL);
+        reload().then(performTest);
+        break;
+      case 5:
+        testCurrentSource(SECOND_URL);
+        closeDebuggerAndFinish(gPanel);
+        break;
     }
   }
 
-  function performTest()
-  {
-    testCurrentScript("-01.js", step);
-    expectedScript = "-01.js";
-    performAction(reloadPage);
+  function reload() {
+    return reloadActiveTab(gPanel, gDebugger.EVENTS.SOURCES_ADDED);
+  }
+
+  function switchAndReload(aUrl) {
+    let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.SOURCE_SHOWN).then(reload);
+    gSources.selectedValue = aUrl;
+    return finished;
   }
 
-  function testScriptShown()
-  {
-    if (!expectedScriptShown) {
-      return;
-    }
-    step++;
+  function testCurrentSource(aUrl, aExpectedUrl = aUrl) {
+    info("Currently preferred source: '" + gSources.preferredValue + "'.");
+    info("Currently selected source: '" + gSources.selectedValue + "'.");
 
-    if (step === 1) {
-      testCurrentScript("-01.js", step, true);
-      expectedScript = "-01.js";
-      performAction(reloadPage);
-    }
-    else if (step === 2) {
-      testCurrentScript("-01.js", step, true);
-      expectedScript = "-02.js";
-      performAction(switchScript, 1);
-    }
-    else if (step === 3) {
-      testCurrentScript("-02.js", step);
-      expectedScript = "-02.js";
-      performAction(reloadPage);
-    }
-    else if (step === 4) {
-      testCurrentScript("-02.js", step, true);
-      expectedScript = "-01.js";
-      performAction(switchScript, 0);
-    }
-    else if (step === 5) {
-      testCurrentScript("-01.js", step);
-      expectedScript = "-01.js";
-      performAction(reloadPage);
-    }
-    else if (step === 6) {
-      testCurrentScript("-01.js", step, true);
-      expectedScript = "-01.js";
-      performAction(reloadPage);
-    }
-    else if (step === 7) {
-      testCurrentScript("-01.js", step, true);
-      expectedScript = "-01.js";
-      performAction(reloadPage);
-    }
-    else if (step === 8) {
-      testCurrentScript("-01.js", step, true);
-      expectedScript = "-02.js";
-      performAction(switchScript, 1);
-    }
-    else if (step === 9) {
-      testCurrentScript("-02.js", step);
-      expectedScript = "-02.js";
-      performAction(reloadPage);
-    }
-    else if (step === 10) {
-      testCurrentScript("-02.js", step, true);
-      expectedScript = "-02.js";
-      performAction(reloadPage);
-    }
-    else if (step === 11) {
-      testCurrentScript("-02.js", step, true);
-      expectedScript = "-02.js";
-      performAction(reloadPage);
-    }
-    else if (step === 12) {
-      testCurrentScript("-02.js", step, true);
-      expectedScript = "-01.js";
-      performAction(switchScript, 0);
-    }
-    else if (step === 13) {
-      testCurrentScript("-01.js", step);
-      finishTest();
-    }
+    is(gSources.preferredValue, aExpectedUrl,
+      "The preferred source url wasn't set correctly (" + gStep + ").");
+    is(gSources.selectedValue, aUrl,
+      "The selected source isn't the correct one (" + gStep + ").");
   }
-
-  function testCurrentScript(part, step, isAfterReload)
-  {
-    info("Currently preferred script: " + gView.Sources.preferredValue);
-    info("Currently selected script: " + gView.Sources.selectedValue);
-
-    if (step < 1) {
-      is(gView.Sources.preferredValue, null,
-        "The preferred script url should be initially null");
-    }
-    else if (isAfterReload) {
-      isnot(gView.Sources.preferredValue.indexOf(part), -1,
-        "The preferred script url wasn't set correctly. (" + step + ")");
-    }
-
-    isnot(gView.Sources.selectedValue.indexOf(part), -1,
-      "The selected script isn't the correct one. (" + step + ")");
-    is(gView.Sources.selectedValue, scriptShownUrl,
-      "The shown script is not the the correct one. (" + step + ")");
-  }
-
-  function performAction(callback, data)
-  {
-    // Poll every few milliseconds until the scripts are retrieved.
-    let count = 0;
-    let intervalID = window.setInterval(function() {
-      info("count: " + count + " ");
-      if (++count > 50) {
-        ok(false, "Timed out while polling for the scripts.");
-        window.clearInterval(intervalID);
-        return closeDebuggerAndFinish();
-      }
-      if (gView.Sources.values.length !== 2) {
-        return;
-      }
-      info("Available scripts: " + gView.Sources.values);
-
-      // We got all the scripts, it's safe to callback.
-      window.clearInterval(intervalID);
-      callback(data);
-    }, 100);
-  }
-
-  function switchScript(index)
-  {
-    gView.Sources.selectedValue = gView.Sources.values[index];
-  }
-
-  function reloadPage()
-  {
-    gDebugger.DebuggerController.client.activeTab.reload();
-  }
-
-  registerCleanupFunction(function() {
-    removeTab(gTab);
-    gPane = null;
-    gTab = null;
-    gDebuggee = null;
-    gDebugger = null;
-    gView = null;
-  });
 }
--- a/browser/devtools/debugger/test/browser_dbg_step-out.js
+++ b/browser/devtools/debugger/test/browser_dbg_step-out.js
@@ -1,132 +1,85 @@
-/* vim:set ts=2 sw=2 sts=2 et: */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Make sure that stepping out of a function displays the right return value.
  */
 
-const TAB_URL = EXAMPLE_URL + "test-step-out.html";
+const TAB_URL = EXAMPLE_URL + "doc_step-out.html";
 
-var gPane = null;
-var gTab = null;
-var gDebugger = null;
+let gTab, gDebuggee, gPanel, gDebugger;
+let gVars;
 
-function test()
-{
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
+function test() {
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
+    gDebuggee = aDebuggee;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gVars = gDebugger.DebuggerView.Variables;
 
     testNormalReturn();
   });
 }
 
-function testNormalReturn()
-{
-  gPane.panelWin.gClient.addOneTimeListener("paused", function() {
-    gDebugger.addEventListener("Debugger:SourceShown", function dbgstmt(aEvent) {
-      gDebugger.removeEventListener(aEvent.type, dbgstmt);
-      is(gDebugger.DebuggerController.activeThread.state, "paused",
-        "Should be paused now.");
-
-      let count = 0;
-      gPane.panelWin.gClient.addOneTimeListener("paused", function() {
-        is(gDebugger.DebuggerController.activeThread.state, "paused",
-          "Should be paused again.");
-
-        gDebugger.addEventListener("Debugger:FetchedVariables", function stepout() {
-          ok(true, "Debugger:FetchedVariables event received.");
-          gDebugger.removeEventListener("Debugger:FetchedVariables", stepout, false);
-
-          Services.tm.currentThread.dispatch({ run: function() {
+function testNormalReturn() {
+  waitForSourceAndCaretAndScopes(gPanel, ".html", 17).then(() => {
+    waitForCaretAndScopes(gPanel, 19).then(() => {
+      let innerScope = gVars.getScopeAtIndex(0);
+      let returnVar = innerScope.get("<return>");
 
-            var scopes = gDebugger.DebuggerView.Variables._list,
-                innerScope = scopes.firstChild,
-                innerNodes = innerScope.querySelector(".variables-view-element-details").childNodes;
-
-            is(innerNodes[0].querySelector(".name").getAttribute("value"), "<return>",
-              "Should have the right property name for the return value.");
-
-            is(innerNodes[0].querySelector(".value").getAttribute("value"), 10,
-              "Should have the right property value for the return value.");
+      is(returnVar.name, "<return>",
+        "Should have the right property name for the returned value.");
+      is(returnVar.value, 10,
+        "Should have the right property value for the returned value.");
 
-            testReturnWithException();
-          }}, 0);
-        }, false);
-      });
+      resumeDebuggee().then(() => testReturnWithException());
+    });
 
-      EventUtils.sendMouseEvent({ type: "mousedown" },
-        gDebugger.document.getElementById("step-out"),
-        gDebugger);
-    });
+    EventUtils.sendMouseEvent({ type: "mousedown" },
+      gDebugger.document.getElementById("step-out"),
+      gDebugger);
   });
 
   EventUtils.sendMouseEvent({ type: "click" },
-    content.document.getElementById("return"),
-    content.window);
+    gDebuggee.document.getElementById("return"),
+    gDebuggee);
 }
 
-function testReturnWithException()
-{
-  gDebugger.DebuggerController.activeThread.resume(function() {
-    gPane.panelWin.gClient.addOneTimeListener("paused", function() {
-      gDebugger.addEventListener("Debugger:FetchedVariables", function dbgstmt(aEvent) {
-        gDebugger.removeEventListener(aEvent.type, dbgstmt, false);
-        is(gDebugger.DebuggerController.activeThread.state, "paused",
-          "Should be paused now.");
-
-        let count = 0;
-        gPane.panelWin.gClient.addOneTimeListener("paused", function() {
-          is(gDebugger.DebuggerController.activeThread.state, "paused",
-            "Should be paused again.");
-
-          gDebugger.addEventListener("Debugger:FetchedVariables", function stepout() {
-            ok(true, "Debugger:FetchedVariables event received.");
-            gDebugger.removeEventListener("Debugger:FetchedVariables", stepout, false);
-
-            Services.tm.currentThread.dispatch({ run: function() {
+function testReturnWithException() {
+  waitForCaretAndScopes(gPanel, 24).then(() => {
+    waitForCaretAndScopes(gPanel, 27).then(() => {
+      let innerScope = gVars.getScopeAtIndex(0);
+      let exceptionVar = innerScope.get("<exception>");
 
-              var scopes = gDebugger.DebuggerView.Variables._list,
-                  innerScope = scopes.firstChild,
-                  innerNodes = innerScope.querySelector(".variables-view-element-details").childNodes;
-
-              is(innerNodes[0].querySelector(".name").getAttribute("value"), "<exception>",
-                "Should have the right property name for the exception value.");
-
-              is(innerNodes[0].querySelector(".value").getAttribute("value"), '"boom"',
-                "Should have the right property value for the exception value.");
+      is(exceptionVar.name, "<exception>",
+        "Should have the right property name for the returned value.");
+      is(exceptionVar.value, "boom",
+        "Should have the right property value for the returned value.");
 
-              resumeAndFinish();
-
-            }}, 0);
-          }, false);
-        });
-
-        EventUtils.sendMouseEvent({ type: "mousedown" },
-          gDebugger.document.getElementById("step-out"),
-          gDebugger);
-      }, false);
+      resumeDebuggee().then(() => closeDebuggerAndFinish(gPanel));
     });
 
-    EventUtils.sendMouseEvent({ type: "click" },
-      content.document.getElementById("throw"),
-      content.window);
+    EventUtils.sendMouseEvent({ type: "mousedown" },
+      gDebugger.document.getElementById("step-out"),
+      gDebugger);
   });
+
+  EventUtils.sendMouseEvent({ type: "click" },
+    gDebuggee.document.getElementById("throw"),
+    gDebuggee);
 }
 
-function resumeAndFinish() {
-  gPane.panelWin.gClient.addOneTimeListener("resumed", function() {
-    Services.tm.currentThread.dispatch({ run: closeDebuggerAndFinish }, 0);
-  });
-
-  gDebugger.DebuggerController.activeThread.resume();
+function resumeDebuggee() {
+  let deferred = promise.defer();
+  gDebugger.gThreadClient.resume(deferred.resolve);
+  return deferred.promise;
 }
 
 registerCleanupFunction(function() {
-  removeTab(gTab);
-  gPane = null;
   gTab = null;
+  gDebuggee = null;
+  gPanel = null;
   gDebugger = null;
+  gVars = null;
 });
--- a/browser/devtools/debugger/test/browser_dbg_tabactor-01.js
+++ b/browser/devtools/debugger/test/browser_dbg_tabactor-01.js
@@ -1,47 +1,70 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Check extension-added tab actor lifetimes.
  */
 
-var gTab1 = null;
-var gTab1Actor = null;
+const CHROME_URL = "chrome://mochitests/content/browser/browser/devtools/debugger/test/"
+const ACTORS_URL = CHROME_URL + "testactors.js";
+const TAB_URL = EXAMPLE_URL + "doc_empty-tab-01.html";
+
+let gClient;
 
-var gClient = null;
+function test() {
+  if (!DebuggerServer.initialized) {
+    DebuggerServer.init(() => true);
+    DebuggerServer.addBrowserActors();
+  }
 
-function test()
-{
-  DebuggerServer.addActors("chrome://mochitests/content/browser/browser/devtools/debugger/test/testactors.js");
+  DebuggerServer.addActors(ACTORS_URL);
 
   let transport = DebuggerServer.connectPipe();
   gClient = new DebuggerClient(transport);
-  gClient.connect(function (aType, aTraits) {
-    is(aType, "browser", "Root actor should identify itself as a browser.");
-    get_tab();
+  gClient.connect((aType, aTraits) => {
+    is(aType, "browser",
+      "Root actor should identify itself as a browser.");
+
+    addTab(TAB_URL)
+      .then(() => attachTabActorForUrl(gClient, TAB_URL))
+      .then(testTabActor)
+      .then(closeTab)
+      .then(closeConnection)
+      .then(finish)
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
   });
 }
 
-function get_tab()
-{
-  gTab1 = addTab(TAB1_URL, function() {
-    attach_tab_actor_for_url(gClient, TAB1_URL, function(aGrip) {
-      gTab1Actor = aGrip.actor;
-      ok(aGrip.testTabActor1, "Found the test tab actor.")
-      ok(aGrip.testTabActor1.indexOf("testone") >= 0,
-         "testTabActor's actorPrefix should be used.");
-      gClient.request({ to: aGrip.testTabActor1, type: "ping" }, function(aResponse) {
-        is(aResponse.pong, "pong", "Actor should respond to requests.");
-        finish_test();
-      });
-    });
+function testTabActor([aGrip, aResponse]) {
+  let deferred = promise.defer();
+
+  ok(aGrip.testTabActor1,
+    "Found the test tab actor.");
+  ok(aGrip.testTabActor1.contains("test_one"),
+    "testTabActor1's actorPrefix should be used.");
+
+  gClient.request({ to: aGrip.testTabActor1, type: "ping" }, aResponse => {
+    is(aResponse.pong, "pong",
+      "Actor should respond to requests.");
+
+    deferred.resolve();
   });
+
+  return deferred.promise;
 }
 
-function finish_test()
-{
-  gClient.close(function() {
-    removeTab(gTab1);
-    finish();
-  });
+function closeTab() {
+  return removeTab(gBrowser.selectedTab);
 }
+
+function closeConnection() {
+  let deferred = promise.defer();
+  gClient.close(deferred.resolve);
+  return deferred.promise;
+}
+
+registerCleanupFunction(function() {
+  gClient = null;
+});
--- a/browser/devtools/debugger/test/browser_dbg_tabactor-02.js
+++ b/browser/devtools/debugger/test/browser_dbg_tabactor-02.js
@@ -1,61 +1,84 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Check extension-added tab actor lifetimes.
  */
 
-var gTab1 = null;
-var gTab1Actor = null;
+const CHROME_URL = "chrome://mochitests/content/browser/browser/devtools/debugger/test/"
+const ACTORS_URL = CHROME_URL + "testactors.js";
+const TAB_URL = EXAMPLE_URL + "doc_empty-tab-01.html";
+
+let gClient;
 
-var gClient = null;
+function test() {
+  if (!DebuggerServer.initialized) {
+    DebuggerServer.init(() => true);
+    DebuggerServer.addBrowserActors();
+  }
 
-function test()
-{
-  DebuggerServer.addActors("chrome://mochitests/content/browser/browser/devtools/debugger/test/testactors.js");
+  DebuggerServer.addActors(ACTORS_URL);
 
   let transport = DebuggerServer.connectPipe();
   gClient = new DebuggerClient(transport);
-  gClient.connect(function (aType, aTraits) {
-    is(aType, "browser", "Root actor should identify itself as a browser.");
-    get_tab();
+  gClient.connect((aType, aTraits) => {
+    is(aType, "browser",
+      "Root actor should identify itself as a browser.");
+
+    addTab(TAB_URL)
+      .then(() => attachTabActorForUrl(gClient, TAB_URL))
+      .then(testTabActor)
+      .then(closeTab)
+      .then(closeConnection)
+      .then(finish)
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
   });
 }
 
-function get_tab()
-{
-  gTab1 = addTab(TAB1_URL, function() {
-    attach_tab_actor_for_url(gClient, TAB1_URL, function(aGrip) {
-      gTab1Actor = aGrip.actor;
-      ok(aGrip.testTabActor1, "Found the test tab actor.")
-      ok(aGrip.testTabActor1.indexOf("testone") >= 0,
-         "testTabActor's actorPrefix should be used.");
-      gClient.request({ to: aGrip.testTabActor1, type: "ping" }, function(aResponse) {
-        is(aResponse.pong, "pong", "Actor should respond to requests.");
-        close_tab(aResponse.actor);
+function testTabActor([aGrip, aResponse]) {
+  let deferred = promise.defer();
+
+  ok(aGrip.testTabActor1,
+    "Found the test tab actor.");
+  ok(aGrip.testTabActor1.contains("test_one"),
+    "testTabActor1's actorPrefix should be used.");
+
+  gClient.request({ to: aGrip.testTabActor1, type: "ping" }, aResponse => {
+    is(aResponse.pong, "pong",
+      "Actor should respond to requests.");
+
+    deferred.resolve(aResponse.actor);
+  });
+
+  return deferred.promise;
+}
+
+function closeTab(aTestActor) {
+  return removeTab(gBrowser.selectedTab).then(() => {
+    let deferred = promise.defer();
+
+    try {
+      gClient.request({ to: aTestActor, type: "ping" }, aResponse => {
+        ok(false, "testTabActor1 didn't go away with the tab.");
+        deferred.reject(aResponse);
       });
-    });
+    } catch(e) {
+      is(e.message, "'ping' request packet has no destination.", "testTabActor1 went away.");
+      deferred.resolve();
+    }
+
+    return deferred.promise;
   });
 }
 
-function close_tab(aTestActor)
-{
-  removeTab(gTab1);
-  try {
-    gClient.request({ to: aTestActor, type: "ping" }, function (aResponse) {
-      is(aResponse, undefined, "testTabActor1 didn't go away with the tab.");
-      finish_test();
-    });
-  } catch (e) {
-    is(e.message, "'ping' request packet has no destination.",
-       "testTabActor1 should have gone away with the tab.");
-    finish_test();
-  }
+function closeConnection() {
+  let deferred = promise.defer();
+  gClient.close(deferred.resolve);
+  return deferred.promise;
 }
 
-function finish_test()
-{
-  gClient.close(function () {
-    finish();
-  });
-}
+registerCleanupFunction(function() {
+  gClient = null;
+});
rename from browser/devtools/debugger/test/browser_dbg_bug727429_watch-expressions-01.js
rename to browser/devtools/debugger/test/browser_dbg_watch-expressions-01.js
--- a/browser/devtools/debugger/test/browser_dbg_bug727429_watch-expressions-01.js
+++ b/browser/devtools/debugger/test/browser_dbg_watch-expressions-01.js
@@ -1,241 +1,228 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
- * Bug 727429: test the debugger watch expressions.
+ * Bug 727429: Test the debugger watch expressions.
  */
 
-const TAB_URL = EXAMPLE_URL + "browser_dbg_watch-expressions.html";
+const TAB_URL = EXAMPLE_URL + "doc_watch-expressions.html";
 
-let gPane = null;
-let gTab = null;
-let gDebuggee = null;
-let gDebugger = null;
-let gWatch = null;
+function test() {
+  // Debug test slaves are a bit slow at this test.
+  requestLongerTimeout(2);
 
-function test()
-{
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
+  let gTab, gDebuggee, gPanel, gDebugger;
+  let gEditor, gWatch, gVariables;
+
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
     gDebuggee = aDebuggee;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gEditor = gDebugger.DebuggerView.editor;
     gWatch = gDebugger.DebuggerView.WatchExpressions;
+    gVariables = gDebugger.DebuggerView.Variables;
 
     gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false });
-    performTest();
+
+    waitForSourceShown(gPanel, ".html")
+      .then(() => performTest())
+      .then(() => closeDebuggerAndFinish(gPanel))
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
   });
 
-  function performTest()
-  {
+  function performTest() {
     is(gWatch.getAllStrings().length, 0,
-      "There should initially be no watch expressions");
+      "There should initially be no watch expressions.");
 
     addAndCheckExpressions(1, 0, "a");
     addAndCheckExpressions(2, 0, "b");
     addAndCheckExpressions(3, 0, "c");
 
     removeAndCheckExpression(2, 1, "a");
     removeAndCheckExpression(1, 0, "a");
 
-
     addAndCheckExpressions(2, 0, "", true);
-    gDebugger.editor.focus();
+    gEditor.focus();
     is(gWatch.getAllStrings().length, 1,
-      "Empty watch expressions are automatically removed");
-
+      "Empty watch expressions are automatically removed.");
 
     addAndCheckExpressions(2, 0, "a", true);
-    gDebugger.editor.focus();
+    gEditor.focus();
     is(gWatch.getAllStrings().length, 1,
-      "Duplicate watch expressions are automatically removed");
+      "Duplicate watch expressions are automatically removed.");
 
     addAndCheckExpressions(2, 0, "a\t", true);
     addAndCheckExpressions(2, 0, "a\r", true);
     addAndCheckExpressions(2, 0, "a\n", true);
-    gDebugger.editor.focus();
+    gEditor.focus();
     is(gWatch.getAllStrings().length, 1,
-      "Duplicate watch expressions are automatically removed");
+      "Duplicate watch expressions are automatically removed.");
 
     addAndCheckExpressions(2, 0, "\ta", true);
     addAndCheckExpressions(2, 0, "\ra", true);
     addAndCheckExpressions(2, 0, "\na", true);
-    gDebugger.editor.focus();
+    gEditor.focus();
     is(gWatch.getAllStrings().length, 1,
-      "Duplicate watch expressions are automatically removed");
-
+      "Duplicate watch expressions are automatically removed.");
 
     addAndCheckCustomExpression(2, 0, "bazΩΩka");
     addAndCheckCustomExpression(3, 0, "bambøøcha");
 
-
     EventUtils.sendMouseEvent({ type: "click" },
       gWatch.getItemAtIndex(0).attachment.closeNode,
       gDebugger);
 
     is(gWatch.getAllStrings().length, 2,
-      "Watch expressions are removed when the close button is pressed");
+      "Watch expressions are removed when the close button is pressed.");
     is(gWatch.getAllStrings()[0], "bazΩΩka",
-      "The expression at index " + 0 + " should be correct (1)");
+      "The expression at index " + 0 + " should be correct (1).");
     is(gWatch.getAllStrings()[1], "a",
-      "The expression at index " + 1 + " should be correct (2)");
-
+      "The expression at index " + 1 + " should be correct (2).");
 
     EventUtils.sendMouseEvent({ type: "click" },
       gWatch.getItemAtIndex(0).attachment.closeNode,
       gDebugger);
 
     is(gWatch.getAllStrings().length, 1,
-      "Watch expressions are removed when the close button is pressed");
+      "Watch expressions are removed when the close button is pressed.");
     is(gWatch.getAllStrings()[0], "a",
-      "The expression at index " + 0 + " should be correct (3)");
-
+      "The expression at index " + 0 + " should be correct (3).");
 
     EventUtils.sendMouseEvent({ type: "click" },
       gWatch.getItemAtIndex(0).attachment.closeNode,
       gDebugger);
 
     is(gWatch.getAllStrings().length, 0,
-      "Watch expressions are removed when the close button is pressed");
-
+      "Watch expressions are removed when the close button is pressed.");
 
     EventUtils.sendMouseEvent({ type: "click" },
       gWatch.widget._parent,
       gDebugger);
 
     is(gWatch.getAllStrings().length, 1,
-      "Watch expressions are added when the view container is pressed");
-
-
-    closeDebuggerAndFinish();
+      "Watch expressions are added when the view container is pressed.");
   }
 
-  function addAndCheckCustomExpression(total, index, string, noBlur) {
-    addAndCheckExpressions(total, index, "", true);
+  function addAndCheckCustomExpression(aTotal, aIndex, aString, noBlur) {
+    addAndCheckExpressions(aTotal, aIndex, "", true);
 
-    for (let i = 0; i < string.length; i++) {
-      EventUtils.sendChar(string[i], gDebugger);
+    for (let i = 0; i < aString.length; i++) {
+      EventUtils.sendChar(aString[i], gDebugger);
     }
 
-    gDebugger.editor.focus();
+    gEditor.focus();
 
-    let element = gWatch.getItemAtIndex(index).target;
+    let element = gWatch.getItemAtIndex(aIndex).target;
 
-    is(gWatch.getItemAtIndex(index).attachment.initialExpression, "",
-      "The initial expression at index " + index + " should be correct (1)");
+    is(gWatch.getItemAtIndex(aIndex).attachment.initialExpression, "",
+      "The initial expression at index " + aIndex + " should be correct (1).");
     is(gWatch.getItemForElement(element).attachment.initialExpression, "",
-      "The initial expression at index " + index + " should be correct (2)");
+      "The initial expression at index " + aIndex + " should be correct (2).");
 
-    is(gWatch.getItemAtIndex(index).attachment.currentExpression, string,
-      "The expression at index " + index + " should be correct (1)");
-    is(gWatch.getItemForElement(element).attachment.currentExpression, string,
-      "The expression at index " + index + " should be correct (2)");
+    is(gWatch.getItemAtIndex(aIndex).attachment.currentExpression, aString,
+      "The expression at index " + aIndex + " should be correct (1).");
+    is(gWatch.getItemForElement(element).attachment.currentExpression, aString,
+      "The expression at index " + aIndex + " should be correct (2).");
 
-    is(gWatch.getString(index), string,
-      "The expression at index " + index + " should be correct (3)");
-    is(gWatch.getAllStrings()[index], string,
-      "The expression at index " + index + " should be correct (4)");
+    is(gWatch.getString(aIndex), aString,
+      "The expression at index " + aIndex + " should be correct (3).");
+    is(gWatch.getAllStrings()[aIndex], aString,
+      "The expression at index " + aIndex + " should be correct (4).");
   }
 
-  function addAndCheckExpressions(total, index, string, noBlur) {
-    gWatch.addExpression(string);
+  function addAndCheckExpressions(aTotal, aIndex, aString, noBlur) {
+    gWatch.addExpression(aString);
 
-    is(gWatch.getAllStrings().length, total,
-      "There should be " + total + " watch expressions available (1)");
-    is(gWatch.itemCount, total,
-      "There should be " + total + " watch expressions available (2)");
+    is(gWatch.getAllStrings().length, aTotal,
+      "There should be " + aTotal + " watch expressions available (1).");
+    is(gWatch.itemCount, aTotal,
+      "There should be " + aTotal + " watch expressions available (2).");
 
-    ok(gWatch.getItemAtIndex(index),
-      "The expression at index " + index + " should be available");
-    is(gWatch.getItemAtIndex(index).attachment.initialExpression, string,
-      "The expression at index " + index + " should have an initial expression");
+    ok(gWatch.getItemAtIndex(aIndex),
+      "The expression at index " + aIndex + " should be available.");
+    is(gWatch.getItemAtIndex(aIndex).attachment.initialExpression, aString,
+      "The expression at index " + aIndex + " should have an initial expression.");
 
-    let element = gWatch.getItemAtIndex(index).target;
+    let element = gWatch.getItemAtIndex(aIndex).target;
 
     ok(element,
-      "There should be a new expression item in the view");
+      "There should be a new expression item in the view.");
     ok(gWatch.getItemForElement(element),
-      "The watch expression item should be accessible");
-    is(gWatch.getItemForElement(element), gWatch.getItemAtIndex(index),
-      "The correct watch expression item was accessed");
+      "The watch expression item should be accessible.");
+    is(gWatch.getItemForElement(element), gWatch.getItemAtIndex(aIndex),
+      "The correct watch expression item was accessed.");
 
-    ok(gWatch.widget.getItemAtIndex(index) instanceof XULElement,
-      "The correct watch expression element was accessed (1)");
-    is(element, gWatch.widget.getItemAtIndex(index),
-      "The correct watch expression element was accessed (2)");
+    ok(gWatch.widget.getItemAtIndex(aIndex) instanceof XULElement,
+      "The correct watch expression element was accessed (1).");
+    is(element, gWatch.widget.getItemAtIndex(aIndex),
+      "The correct watch expression element was accessed (2).");
 
     is(gWatch.getItemForElement(element).attachment.arrowNode.hidden, false,
-      "The arrow node should be visible");
+      "The arrow node should be visible.");
     is(gWatch.getItemForElement(element).attachment.closeNode.hidden, false,
-      "The close button should be visible");
+      "The close button should be visible.");
     is(gWatch.getItemForElement(element).attachment.inputNode.getAttribute("focused"), "true",
-      "The textbox input should be focused");
+      "The textbox input should be focused.");
 
-    is(gDebugger.DebuggerView.Variables.parentNode.scrollTop, 0,
+    is(gVariables.parentNode.scrollTop, 0,
       "The variables view should be scrolled to top");
 
-    is(gWatch.orderedItems[0], gWatch.getItemAtIndex(index),
-      "The correct watch expression was added to the cache (1)");
-    is(gWatch.orderedItems[0], gWatch.getItemForElement(element),
-      "The correct watch expression was added to the cache (2)");
+    is(gWatch.items[0], gWatch.getItemAtIndex(aIndex),
+      "The correct watch expression was added to the cache (1).");
+    is(gWatch.items[0], gWatch.getItemForElement(element),
+      "The correct watch expression was added to the cache (2).");
 
     if (!noBlur) {
-      gDebugger.editor.focus();
+      gEditor.focus();
 
-      is(gWatch.getItemAtIndex(index).attachment.initialExpression, string,
-        "The initial expression at index " + index + " should be correct (1)");
-      is(gWatch.getItemForElement(element).attachment.initialExpression, string,
-        "The initial expression at index " + index + " should be correct (2)");
+      is(gWatch.getItemAtIndex(aIndex).attachment.initialExpression, aString,
+        "The initial expression at index " + aIndex + " should be correct (1).");
+      is(gWatch.getItemForElement(element).attachment.initialExpression, aString,
+        "The initial expression at index " + aIndex + " should be correct (2).");
 
-      is(gWatch.getItemAtIndex(index).attachment.currentExpression, string,
-        "The expression at index " + index + " should be correct (1)");
-      is(gWatch.getItemForElement(element).attachment.currentExpression, string,
-        "The expression at index " + index + " should be correct (2)");
+      is(gWatch.getItemAtIndex(aIndex).attachment.currentExpression, aString,
+        "The expression at index " + aIndex + " should be correct (1).");
+      is(gWatch.getItemForElement(element).attachment.currentExpression, aString,
+        "The expression at index " + aIndex + " should be correct (2).");
 
-      is(gWatch.getString(index), string,
-        "The expression at index " + index + " should be correct (3)");
-      is(gWatch.getAllStrings()[index], string,
-        "The expression at index " + index + " should be correct (4)");
+      is(gWatch.getString(aIndex), aString,
+        "The expression at index " + aIndex + " should be correct (3).");
+      is(gWatch.getAllStrings()[aIndex], aString,
+        "The expression at index " + aIndex + " should be correct (4).");
     }
   }
 
-  function removeAndCheckExpression(total, index, string) {
-    gWatch.removeAt(index);
-
-    is(gWatch.getAllStrings().length, total,
-      "There should be " + total + " watch expressions available (1)");
-    is(gWatch.itemCount, total,
-      "There should be " + total + " watch expressions available (2)");
+  function removeAndCheckExpression(aTotal, aIndex, aString) {
+    gWatch.removeAt(aIndex);
 
-    ok(gWatch.getItemAtIndex(index),
-      "The expression at index " + index + " should still be available");
-    is(gWatch.getItemAtIndex(index).attachment.initialExpression, string,
-      "The expression at index " + index + " should still have an initial expression");
+    is(gWatch.getAllStrings().length, aTotal,
+      "There should be " + aTotal + " watch expressions available (1).");
+    is(gWatch.itemCount, aTotal,
+      "There should be " + aTotal + " watch expressions available (2).");
 
-    let element = gWatch.getItemAtIndex(index).target;
+    ok(gWatch.getItemAtIndex(aIndex),
+      "The expression at index " + aIndex + " should still be available.");
+    is(gWatch.getItemAtIndex(aIndex).attachment.initialExpression, aString,
+      "The expression at index " + aIndex + " should still have an initial expression.");
 
-    is(gWatch.getItemAtIndex(index).attachment.initialExpression, string,
-      "The initial expression at index " + index + " should be correct (1)");
-    is(gWatch.getItemForElement(element).attachment.initialExpression, string,
-      "The initial expression at index " + index + " should be correct (2)");
+    let element = gWatch.getItemAtIndex(aIndex).target;
 
-    is(gWatch.getItemAtIndex(index).attachment.currentExpression, string,
-      "The expression at index " + index + " should be correct (1)");
-    is(gWatch.getItemForElement(element).attachment.currentExpression, string,
-      "The expression at index " + index + " should be correct (2)");
+    is(gWatch.getItemAtIndex(aIndex).attachment.initialExpression, aString,
+      "The initial expression at index " + aIndex + " should be correct (1).");
+    is(gWatch.getItemForElement(element).attachment.initialExpression, aString,
+      "The initial expression at index " + aIndex + " should be correct (2).");
 
-    is(gWatch.getString(index), string,
-      "The expression at index " + index + " should be correct (3)");
-    is(gWatch.getAllStrings()[index], string,
-      "The expression at index " + index + " should be correct (4)");
+    is(gWatch.getItemAtIndex(aIndex).attachment.currentExpression, aString,
+      "The expression at index " + aIndex + " should be correct (1).");
+    is(gWatch.getItemForElement(element).attachment.currentExpression, aString,
+      "The expression at index " + aIndex + " should be correct (2).");
+
+    is(gWatch.getString(aIndex), aString,
+      "The expression at index " + aIndex + " should be correct (3).");
+    is(gWatch.getAllStrings()[aIndex], aString,
+      "The expression at index " + aIndex + " should be correct (4).");
   }
-
-  registerCleanupFunction(function() {
-    removeTab(gTab);
-    gPane = null;
-    gTab = null;
-    gDebuggee = null;
-    gDebugger = null;
-    gWatch = null;
-  });
 }
rename from browser/devtools/debugger/test/browser_dbg_bug727429_watch-expressions-02.js
rename to browser/devtools/debugger/test/browser_dbg_watch-expressions-02.js
--- a/browser/devtools/debugger/test/browser_dbg_bug727429_watch-expressions-02.js
+++ b/browser/devtools/debugger/test/browser_dbg_watch-expressions-02.js
@@ -1,41 +1,46 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
- * Bug 727429: test the debugger watch expressions.
+ * Bug 727429: Test the debugger watch expressions.
  */
 
-const TAB_URL = EXAMPLE_URL + "browser_dbg_watch-expressions.html";
+const TAB_URL = EXAMPLE_URL + "doc_watch-expressions.html";
 
-let gPane = null;
-let gTab = null;
-let gDebuggee = null;
-let gDebugger = null;
-let gWatch = null;
-let gVars = null;
+function test() {
+  // Debug test slaves are a bit slow at this test.
+  requestLongerTimeout(2);
 
-function test()
-{
-  debug_tab_pane(TAB_URL, function(aTab, aDebuggee, aPane) {
+  let gTab, gDebuggee, gPanel, gDebugger;
+  let gEditor, gWatch, gVariables;
+
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
     gTab = aTab;
     gDebuggee = aDebuggee;
-    gPane = aPane;
-    gDebugger = gPane.panelWin;
+    gPanel = aPanel;
+    gDebugger = gPanel.panelWin;
+    gEditor = gDebugger.DebuggerView.editor;
     gWatch = gDebugger.DebuggerView.WatchExpressions;
-    gVars = gDebugger.DebuggerView.Variables;
+    gVariables = gDebugger.DebuggerView.Variables;
 
     gDebugger.DebuggerView.toggleInstrumentsPane({ visible: true, animated: false });
-    addExpressions();
-    performTest();
+
+    waitForSourceShown(gPanel, ".html", 1)
+      .then(() => addExpressions())
+      .then(() => performTest())
+      .then(() => finishTest())
+      .then(() => closeDebuggerAndFinish(gPanel))
+      .then(null, aError => {
+        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+      });
   });
 
-  function addExpressions()
-  {
+  function addExpressions() {
     gWatch.addExpression("'a'");
     gWatch.addExpression("\"a\"");
     gWatch.addExpression("'a\"\"'");
     gWatch.addExpression("\"a''\"");
     gWatch.addExpression("?");
     gWatch.addExpression("a");
     gWatch.addExpression("this");
     gWatch.addExpression("this.canada");
@@ -55,219 +60,203 @@ function test()
     gWatch.addExpression("({}).foo()");
     gWatch.addExpression("new Array(-1)");
     gWatch.addExpression("4.2.toExponential(-4.2)");
     gWatch.addExpression("throw new Error(\"bazinga\")");
     gWatch.addExpression("({ get error() { throw new Error(\"bazinga\") } }).error");
     gWatch.addExpression("throw { get name() { throw \"bazinga\" } }");
   }
 
-  function performTest()
-  {
-    is(gWatch.widget._parent.querySelectorAll(".dbg-expression[hidden=true]").length, 0,
+  function performTest() {
+    let deferred = promise.defer();
+
+    is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 0,
       "There should be 0 hidden nodes in the watch expressions container");
-    is(gWatch.widget._parent.querySelectorAll(".dbg-expression:not([hidden=true])").length, 27,
+    is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 27,
       "There should be 27 visible nodes in the watch expressions container");
 
     test1(function() {
       test2(function() {
         test3(function() {
           test4(function() {
             test5(function() {
               test6(function() {
                 test7(function() {
                   test8(function() {
                     test9(function() {
-                      finishTest();
+                      deferred.resolve();
                     });
                   });
                 });
               });
             });
           });
         });
       });
     });
+
+    return deferred.promise;
   }
 
-  function finishTest()
-  {
-    is(gWatch.widget._parent.querySelectorAll(".dbg-expression[hidden=true]").length, 0,
+  function finishTest() {
+    is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, 0,
       "There should be 0 hidden nodes in the watch expressions container");
-    is(gWatch.widget._parent.querySelectorAll(".dbg-expression:not([hidden=true])").length, 27,
+    is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 27,
       "There should be 27 visible nodes in the watch expressions container");
-
-    closeDebuggerAndFinish();
   }
 
-  function test1(callback) {
-    waitForWatchExpressions(function() {
-      info("Performing test1");
-      checkWatchExpressions("ReferenceError: a is not defined",
-                            { type: "object", class: "Object" },
-                            { type: "object", class: "String" },
-                            { type: "undefined" },
-                            26);
-      callback();
+  function test1(aCallback) {
+    gDebugger.once(gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS, () => {
+      checkWatchExpressions(26, {
+        a: "ReferenceError: a is not defined",
+        this: { type: "object", class: "Object" },
+        prop: { type: "object", class: "String" },
+        args: { type: "undefined" }
+      });
+      aCallback();
     });
-    executeSoon(function() {
-      gDebuggee.test(); // ermahgerd!!
-    });
+
+    gDebuggee.test();
   }
 
-  function test2(callback) {
-    waitForWatchExpressions(function() {
-      info("Performing test2");
-      checkWatchExpressions({ type: "undefined" },
-                            { type: "object", class: "Window" },
-                            { type: "undefined" },
-                            "sensational",
-                            26);
-      callback();
+  function test2(aCallback) {
+    gDebugger.once(gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS, () => {
+      checkWatchExpressions(26, {
+        a: { type: "undefined" },
+        this: { type: "object", class: "Window" },
+        prop: { type: "undefined" },
+        args: "sensational"
+      });
+      aCallback();
     });
+
     EventUtils.sendMouseEvent({ type: "mousedown" },
       gDebugger.document.getElementById("resume"),
       gDebugger);
   }
 
-  function test3(callback) {
-    waitForWatchExpressions(function() {
-      info("Performing test3");
-      checkWatchExpressions({ type: "object", class: "Object" },
-                            { type: "object", class: "Window" },
-                            { type: "undefined" },
-                            "sensational",
-                            26);
-      callback();
+  function test3(aCallback) {
+    gDebugger.once(gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS, () => {
+      checkWatchExpressions(26, {
+        a: { type: "object", class: "Object" },
+        this: { type: "object", class: "Window" },
+        prop: { type: "undefined" },
+        args: "sensational"
+      });
+      aCallback();
     });
+
     EventUtils.sendMouseEvent({ type: "mousedown" },
       gDebugger.document.getElementById("resume"),
       gDebugger);
   }
 
-  function test4(callback) {
-    waitForWatchExpressions(function() {
-      info("Performing test4");
-      checkWatchExpressions(5,
-                            { type: "object", class: "Window" },
-                            { type: "undefined" },
-                            "sensational",
-                            27);
-      callback();
+  function test4(aCallback) {
+    gDebugger.once(gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS, () => {
+      checkWatchExpressions(27, {
+        a: 5,
+        this: { type: "object", class: "Window" },
+        prop: { type: "undefined" },
+        args: "sensational"
+      });
+      aCallback();
     });
-    executeSoon(function() {
-      gWatch.addExpression("a = 5");
-      EventUtils.sendKey("RETURN", gDebugger);
-    });
+
+    gWatch.addExpression("a = 5");
+    EventUtils.sendKey("RETURN", gDebugger);
   }
 
-  function test5(callback) {
-    waitForWatchExpressions(function() {
-      info("Performing test5");
-      checkWatchExpressions(5,
-                            { type: "object", class: "Window" },
-                            { type: "undefined" },
-                            "sensational",
-                            27);
-      callback();
+  function test5(aCallback) {
+    gDebugger.once(gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS, () => {
+      checkWatchExpressions(27, {
+        a: 5,
+        this: { type: "object", class: "Window" },
+        prop: { type: "undefined" },
+        args: "sensational"
+      });
+      aCallback();
     });
-    executeSoon(function() {
-      gWatch.addExpression("encodeURI(\"\\\")");
-      EventUtils.sendKey("RETURN", gDebugger);
-    });
+
+    gWatch.addExpression("encodeURI(\"\\\")");
+    EventUtils.sendKey("RETURN", gDebugger);
   }
 
-  function test6(callback) {
-    waitForWatchExpressions(function() {
-      info("Performing test6");
-      checkWatchExpressions(5,
-                            { type: "object", class: "Window" },
-                            { type: "undefined" },
-                            "sensational",
-                            27);
-      callback();
+  function test6(aCallback) {
+    gDebugger.once(gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS, () => {
+      checkWatchExpressions(27, {
+        a: 5,
+        this: { type: "object", class: "Window" },
+        prop: { type: "undefined" },
+        args: "sensational"
+      });
+      aCallback();
     })
-    executeSoon(function() {
-      gWatch.addExpression("decodeURI(\"\\\")");
-      EventUtils.sendKey("RETURN", gDebugger);
-    });
+
+    gWatch.addExpression("decodeURI(\"\\\")");
+    EventUtils.sendKey("RETURN", gDebugger);
   }
 
-  function test7(callback) {
-    waitForWatchExpressions(function() {
-      info("Performing test7");
-      checkWatchExpressions(5,
-                            { type: "object", class: "Window" },
-                            { type: "undefined" },
-                            "sensational",
-                            27);
-      callback();
+  function test7(aCallback) {
+    gDebugger.once(gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS, () => {
+      checkWatchExpressions(27, {
+        a: 5,
+        this: { type: "object", class: "Window" },
+        prop: { type: "undefined" },
+        args: "sensational"
+      });
+      aCallback();
     });
-    executeSoon(function() {
-      gWatch.addExpression("?");
-      EventUtils.sendKey("RETURN", gDebugger);
-    });
+
+    gWatch.addExpression("?");
+    EventUtils.sendKey("RETURN", gDebugger);
   }
 
-  function test8(callback) {
-    waitForWatchExpressions(function() {
-      info("Performing test8");
-      checkWatchExpressions(5,
-                            { type: "object", class: "Window" },
-                            { type: "undefined" },
-                            "sensational",
-                            27);
-      callback();
+  function test8(aCallback) {
+    gDebugger.once(gDebugger.EVENTS.FETCHED_WATCH_EXPRESSIONS, () => {
+      checkWatchExpressions(27, {
+        a: 5,
+        this: { type: "object", class: "Window" },
+        prop: { type: "undefined" },
+        args: "sensational"
+      });
+      aCallback();
     });
-    executeSoon(function() {
-      gWatch.addExpression("a");
-      EventUtils.sendKey("RETURN", gDebugger);
-    });
+
+    gWatch.addExpression("a");
+    EventUtils.sendKey("RETURN", gDebugger);
   }
 
-  function test9(callback) {
-    waitForAfterFramesCleared(function() {
-      info("Performing test9");
-      callback();
+  function test9(aCallback) {
+    gDebugger.once(gDebugger.EVENTS.AFTER_FRAMES_CLEARED, () => {
+      aCallback();
     });
+
     EventUtils.sendMouseEvent({ type: "mousedown" },
       gDebugger.document.getElementById("resume"),
       gDebugger);
   }
 
-  function waitForAfterFramesCleared(callback) {
-    gDebugger.addEventListener("Debugger:AfterFramesCleared", function onClear() {
-      gDebugger.removeEventListener("Debugger:AfterFramesCleared", onClear, false);
-      executeSoon(callback);
-    }, false);
-  }
+  function checkWatchExpressions(aTotal, aExpectedExpressions) {
+    let {
+      a: expected_a,
+      this: expected_this,
+      prop: expected_prop,
+      args: expected_args
+    } = aExpectedExpressions;
 
-  function waitForWatchExpressions(callback) {
-    gDebugger.addEventListener("Debugger:FetchedWatchExpressions", function onFetch() {
-      gDebugger.removeEventListener("Debugger:FetchedWatchExpressions", onFetch, false);
-      executeSoon(callback);
-    }, false);
-  }
-
-  function checkWatchExpressions(expected_a,
-                                 expected_this,
-                                 expected_prop,
-                                 expected_arguments,
-                                 total)
-  {
-    is(gWatch.widget._parent.querySelectorAll(".dbg-expression[hidden=true]").length, total,
-      "There should be " + total + " hidden nodes in the watch expressions container");
-    is(gWatch.widget._parent.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
-      "There should be 0 visible nodes in the watch expressions container");
+    is(gDebugger.document.querySelectorAll(".dbg-expression[hidden=true]").length, aTotal,
+      "There should be " + aTotal + " hidden nodes in the watch expressions container.");
+    is(gDebugger.document.querySelectorAll(".dbg-expression:not([hidden=true])").length, 0,
+      "There should be 0 visible nodes in the watch expressions container.");
 
     let label = gDebugger.L10N.getStr("watchExpressionsScopeLabel");
-    let scope = gVars._currHierarchy.get(label);
+    let scope = gVariables._currHierarchy.get(label);
 
-    ok(scope, "There should be a wach expressions scope in the variables view");
-    is(scope._store.size, total, "There should be " + total + " evaluations availalble");
+    ok(scope, "There should be a wach expressions scope in the variables view.");
+    is(scope._store.size, aTotal, "There should be " + aTotal + " evaluations availalble.");
 
     let w1 = scope.get("'a'");
     let w2 = scope.get("\"a\"");
     let w3 = scope.get("'a\"\"'");
     let w4 = scope.get("\"a''\"");
     let w5 = scope.get("?");
     let w6 = scope.get("a");
     let w7 = scope.get("this");
@@ -287,108 +276,98 @@ function test()
     let w21 = scope.get("{}.foo()");
     let w22 = scope.get("({}).foo()");
     let w23 = scope.get("new Array(-1)");
     let w24 = scope.get("4.2.toExponential(-4.2)");
     let w25 = scope.get("throw new Error(\"bazinga\")");
     let w26 = scope.get("({ get error() { throw new Error(\"bazinga\") } }).error");
     let w27 = scope.get("throw { get name() { throw \"bazinga\" } }");
 
-    ok(w1, "The first watch expression should be present in the scope");
-    ok(w2, "The second watch expression should be present in the scope");
-    ok(w3, "The third watch expression should be present in the scope");
-    ok(w4, "The fourth watch expression should be present in the scope");
-    ok(w5, "The fifth watch expression should be present in the scope");
-    ok(w6, "The sixth watch expression should be present in the scope");
-    ok(w7, "The seventh watch expression should be present in the scope");
-    ok(w8, "The eight watch expression should be present in the scope");
-    ok(w9, "The ninth watch expression should be present in the scope");
-    ok(w10, "The tenth watch expression should be present in the scope");
-    ok(w11, "The eleventh watch expression should be present in the scope");
-    ok(w12, "The twelfth watch expression should be present in the scope");
-    ok(w13, "The 13th watch expression should be present in the scope");
-    ok(w14, "The 14th watch expression should be present in the scope");
-    ok(w15, "The 15th watch expression should be present in the scope");
-    ok(w16, "The 16th watch expression should be present in the scope");
-    ok(w17, "The 17th watch expression should be present in the scope");
-    ok(w18, "The 18th watch expression should be present in the scope");
-    ok(w19, "The 19th watch expression should be present in the scope");
-    ok(w20, "The 20th watch expression should be present in the scope");
-    ok(w21, "The 21st watch expression should be present in the scope");
-    ok(w22, "The 22nd watch expression should be present in the scope");
-    ok(w23, "The 23nd watch expression should be present in the scope");
-    ok(w24, "The 24th watch expression should be present in the scope");
-    ok(w25, "The 25th watch expression should be present in the scope");
-    ok(w26, "The 26th watch expression should be present in the scope");
-    ok(!w27, "The 27th watch expression should not be present in the scope");
+    ok(w1, "The first watch expression should be present in the scope.");
+    ok(w2, "The second watch expression should be present in the scope.");
+    ok(w3, "The third watch expression should be present in the scope.");
+    ok(w4, "The fourth watch expression should be present in the scope.");
+    ok(w5, "The fifth watch expression should be present in the scope.");
+    ok(w6, "The sixth watch expression should be present in the scope.");
+    ok(w7, "The seventh watch expression should be present in the scope.");
+    ok(w8, "The eight watch expression should be present in the scope.");
+    ok(w9, "The ninth watch expression should be present in the scope.");
+    ok(w10, "The tenth watch expression should be present in the scope.");
+    ok(w11, "The eleventh watch expression should be present in the scope.");
+    ok(w12, "The twelfth watch expression should be present in the scope.");
+    ok(w13, "The 13th watch expression should be present in the scope.");
+    ok(w14, "The 14th watch expression should be present in the scope.");
+    ok(w15, "The 15th watch expression should be present in the scope.");
+    ok(w16, "The 16th watch expression should be present in the scope.");
+    ok(w17, "The 17th watch expression should be present in the scope.");
+    ok(w18, "The 18th watch expression should be present in the scope.");
+    ok(w19, "The 19th watch expression should be present in the scope.");
+    ok(w20, "The 20th watch expression should be present in the scope.");
+    ok(w21, "The 21st watch expression should be present in the scope.");
+    ok(w22, "The 22nd watch expression should be present in the scope.");
+    ok(w23, "The 23nd watch expression should be present in the scope.");
+    ok(w24, "The 24th watch expression should be present in the scope.");
+    ok(w25, "The 25th watch expression should be present in the scope.");
+    ok(w26, "The 26th watch expression should be present in the scope.");
+    ok(!w27, "The 27th watch expression should not be present in the scope.");
 
-    is(w1.value, "a", "The first value is correct");
-    is(w2.value, "a", "The second value is correct");
-    is(w3.value, "a\"\"", "The third value is correct");
-    is(w4.value, "a''", "The fourth value is correct");
-    is(w5.value, "SyntaxError: syntax error", "The fifth value is correct");
+    is(w1.value, "a", "The first value is correct.");
+    is(w2.value, "a", "The second value is correct.");
+    is(w3.value, "a\"\"", "The third value is correct.");
+    is(w4.value, "a''", "The fourth value is correct.");
+    is(w5.value, "SyntaxError: syntax error", "The fifth value is correct.");
 
     if (typeof expected_a == "object") {
-      is(w6.value.type, expected_a.type, "The sixth value type is correct");
-      is(w6.value.class, expected_a.class, "The sixth value class is correct");
+      is(w6.value.type, expected_a.type, "The sixth value type is correct.");
+      is(w6.value.class, expected_a.class, "The sixth value class is correct.");
     } else {
-      is(w6.value, expected_a, "The sixth value is correct");
+      is(w6.value, expected_a, "The sixth value is correct.");
     }
 
     if (typeof expected_this == "object") {
-      is(w7.value.type, expected_this.type, "The seventh value type is correct");
-      is(w7.value.class, expected_this.class, "The seventh value class is correct");
+      is(w7.value.type, expected_this.type, "The seventh value type is correct.");
+      is(w7.value.class, expected_this.class, "The seventh value class is correct.");
     } else {
-      is(w7.value, expected_this, "The seventh value is correct");
+      is(w7.value, expected_this, "The seventh value is correct.");
     }
 
     if (typeof expected_prop == "object") {
-      is(w8.value.type, expected_prop.type, "The eighth value type is correct");
-      is(w8.value.class, expected_prop.class, "The eighth value class is correct");
+      is(w8.value.type, expected_prop.type, "The eighth value type is correct.");
+      is(w8.value.class, expected_prop.class, "The eighth value class is correct.");
     } else {
-      is(w8.value, expected_prop, "The eighth value is correct");
-    }
-
-    is(w9.value.type, "object", "The ninth value type is correct");
-    is(w9.value.class, "Array", "The ninth value class is correct");
-    is(w10.value.type, "object", "The tenth value type is correct");
-    is(w10.value.class, "Array", "The tenth value class is correct");
-    is(w11.value, "4", "The eleventh value is correct");
-    is(w12.value.type, "object", "The eleventh value type is correct");
-    is(w12.value.class, "Array", "The twelfth value class is correct");
-    is(w13.value, false, "The 13th value is correct");
-
-    if (typeof expected_arguments == "object") {
-      is(w14.value.type, expected_arguments.type, "The 14th value type is correct");
-      is(w14.value.class, expected_arguments.class, "The 14th value class is correct");
-    } else {
-      is(w14.value, expected_arguments, "The 14th value is correct");
+      is(w8.value, expected_prop, "The eighth value is correct.");
     }
 
-    is(w15.value, "SyntaxError: unterminated string literal", "The 15th value is correct");
-    is(w16.value, "SyntaxError: unterminated string literal", "The 16th value is correct");
-    is(w17.value, "URIError: malformed URI sequence", "The 17th value is correct");
+    is(w9.value.type, "object", "The ninth value type is correct.");
+    is(w9.value.class, "Array", "The ninth value class is correct.");
+    is(w10.value.type, "object", "The tenth value type is correct.");
+    is(w10.value.class, "Array", "The tenth value class is correct.");
+    is(w11.value, "4", "The eleventh value is correct.");
+    is(w12.value.type, "object", "The eleventh value type is correct.");
+    is(w12.value.class, "Array", "The twelfth value class is correct.");
+    is(w13.value, false, "The 13th value is correct.");
 
-    is(w18.value.type, "undefined", "The 18th value type is correct");
-    is(w18.value.class, undefined, "The 18th value class is correct");
-
-    is(w19.value.type, "undefined", "The 19th value type is correct");
-    is(w19.value.class, undefined, "The 19th value class is correct");
+    if (typeof expected_args == "object") {
+      is(w14.value.type, expected_args.type, "The 14th value type is correct.");
+      is(w14.value.class, expected_args.class, "The 14th value class is correct.");
+    } else {
+      is(w14.value, expected_args, "The 14th value is correct.");
+    }
 
-    is(w20.value, "SyntaxError: syntax error", "The 20th value is correct");
-    is(w21.value, "SyntaxError: syntax error", "The 21th value is correct");
-    is(w22.value, "TypeError: (intermediate value).foo is not a function", "The 22th value is correct");
-    is(w23.value, "RangeError: invalid array length", "The 23th value is correct");
-    is(w24.value, "RangeError: precision -4 out of range", "The 24st value is correct");
-    is(w25.value, "Error: bazinga", "The 25nd value is correct");
-    is(w26.value, "Error: bazinga", "The 26rd value is correct");
-  }
+    is(w15.value, "SyntaxError: unterminated string literal", "The 15th value is correct.");
+    is(w16.value, "SyntaxError: unterminated string literal", "The 16th value is correct.");
+    is(w17.value, "URIError: malformed URI sequence", "The 17th value is correct.");
+
+    is(w18.value.type, "undefined", "The 18th value type is correct.");
+    is(w18.value.class, undefined, "The 18th value class is correct.");
+
+    is(w19.value.type, "undefined", "The 19th value type is correct.");
+    is(w19.value.class, undefined, "The 19th value class is correct.");
 
-  registerCleanupFunction(function() {
-    removeTab(gTab);
-    gPane = null;
-    gTab = null;
-    gDebuggee = null;
-    gDebugger = null;
-    gWatch = null;
-    gVars = null;
-  });
+    is(w20.value, "SyntaxError: syntax error", "The 20th value is correct.");
+    is(w21.value, "SyntaxError: syntax error", "The 21th value is correct.");
+    is(w22.value, "TypeError: (intermediate value).foo is not a function", "The 22th value is correct.");
+    is(w23.value, "RangeError: invalid array length", "The 23th value is correct.");
+    is(w24.value, "RangeError: precision -4 out of range", "The 24th value is correct.");
+    is(w25.value, "Error: bazinga", "The 25th value is correct.");
+    is(w26.value, "Error: bazinga", "The 26th value is correct.");
+  }
 }