diff --git a/devtools/client/debugger/new/test/mochitest/browser.ini b/devtools/client/debugger/new/test/mochitest/browser.ini index 9e1cb2b39948..be0270051f77 100644 --- a/devtools/client/debugger/new/test/mochitest/browser.ini +++ b/devtools/client/debugger/new/test/mochitest/browser.ini @@ -5,6 +5,7 @@ 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 diff --git a/devtools/client/debugger/new/test/mochitest/helpers/context.js b/devtools/client/debugger/new/test/mochitest/helpers/context.js new file mode 100644 index 000000000000..d8af581c47f2 --- /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 diff --git a/devtools/client/webconsole/test/mochitest/browser.ini b/devtools/client/webconsole/test/mochitest/browser.ini index b43fea5aad4d..dbbc61907dd4 100644 --- a/devtools/client/webconsole/test/mochitest/browser.ini +++ b/devtools/client/webconsole/test/mochitest/browser.ini @@ -156,6 +156,8 @@ support-files = !/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 diff --git a/devtools/client/webconsole/test/mochitest/browser_webconsole_location_debugger_link.js b/devtools/client/webconsole/test/mochitest/browser_webconsole_location_debugger_link.js index 54efd21ad337..1a8da1b4dfd1 100644 --- a/devtools/client/webconsole/test/mochitest/browser_webconsole_location_debugger_link.js +++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_location_debugger_link.js @@ -19,9 +19,6 @@ 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); diff --git 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 index 3b8a7bb811d9..c22e2564e19c 100644 --- 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 @@ -12,8 +12,6 @@ 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"); @@ -24,7 +22,9 @@ add_task(async function() { 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"); @@ -63,16 +63,10 @@ add_task(async function() { ok(oiNodes[2].textContent.includes(`: 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); } diff --git a/devtools/client/webconsole/test/mochitest/browser_webconsole_sourcemap_nosource.js b/devtools/client/webconsole/test/mochitest/browser_webconsole_sourcemap_nosource.js index bbd4db30b28d..eb371e1e0c67 100644 --- a/devtools/client/webconsole/test/mochitest/browser_webconsole_sourcemap_nosource.js +++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_sourcemap_nosource.js @@ -25,9 +25,6 @@ const PAGE_URL = `data:text/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); diff --git 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 index 7ee7781af712..1f7c2c5c60b8 100644 --- 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 @@ -21,7 +21,6 @@ const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" + 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"); }); diff --git a/devtools/client/webconsole/test/mochitest/head.js b/devtools/client/webconsole/test/mochitest/head.js index 772fe18cf085..14e0754d4560 100644 --- a/devtools/client/webconsole/test/mochitest/head.js +++ b/devtools/client/webconsole/test/mochitest/head.js @@ -19,6 +19,12 @@ 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({ @@ -535,9 +541,17 @@ async function openDebugger(options = {}) { 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}; }