Bug 1314057 - Remove new-debugger-frontend usage from webconsole tests r=davidwalsh
authorDavid Walsh <dwalsh@mozilla.com>
Fri, 14 Sep 2018 10:47:49 -0500
changeset 436844 b69b81f1aaf5531b9b7dda6c74006e9e6c678c7d
parent 436843 a026c2283c4ea129fd158b2e7ffc9719133de652
child 436845 81865752a2f77ef0bdc3e79d05df71335a5430b7
push id34660
push userbtara@mozilla.com
push dateMon, 17 Sep 2018 21:58:52 +0000
treeherdermozilla-central@87a95e1b7ec6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidwalsh
bugs1314057
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1314057 - Remove new-debugger-frontend usage from webconsole tests r=davidwalsh
devtools/client/shared/view-source.js
devtools/client/webconsole/test/mochitest/browser.ini
devtools/client/webconsole/test/mochitest/browser_jsterm_autocomplete_in_debugger_stackframe.js
devtools/client/webconsole/test/mochitest/browser_webconsole_click_function_to_source.js
devtools/client/webconsole/test/mochitest/browser_webconsole_closure_inspection.js
devtools/client/webconsole/test/mochitest/browser_webconsole_eval_in_debugger_stackframe.js
devtools/client/webconsole/test/mochitest/browser_webconsole_eval_in_debugger_stackframe2.js
devtools/client/webconsole/test/mochitest/browser_webconsole_object_inspector_while_debugging_and_inspecting.js
devtools/client/webconsole/test/mochitest/browser_webconsole_optimized_out_vars.js
--- a/devtools/client/shared/view-source.js
+++ b/devtools/client/shared/view-source.js
@@ -1,17 +1,16 @@
 /* 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/. */
 
 "use strict";
 
 var Services = require("Services");
 var { gDevTools } = require("devtools/client/framework/devtools");
-var { getSourceText } = require("devtools/client/debugger/content/queries");
 
 /**
  * Tries to open a Stylesheet file in the Style Editor. If the file is not
  * found, it is opened in source view instead.
  * Returns a promise resolving to a boolean indicating whether or not
  * the source was able to be displayed in the StyleEditor, as the built-in
  * Firefox View Source is the fallback.
  *
@@ -46,83 +45,24 @@ exports.viewSourceInStyleEditor = async 
  * @param {string} sourceURL
  * @param {number} sourceLine
  * @param {string} [reason=unknown]
  *
  * @return {Promise<boolean>}
  */
 exports.viewSourceInDebugger = async function(toolbox, sourceURL, sourceLine,
                                               reason = "unknown") {
-  // If the Debugger was already open, switch to it and try to show the
-  // source immediately. Otherwise, initialize it and wait for the sources
-  // to be added first.
-  const debuggerAlreadyOpen = toolbox.getPanel("jsdebugger");
   const dbg = await toolbox.loadTool("jsdebugger");
-
-  // New debugger frontend
-  if (Services.prefs.getBoolPref("devtools.debugger.new-debugger-frontend")) {
-    const source = dbg.getSource(sourceURL);
-    if (source) {
-      await toolbox.selectTool("jsdebugger", reason);
-      dbg.selectSource(sourceURL, sourceLine);
-      return true;
-    }
-
-    exports.viewSource(toolbox, sourceURL, sourceLine);
-    return false;
-  }
-
-  const win = dbg.panelWin;
-
-  // Old debugger frontend
-  if (!debuggerAlreadyOpen) {
-    await win.DebuggerController.waitForSourcesLoaded();
-  }
-
-  const { DebuggerView } = win;
-  const { Sources } = DebuggerView;
-
-  const item = Sources.getItemForAttachment(a => a.source.url === sourceURL);
-  if (item) {
+  const source = dbg.getSource(sourceURL);
+  if (source) {
     await toolbox.selectTool("jsdebugger", reason);
-
-    // Determine if the source has already finished loading. There's two cases
-    // in which we need to wait for the source to be shown:
-    // 1) The requested source is not yet selected and will be shown once it is
-    //    selected and loaded
-    // 2) The requested source is selected BUT the source text is still loading.
-    const { actor } = item.attachment.source;
-    const state = win.DebuggerController.getState();
-
-    // (1) Is the source selected?
-    const selected = state.sources.selectedSource;
-    const isSelected = selected === actor;
-
-    // (2) Has the source text finished loading?
-    let isLoading = false;
-
-    // Only check if the source is loading when the source is already selected.
-    // If the source is not selected, we will select it below and the already
-    // pending load will be cancelled and this check is useless.
-    if (isSelected) {
-      const sourceTextInfo = getSourceText(state, selected);
-      isLoading = sourceTextInfo && sourceTextInfo.loading;
-    }
-
-    // Select the requested source
-    DebuggerView.setEditorLocation(actor, sourceLine, { noDebug: true });
-
-    // Wait for it to load
-    if (!isSelected || isLoading) {
-      await win.DebuggerController.waitForSourceShown(sourceURL);
-    }
+    dbg.selectSource(sourceURL, sourceLine);
     return true;
   }
 
-  // If not found, still attempt to open in View Source
   exports.viewSource(toolbox, sourceURL, sourceLine);
   return false;
 };
 
 /**
  * Tries to open a JavaScript file in the corresponding Scratchpad.
  *
  * @param {string} sourceURL
--- a/devtools/client/webconsole/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/test/mochitest/browser.ini
@@ -248,17 +248,16 @@ tags = mcb
 [browser_webconsole_cd_iframe.js]
 [browser_webconsole_certificate_messages.js]
 [browser_webconsole_clear_cache.js]
 [browser_webconsole_click_function_to_source.js]
 [browser_webconsole_clickable_urls.js]
 [browser_webconsole_close_unfocused_window.js]
 [browser_webconsole_closing_after_completion.js]
 [browser_webconsole_close_sidebar.js]
-[browser_webconsole_closure_inspection.js]
 skip-if = true # Bug 1405250
 [browser_webconsole_console_api_iframe.js]
 [browser_webconsole_console_dir.js]
 [browser_webconsole_console_dir_uninspectable.js]
 [browser_webconsole_console_error_expand_object.js]
 [browser_webconsole_console_group.js]
 [browser_webconsole_console_logging_workers_api.js]
 [browser_webconsole_console_table.js]
--- a/devtools/client/webconsole/test/mochitest/browser_jsterm_autocomplete_in_debugger_stackframe.js
+++ b/devtools/client/webconsole/test/mochitest/browser_jsterm_autocomplete_in_debugger_stackframe.js
@@ -3,32 +3,35 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that makes sure web console autocomplete happens in the user-selected
 // stackframe from the js debugger.
 
 "use strict";
 
+// Import helpers for the new debugger
+/* import-globals-from ../../../debugger/new/test/mochitest/helpers.js */
+Services.scriptloader.loadSubScript(
+  "chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/helpers.js",
+  this);
+
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "test/mochitest/test-autocomplete-in-stackframe.html";
 
 add_task(async function() {
   // Run test with legacy JsTerm
   await pushPref("devtools.webconsole.jsterm.codeMirror", false);
   await performTests();
   // And then run it with the CodeMirror-powered one.
   await pushPref("devtools.webconsole.jsterm.codeMirror", true);
   await performTests();
 });
 
 async function performTests() {
-  // Force the old debugger UI since it's directly used (see Bug 1301705)
-  await pushPref("devtools.debugger.new-debugger-frontend", false);
-
   const { jsterm } = await openNewTabAndConsole(TEST_URI);
   const {
     autocompletePopup: popup,
   } = jsterm;
 
   const target = TargetFactory.forTab(gBrowser.selectedTab);
   const toolbox = gDevTools.getToolbox(target);
 
@@ -55,34 +58,36 @@ async function performTests() {
     `"foo1Obj." gave the expected suggestions`);
 
   // Test if 'foo1Obj.prop2.' gives 'prop21'
   await jstermComplete("foo1Obj.prop2.");
   ok(getPopupLabels(popup).includes("prop21"),
     `"foo1Obj.prop2." gave the expected suggestions`);
 
   info("Opening Debugger");
-  const {panel} = await openDebugger();
+  await openDebugger();
+  const dbg = createDebuggerContext(toolbox);
 
   info("Waiting for pause");
-  const stackFrames = await pauseDebugger(panel);
+  await pauseDebugger(dbg);
+  const stackFrames = dbg.selectors.getCallStackFrames(dbg.getState());
 
   info("Opening Console again");
   await toolbox.selectTool("webconsole");
 
   // Test if 'foo' gives 'foo3' and 'foo1' but not 'foo2', since we are paused in
   // the `secondCall` function (called by `firstCall`, which we call in `pauseDebugger`).
   await jstermComplete("foo");
   is(getPopupLabels(popup).join("-"), "foo1-foo1Obj-foo3-foo3Obj",
     `"foo" gave the expected suggestions`);
 
   await openDebugger();
 
   // Select the frame for the `firstCall` function.
-  stackFrames.selectFrame(1);
+  await dbg.actions.selectFrame(stackFrames[1]);
 
   info("openConsole");
   await toolbox.selectTool("webconsole");
 
   // Test if 'foo' gives 'foo2' and 'foo1' but not 'foo3', since we are now in the
   // `firstCall` frame.
   await jstermComplete("foo");
   is(getPopupLabels(popup).join("-"), "foo1-foo1Obj-foo2-foo2Obj",
@@ -104,23 +109,15 @@ async function performTests() {
   await jstermComplete("foo2Obj[0].");
   is(getPopupLabels(popup).length, 0, "no items for foo2Obj[0]");
 }
 
 function getPopupLabels(popup) {
   return popup.getItems().map(item => item.label);
 }
 
-function pauseDebugger(debuggerPanel) {
-  const debuggerWin = debuggerPanel.panelWin;
-  const debuggerController = debuggerWin.DebuggerController;
-  const thread = debuggerController.activeThread;
-
-  return new Promise(resolve => {
-    thread.addOneTimeListener("framesadded", () =>
-      resolve(debuggerController.StackFrames));
-
-    info("firstCall()");
-    ContentTask.spawn(gBrowser.selectedBrowser, {}, function() {
-      content.wrappedJSObject.firstCall();
-    });
+async function pauseDebugger(dbg) {
+  info("Waiting for debugger to pause");
+  ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
+    content.wrappedJSObject.firstCall();
   });
+  await waitForPaused(dbg);
 }
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_click_function_to_source.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_click_function_to_source.js
@@ -2,45 +2,53 @@
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests that clicking on a function displays its source in the debugger. See Bug 1050691.
 
 "use strict";
 
+// Import helpers for the new debugger
+/* import-globals-from ../../../debugger/new/test/mochitest/helpers.js */
+Services.scriptloader.loadSubScript(
+  "chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/helpers.js",
+  this);
+
+requestLongerTimeout(5);
+
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "test/mochitest/" +
                  "test-click-function-to-source.html";
 
-// Force the old debugger UI since it's directly used (see Bug 1301705)
-pushPref("devtools.debugger.new-debugger-frontend", false);
+const TEST_SCRIPT_URI = "http://example.com/browser/devtools/client/webconsole/" +
+                 "test/mochitest/" +
+                 "test-click-function-to-source.js";
 
 add_task(async function() {
   const hud = await openNewTabAndConsole(TEST_URI);
 
   info("Open the Debugger panel.");
-  const {panel} = await openDebugger();
-  const panelWin = panel.panelWin;
+  await openDebugger();
 
   info("And right after come back to the Console panel.");
   await openConsole();
 
   info("Log a function");
   const onLoggedFunction = waitForMessage(hud, "function foo");
   ContentTask.spawn(gBrowser.selectedBrowser, {}, function() {
     content.wrappedJSObject.foo();
   });
   const {node} = await onLoggedFunction;
   const jumpIcon = node.querySelector(".jump-definition");
   ok(jumpIcon, "A jump to definition button is rendered, as expected");
 
   info("Click on the jump to definition button.");
-  const onEditorLocationSet = panelWin.once(panelWin.EVENTS.EDITOR_LOCATION_SET);
   jumpIcon.click();
-  await onEditorLocationSet;
 
-  const {editor} = panelWin.DebuggerView;
-  const {line, ch} = editor.getCursor();
-  // Source editor starts counting line and column numbers from 0.
-  is(line, 8, "Debugger is open at the expected line");
-  is(ch, 0, "Debugger is open at the expected character");
+  const toolbox = gDevTools.getToolbox(hud.target);
+  const dbg = createDebuggerContext(toolbox);
+  await waitForSelectedSource(dbg, TEST_SCRIPT_URI);
+
+  const pendingLocation = dbg.selectors.getPendingSelectedLocation(dbg.getState());
+  const {line} = pendingLocation;
+  is(line, 9, "Debugger is open at the expected line");
 });
deleted file mode 100644
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_closure_inspection.js
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
-/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// XXX Remove this when the file is migrated to the new frontend.
-/* eslint-disable no-undef */
-
-// Check that inspecting a closure in the variables view sidebar works when
-// execution is paused.
-
-"use strict";
-
-const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
-                 "test/mochitest/test-closures.html";
-
-var gWebConsole, gJSTerm, gVariablesView;
-
-// Force the old debugger UI since it's directly used (see Bug 1301705)
-Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
-registerCleanupFunction(function() {
-  Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
-});
-
-function test() {
-  registerCleanupFunction(() => {
-    gWebConsole = gJSTerm = gVariablesView = null;
-  });
-
-  function fetchScopes(hud, toolbox, panelWin, deferred) {
-    panelWin.once(panelWin.EVENTS.FETCHED_SCOPES, () => {
-      ok(true, "Scopes were fetched");
-      toolbox.selectTool("webconsole").then(() => consoleOpened(hud));
-      deferred.resolve();
-    });
-  }
-
-  loadTab(TEST_URI).then(() => {
-    openConsole().then((hud) => {
-      openDebugger().then(({ toolbox, panelWin }) => {
-        const deferred = defer();
-        fetchScopes(hud, toolbox, panelWin, deferred);
-
-        // eslint-disable-next-line
-        ContentTask.spawn(gBrowser.selectedBrowser, {}, () => {
-          const button = content.document.querySelector("button");
-          ok(button, "button element found");
-          button.click();
-        });
-
-        return deferred.promise;
-      });
-    });
-  });
-}
-
-function consoleOpened(hud) {
-  gWebConsole = hud;
-  gJSTerm = hud.jsterm;
-  gJSTerm.execute("window.george.getName");
-
-  waitForMessages({
-    webconsole: gWebConsole,
-    messages: [{
-      text: "getName()",
-      category: CATEGORY_OUTPUT,
-      objects: true,
-    }],
-  }).then(onExecuteGetName);
-}
-
-function onExecuteGetName(results) {
-  const clickable = results[0].clickableElements[0];
-  ok(clickable, "clickable object found");
-
-  gJSTerm.once("variablesview-fetched", onGetNameFetch);
-  const contextMenu =
-      gWebConsole.iframeWindow.document.getElementById("output-contextmenu");
-  waitForContextMenu(contextMenu, clickable, () => {
-    const openInVarView = contextMenu.querySelector("#menu_openInVarView");
-    ok(openInVarView.disabled === false,
-       "the \"Open In Variables View\" context menu item should be clickable");
-    // EventUtils.synthesizeMouseAtCenter seems to fail here in Mac OSX
-    openInVarView.click();
-  });
-}
-
-function onGetNameFetch(view) {
-  gVariablesView = view._variablesView;
-  ok(gVariablesView, "variables view object");
-
-  findVariableViewProperties(view, [
-    { name: /_pfactory/, value: "" },
-  ], { webconsole: gWebConsole }).then(onExpandClosure);
-}
-
-function onExpandClosure(results) {
-  const prop = results[0].matchedProp;
-  ok(prop, "matched the name property in the variables view");
-
-  gVariablesView.window.focus();
-  gJSTerm.once("sidebar-closed", finishTest);
-  EventUtils.synthesizeKey("VK_ESCAPE", {}, gVariablesView.window);
-}
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_eval_in_debugger_stackframe.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_eval_in_debugger_stackframe.js
@@ -3,23 +3,26 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that makes sure web console eval happens in the user-selected stackframe
 // from the js debugger.
 
 "use strict";
 
+// Import helpers for the new debugger
+/* import-globals-from ../../../debugger/new/test/mochitest/helpers.js */
+Services.scriptloader.loadSubScript(
+  "chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/helpers.js",
+  this);
+
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "test/mochitest/test-eval-in-stackframe.html";
 
 add_task(async function() {
-  // Force the old debugger UI since it's directly used (see Bug 1301705).
-  await pushPref("devtools.debugger.new-debugger-frontend", false);
-
   info("open the console");
   const hud = await openNewTabAndConsole(TEST_URI);
   const {jsterm} = hud;
 
   info("Check `foo` value");
   let onResultMessage = waitForMessage(hud, "globalFooBug783499");
   jsterm.execute("foo");
   await onResultMessage;
@@ -27,47 +30,46 @@ add_task(async function() {
 
   info("Assign and check `foo2` value");
   onResultMessage = waitForMessage(hud, "newFoo");
   jsterm.execute("foo2 = 'newFoo'; window.foo2");
   await onResultMessage;
   ok(true, "'newFoo' is displayed after adding `foo2`");
 
   info("Open the debugger and then select the console again");
-  const {panel} = await openDebugger();
-  const {activeThread, StackFrames: stackFrames} = panel.panelWin.DebuggerController;
+  await openDebugger();
+  const toolbox = gDevTools.getToolbox(hud.target);
+  const dbg = createDebuggerContext(toolbox);
 
   await openConsole();
 
   info("Check `foo + foo2` value");
   onResultMessage = waitForMessage(hud, "globalFooBug783499newFoo");
   jsterm.execute("foo + foo2");
   await onResultMessage;
 
   info("Select the debugger again");
   await openDebugger();
+  await pauseDebugger(dbg);
 
-  const onFirstCallFramesAdded = activeThread.addOneTimeListener("framesadded");
-  // firstCall calls secondCall, which has a debugger statement, so we'll be paused.
-  ContentTask.spawn(gBrowser.selectedBrowser, {}, function() {
-    content.wrappedJSObject.firstCall();
-  });
-  await onFirstCallFramesAdded;
+  const stackFrames = dbg.selectors.getCallStackFrames(dbg.getState());
 
   info("frames added, select the console again");
   await openConsole();
 
   info("Check `foo + foo2` value when paused");
   onResultMessage = waitForMessage(hud, "globalFooBug783499foo2SecondCall");
   jsterm.execute("foo + foo2");
   ok(true, "`foo + foo2` from `secondCall()`");
 
   info("select the debugger and select the frame (1)");
   await openDebugger();
-  stackFrames.selectFrame(1);
+
+  await dbg.actions.selectFrame(stackFrames[1]);
+
   await openConsole();
 
   info("Check `foo + foo2 + foo3` value when paused on a given frame");
   onResultMessage = waitForMessage(hud, "fooFirstCallnewFoofoo3FirstCall");
   jsterm.execute("foo + foo2 + foo3");
   await onResultMessage;
   ok(true, "`foo + foo2 + foo3` from `firstCall()`");
 
@@ -77,8 +79,16 @@ add_task(async function() {
   ok(true, "`foo + foo3` updated in `firstCall()`");
 
   await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
     is(content.wrappedJSObject.foo, "globalFooBug783499", "`foo` in content window");
     is(content.wrappedJSObject.foo2, "newFoo", "`foo2` in content window");
     ok(!content.wrappedJSObject.foo3, "`foo3` was not added to the content window");
   });
 });
+
+async function pauseDebugger(dbg) {
+  info("Waiting for debugger to pause");
+  ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
+    content.wrappedJSObject.firstCall();
+  });
+  await waitForPaused(dbg);
+}
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_eval_in_debugger_stackframe2.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_eval_in_debugger_stackframe2.js
@@ -4,44 +4,48 @@
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test to make sure that web console commands can fire while paused at a
 // breakpoint that was triggered from a JS call.  Relies on asynchronous js
 // evaluation over the protocol - see Bug 1088861.
 
 "use strict";
 
+// Import helpers for the new debugger
+/* import-globals-from ../../../debugger/new/test/mochitest/helpers.js */
+Services.scriptloader.loadSubScript(
+  "chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/helpers.js",
+  this);
+
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "test/mochitest/test-eval-in-stackframe.html";
 
 add_task(async function() {
-  // Force the old debugger UI since it's directly used (see Bug 1301705).
-  await pushPref("devtools.debugger.new-debugger-frontend", false);
-
   info("open the console");
   const hud = await openNewTabAndConsole(TEST_URI);
   const {jsterm} = hud;
 
   info("open the debugger");
-  const {panel} = await openDebugger();
-  const {activeThread} = panel.panelWin.DebuggerController;
+  await openDebugger();
 
-  const onFirstCallFramesAdded = activeThread.addOneTimeListener("framesadded");
+  const toolbox = gDevTools.getToolbox(hud.target);
+  const dbg = createDebuggerContext(toolbox);
+
   // firstCall calls secondCall, which has a debugger statement, so we'll be paused.
   const onFirstCallMessageReceived = waitForMessage(hud, "undefined");
 
   const unresolvedSymbol = Symbol();
   let firstCallEvaluationResult = unresolvedSymbol;
   onFirstCallMessageReceived.then(message => {
     firstCallEvaluationResult = message;
   });
   jsterm.execute("firstCall()");
 
   info("Waiting for a frame to be added");
-  await onFirstCallFramesAdded;
+  await waitForPaused(dbg);
 
   info("frames added, select the console again");
   await openConsole();
 
   info("Executing basic command while paused");
   let onMessageReceived = waitForMessage(hud, "3");
   jsterm.execute("1 + 2");
   let message = await onMessageReceived;
@@ -52,14 +56,14 @@ add_task(async function() {
   jsterm.execute("foo + foo2");
   message = await onMessageReceived;
   ok(message, "`foo + foo2` was evaluated as expected with debugger paused");
 
   info("Checking the first command, which is the last to resolve since it paused");
   ok(firstCallEvaluationResult === unresolvedSymbol, "firstCall was not evaluated yet");
 
   info("Resuming the thread");
-  activeThread.resume();
+  dbg.actions.resume(dbg.getState());
 
   message = await onFirstCallMessageReceived;
   ok(firstCallEvaluationResult !== unresolvedSymbol,
     "firstCall() returned correct value");
 });
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_object_inspector_while_debugging_and_inspecting.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_object_inspector_while_debugging_and_inspecting.js
@@ -3,16 +3,22 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Test that makes sure web console eval works while the js debugger paused the
 // page, and while the inspector is active. See bug 886137.
 
 "use strict";
 
+// Import helpers for the new debugger
+/* import-globals-from ../../../debugger/new/test/mochitest/helpers.js */
+Services.scriptloader.loadSubScript(
+  "chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/helpers.js",
+  this);
+
 const TEST_URI = "https://example.com/browser/devtools/client/webconsole/" +
                  "test/mochitest/test-eval-in-stackframe.html";
 
 add_task(async function() {
   const hud = await openNewTabAndConsole(TEST_URI);
 
   info("Switch to the debugger");
   await openDebugger();
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_optimized_out_vars.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_optimized_out_vars.js
@@ -3,57 +3,61 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Check that inspecting an optimized out variable works when execution is
 // paused.
 
 "use strict";
 
+// Import helpers for the new debugger
+/* import-globals-from ../../../debugger/new/test/mochitest/helpers.js */
+Services.scriptloader.loadSubScript(
+    "chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/helpers.js",
+    this);
+
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "test/mochitest/" +
                  "test-closure-optimized-out.html";
 
 add_task(async function() {
-  // Force the old debugger UI since it's directly used (see Bug 1301705)
-  await pushPref("devtools.debugger.new-debugger-frontend", false);
-
   const hud = await openNewTabAndConsole(TEST_URI);
-  const { toolbox, panel: debuggerPanel } = await openDebugger();
+  await openDebugger();
 
-  const sources = debuggerPanel.panelWin.DebuggerView.Sources;
-  await debuggerPanel.addBreakpoint({ actor: sources.values[0], line: 18 });
-  await ensureThreadClientState(debuggerPanel, "resumed");
+  const toolbox = gDevTools.getToolbox(hud.target);
+  const dbg = createDebuggerContext(toolbox);
 
-  const { FETCHED_SCOPES } = debuggerPanel.panelWin.EVENTS;
-  const fetchedScopes = debuggerPanel.panelWin.once(FETCHED_SCOPES);
+  await addBreakpoint(dbg, "test-closure-optimized-out.html", 18);
+  await waitForThreadEvents(dbg, "resumed");
 
   // Cause the debuggee to pause
-  ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
-    const button = content.document.querySelector("button");
-    button.click();
-  });
-
-  await fetchedScopes;
-  ok(true, "Scopes were fetched");
+  await pauseDebugger(dbg);
 
   await toolbox.selectTool("webconsole");
 
   // This is the meat of the test: evaluate the optimized out variable.
   const onMessage = waitForMessage(hud, "optimized out");
   hud.jsterm.execute("upvar");
 
   info("Waiting for optimized out message");
   await onMessage;
 
   ok(true, "Optimized out message logged");
+
+  info("Open the debugger");
+  await openDebugger();
+
+  info("Resume");
+  await resume(dbg);
+
+  info("Remove the breakpoint");
+  const source = findSource(dbg, "test-closure-optimized-out.html");
+  await removeBreakpoint(dbg, source.id, 18);
 });
 
-// Debugger helper functions adapted from devtools/client/debugger/test/head.js.
-
-async function ensureThreadClientState(debuggerPanel, state) {
-  const thread = debuggerPanel.panelWin.gThreadClient;
-  info(`Thread is: '${thread.state}'.`);
-  if (thread.state != state) {
-    info("Waiting for thread event: '${state}'.");
-    await thread.addOneTimeListener(state);
-  }
+async function pauseDebugger(dbg) {
+  info("Waiting for debugger to pause");
+  ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() {
+    const button = content.document.querySelector("button");
+    button.click();
+  });
+  await waitForPaused(dbg);
 }