Bug 1314057 - Remove unnecessary debugger pref declarations, fix browser_webconsole_object_inspector_while_debugging_and_inspecting test r=davidwalsh
authorDavid Walsh <dwalsh@mozilla.com>
Fri, 14 Sep 2018 21:12:34 -0500
changeset 436842 3bacabb319619d9127da0cc12711917d5edda27f
parent 436841 2ba943d7458dba6a080fe8e09654d03bcfb8d566
child 436843 a026c2283c4ea129fd158b2e7ffc9719133de652
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 unnecessary debugger pref declarations, fix browser_webconsole_object_inspector_while_debugging_and_inspecting test r=davidwalsh
devtools/client/debugger/new/test/mochitest/browser.ini
devtools/client/debugger/new/test/mochitest/helpers/context.js
devtools/client/webconsole/test/mochitest/browser.ini
devtools/client/webconsole/test/mochitest/browser_webconsole_location_debugger_link.js
devtools/client/webconsole/test/mochitest/browser_webconsole_object_inspector_while_debugging_and_inspecting.js
devtools/client/webconsole/test/mochitest/browser_webconsole_sourcemap_nosource.js
devtools/client/webconsole/test/mochitest/browser_webconsole_stacktrace_location_debugger_link.js
devtools/client/webconsole/test/mochitest/head.js
--- a/devtools/client/debugger/new/test/mochitest/browser.ini
+++ b/devtools/client/debugger/new/test/mochitest/browser.ini
@@ -1,15 +1,16 @@
 [DEFAULT]
 tags = devtools
 subsuite = devtools
 skip-if = (os == 'linux' && debug && bits == 32)
 support-files =
   head.js
   helpers.js
+  helpers/context.js
   !/devtools/client/shared/test/shared-head.js
   !/devtools/client/shared/test/telemetry-test-helpers.js
   ## START-SOURCEMAPPED-FIXTURES - Generated by examples/sourcemapped/build.js
   examples/sourcemapped/polyfill-bundle.js
   examples/sourcemapped/output/parcel/babel-bindings-with-flow.js
   examples/sourcemapped/output/parcel/babel-bindings-with-flow.map
   examples/sourcemapped/output/parcel/babel-classes.js
   examples/sourcemapped/output/parcel/babel-classes.map
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/helpers/context.js
@@ -0,0 +1,23 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Helper method to create a "dbg" context for other tools to use
+ */
+
+function createDebuggerContext(toolbox) {
+  const panel = toolbox.getPanel("jsdebugger");
+  const win = panel.panelWin;
+  const { store, client, selectors, actions } = panel.getVarsForTests();
+
+  return {
+    actions: actions,
+    selectors: selectors,
+    getState: store.getState,
+    store: store,
+    client: client,
+    toolbox: toolbox,
+    win: win,
+    panel: panel
+  };
+}
\ No newline at end of file
--- a/devtools/client/webconsole/test/mochitest/browser.ini
+++ b/devtools/client/webconsole/test/mochitest/browser.ini
@@ -151,16 +151,18 @@ support-files =
   test-trackingprotection-securityerrors.html
   test-webconsole-error-observer.html
   test-websocket.html
   test-websocket.js
   testscript.js
   !/devtools/client/netmonitor/test/sjs_cors-test-server.sjs
   !/image/test/mochitest/blue.png
   !/devtools/client/shared/test/shared-head.js
+  !/devtools/client/debugger/new/test/mochitest/helpers.js
+  !/devtools/client/debugger/new/test/mochitest/helpers/context.js
   !/devtools/client/shared/test/telemetry-test-helpers.js
   !/devtools/client/shared/test/test-actor.js
   !/devtools/client/shared/test/test-actor-registry.js
 
 [browser_console.js]
 [browser_console_clear_cache.js]
 [browser_console_clear_method.js]
 skip-if = true # Bug 1437843
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_location_debugger_link.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_location_debugger_link.js
@@ -14,19 +14,16 @@ const { PromiseTestUtils } = scopedCuImp
 PromiseTestUtils.whitelistRejectionsGlobally(/this\.worker is null/);
 
 requestLongerTimeout(2);
 
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "test/mochitest/test-location-debugger-link.html";
 
 add_task(async function() {
-  // Force the new debugger UI, in case this gets uplifted with the old
-  // debugger still turned on
-  await pushPref("devtools.debugger.new-debugger-frontend", true);
   await pushPref("devtools.webconsole.filter.error", true);
   await pushPref("devtools.webconsole.filter.log", true);
 
   // On e10s, the exception thrown in test-location-debugger-link-errors.js
   // is triggered in child process and is ignored by test harness
   if (!Services.appinfo.browserTabsRemoteAutostart) {
     expectUncaughtException();
   }
--- 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
@@ -7,29 +7,29 @@
 // page, and while the inspector is active. See bug 886137.
 
 "use strict";
 
 const TEST_URI = "https://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);
   const hud = await openNewTabAndConsole(TEST_URI);
 
   info("Switch to the debugger");
   await openDebugger();
 
   info("Switch to the inspector");
   const target = TargetFactory.forTab(gBrowser.selectedTab);
   await gDevTools.showToolbox(target, "inspector");
 
   info("Call firstCall() and wait for the debugger statement to be reached.");
-  await waitForFrameAdded();
+  const toolbox = gDevTools.getToolbox(target);
+  const dbg = createDebuggerContext(toolbox);
+  await pauseDebugger(dbg);
 
   info("Switch back to the console");
   await gDevTools.showToolbox(target, "webconsole");
 
   info("Test logging and inspecting objects while on a breakpoint.");
   const jsterm = hud.jsterm;
 
   const onMessage = waitForMessage(hud, '{ testProp2: "testValue2" }');
@@ -58,21 +58,15 @@ add_task(async function() {
   const oiNodes = oi.querySelectorAll(".node");
   is(oiNodes.length, 3, "There is the expected number of nodes in the tree");
 
   ok(oiNodes[0].textContent.includes(`{\u2026}`));
   ok(oiNodes[1].textContent.includes(`testProp2: "testValue2"`));
   ok(oiNodes[2].textContent.includes(`<prototype>: Object { \u2026 }`));
 });
 
-async function waitForFrameAdded() {
-  const target = TargetFactory.forTab(gBrowser.selectedTab);
-  const toolbox = gDevTools.getToolbox(target);
-  const thread = toolbox.threadClient;
-
-  info("Waiting for framesadded");
-  await new Promise(resolve => {
-    thread.addOneTimeListener("framesadded", resolve);
-    ContentTask.spawn(gBrowser.selectedBrowser, {}, async 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_sourcemap_nosource.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_sourcemap_nosource.js
@@ -20,19 +20,16 @@ const PAGE_URL = `data:text/html,
 
   <body>
     <script src="${JS_URL}"></script>
   </body>
 
 </html>`;
 
 add_task(async function() {
-  // Force the new debugger UI, in case this gets uplifted with the old
-  // debugger still turned on
-  await pushPref("devtools.debugger.new-debugger-frontend", true);
   await pushPref("devtools.source-map.client-service.enabled", true);
 
   const hud = await openNewTabAndConsole(PAGE_URL);
   const toolbox = hud.ui.consoleOutput.toolbox;
 
   info("Finding \"here\" message and waiting for source map to be applied");
   await waitFor(() => {
     const node = findMessage(hud, "here");
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_stacktrace_location_debugger_link.js
+++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_stacktrace_location_debugger_link.js
@@ -16,17 +16,16 @@ PromiseTestUtils.whitelistRejectionsGlob
 
 const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" +
                  "test/mochitest/" +
                  "test-stacktrace-location-debugger-link.html";
 
 add_task(async function() {
   Services.prefs.setBoolPref("devtools.webconsole.filter.log", true);
   registerCleanupFunction(async function() {
-    Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
     Services.prefs.clearUserPref("devtools.webconsole.filter.log");
   });
 
   const hud = await openNewTabAndConsole(TEST_URI);
   const target = TargetFactory.forTab(gBrowser.selectedTab);
   const toolbox = gDevTools.getToolbox(target);
 
   await testOpenInDebugger(hud, toolbox, "console.trace()");
--- a/devtools/client/webconsole/test/mochitest/head.js
+++ b/devtools/client/webconsole/test/mochitest/head.js
@@ -14,16 +14,22 @@ Services.scriptloader.loadSubScript(
 
 // shared-head.js handles imports, constants, and utility functions
 // Load the shared-head file first.
 /* import-globals-from ../../../shared/test/shared-head.js */
 Services.scriptloader.loadSubScript(
   "chrome://mochitests/content/browser/devtools/client/shared/test/shared-head.js",
   this);
 
+// Import helpers for the new debugger
+/* import-globals-from ../../../debugger/new/test/mochitest/helpers/context.js */
+Services.scriptloader.loadSubScript(
+  "chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/helpers/context.js",
+  this);
+
 var {HUDService} = require("devtools/client/webconsole/hudservice");
 var WCUL10n = require("devtools/client/webconsole/webconsole-l10n");
 const DOCS_GA_PARAMS = `?${new URLSearchParams({
   "utm_source": "mozilla",
   "utm_medium": "firefox-console-errors",
   "utm_campaign": "default"
 })}`;
 const STATUS_CODES_GA_PARAMS = `?${new URLSearchParams({
@@ -530,19 +536,27 @@ async function openDebugger(options = {}
       panel: toolbox.getCurrentPanel()
     };
   }
 
   toolbox = await gDevTools.showToolbox(target, "jsdebugger");
   const panel = toolbox.getCurrentPanel();
 
   // Do not clear VariableView lazily so it doesn't disturb test ending.
-  panel._view.Variables.lazyEmpty = false;
+  if (panel._view) {
+    panel._view.Variables.lazyEmpty = false;
+  }
 
-  await panel.panelWin.DebuggerController.waitForSourcesLoaded();
+  // Old debugger
+  if (panel.panelWin && panel.panelWin.DebuggerController) {
+    await panel.panelWin.DebuggerController.waitForSourcesLoaded();
+  } else {
+    // New debugger
+    await toolbox.threadClient.getSources();
+  }
   return {target, toolbox, panel};
 }
 
 async function openInspector(options = {}) {
   if (!options.tab) {
     options.tab = gBrowser.selectedTab;
   }