author | Bogdan Tara <btara@mozilla.com> |
Sat, 15 Sep 2018 03:30:07 +0300 | |
changeset 492254 | be14b8d9e4cc3acc1dc642115e818d6a806fd71f |
parent 492253 | 75f0a4384b0f31f7356d4bb92bb6429ba82d281f |
child 492255 | 67f6883be55ddf8601475b0b6278a54dd113753f |
push id | 9984 |
push user | ffxbld-merge |
push date | Mon, 15 Oct 2018 21:07:35 +0000 |
treeherder | mozilla-beta@183d27ea8570 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1314057 |
milestone | 64.0a1 |
backs out | 1d626fdff4f36e157c317791534b902771faa94d f992a076c6f2a0a834db2b217fd964cb9271fbbf b356beaa690fee6b93370b7b7261ef346a6d16c6 b797675da9c1787f0b4af6b0b7e4b8a1327fc242 f34f4f04848064f81c3b5ef59d3f88c4ff90e251 |
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
|
--- a/devtools/client/application/test/browser.ini +++ b/devtools/client/application/test/browser.ini @@ -7,17 +7,16 @@ support-files = service-workers/debug.html service-workers/dynamic-registration.html service-workers/empty.html service-workers/empty-sw.js service-workers/scope-page.html service-workers/simple.html service-workers/simple-unicode.html !/devtools/client/debugger/new/test/mochitest/helpers.js - !/devtools/client/debugger/new/test/mochitest/helpers/context.js !/devtools/client/shared/test/frame-script-utils.js !/devtools/client/shared/test/shared-head.js !/devtools/client/shared/test/telemetry-test-helpers.js [browser_application_panel_debug-service-worker.js] [browser_application_panel_list-domain-workers.js] [browser_application_panel_list-several-workers.js] [browser_application_panel_list-single-worker.js]
--- a/devtools/client/application/test/browser_application_panel_debug-service-worker.js +++ b/devtools/client/application/test/browser_application_panel_debug-service-worker.js @@ -3,21 +3,16 @@ "use strict"; /* 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); -/* 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); - const TAB_URL = URL_ROOT + "service-workers/debug.html"; add_task(async function() { await enableApplicationPanel(); const { panel, tab, target } = await openNewTabAndApplicationPanel(TAB_URL); const doc = panel.panelWin.document;
--- a/devtools/client/canvasdebugger/test/browser.ini +++ b/devtools/client/canvasdebugger/test/browser.ini @@ -12,17 +12,16 @@ support-files = doc_simple-canvas-transparent.html doc_webgl-bindings.html doc_webgl-enum.html doc_webgl-drawArrays.html doc_webgl-drawElements.html head.js !/devtools/client/shared/test/frame-script-utils.js !/devtools/client/shared/test/shared-head.js - !/devtools/client/debugger/new/test/mochitest/helpers/context.js !/devtools/client/shared/test/telemetry-test-helpers.js [browser_canvas-actor-test-01.js] [browser_canvas-actor-test-02.js] [browser_canvas-actor-test-03.js] [browser_canvas-actor-test-04.js] [browser_canvas-actor-test-05.js] [browser_canvas-actor-test-06.js]
--- a/devtools/client/canvasdebugger/test/browser_canvas-frontend-call-stack-01.js +++ b/devtools/client/canvasdebugger/test/browser_canvas-frontend-call-stack-01.js @@ -1,16 +1,20 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ /** * Tests if the a function call's stack is properly displayed in the UI. */ -requestLongerTimeout(2); +// 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"); +}); async function ifTestingSupported() { const { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_DEEP_STACK_URL); const { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin; await reload(target); const recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED); @@ -61,14 +65,18 @@ async function ifTestingSupported() { "doc_simple-canvas-deep-stack.html:35", "The fourth function on the stack has the correct location."); const jumpedToSource = once(window, EVENTS.SOURCE_SHOWN_IN_JS_DEBUGGER); EventUtils.sendMouseEvent({ type: "mousedown" }, $(".call-item-stack-fn-location", callItem.target)); await jumpedToSource; const toolbox = await gDevTools.getToolbox(target); - const dbg = createDebuggerContext(toolbox); - await validateDebuggerLocation(dbg, SIMPLE_CANVAS_DEEP_STACK_URL, 26); + const { panelWin: { DebuggerView: view } } = toolbox.getPanel("jsdebugger"); + + is(view.Sources.selectedValue, getSourceActor(view.Sources, SIMPLE_CANVAS_DEEP_STACK_URL), + "The expected source was shown in the debugger."); + is(view.editor.getCursor().line, 25, + "The expected source line is highlighted in the debugger."); await teardown(panel); finish(); }
--- a/devtools/client/canvasdebugger/test/browser_canvas-frontend-call-stack-02.js +++ b/devtools/client/canvasdebugger/test/browser_canvas-frontend-call-stack-02.js @@ -1,17 +1,21 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ /** * Tests if the a function call's stack is properly displayed in the UI * and jumping to source in the debugger for the topmost call item works. */ -requestLongerTimeout(2); +// 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"); +}); async function ifTestingSupported() { const { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_DEEP_STACK_URL); const { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin; await reload(target); const recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED); @@ -36,14 +40,18 @@ async function ifTestingSupported() { ok($all(".call-item-stack-fn", callItem.target).length >= 4, "There should be at least 4 functions on the stack for the draw call."); const jumpedToSource = once(window, EVENTS.SOURCE_SHOWN_IN_JS_DEBUGGER); EventUtils.sendMouseEvent({ type: "mousedown" }, $(".call-item-location", callItem.target)); await jumpedToSource; const toolbox = await gDevTools.getToolbox(target); - const dbg = createDebuggerContext(toolbox); - await validateDebuggerLocation(dbg, SIMPLE_CANVAS_DEEP_STACK_URL, 24); + const { panelWin: { DebuggerView: view } } = toolbox.getPanel("jsdebugger"); + + is(view.Sources.selectedValue, getSourceActor(view.Sources, SIMPLE_CANVAS_DEEP_STACK_URL), + "The expected source was shown in the debugger."); + is(view.editor.getCursor().line, 23, + "The expected source line is highlighted in the debugger."); await teardown(panel); finish(); }
--- a/devtools/client/canvasdebugger/test/head.js +++ b/devtools/client/canvasdebugger/test/head.js @@ -1,27 +1,21 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ /* eslint no-unused-vars: [2, {"vars": "local"}] */ /* import-globals-from ../../shared/test/shared-head.js */ -/* import-globals-from ../../debugger/new/test/mochitest/helpers/context.js */ "use strict"; // Load the shared-head file first. Services.scriptloader.loadSubScript( "chrome://mochitests/content/browser/devtools/client/shared/test/shared-head.js", this); -// Import helpers for the new debugger -Services.scriptloader.loadSubScript( - "chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/helpers/context.js", - this); - var { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator); var { DebuggerClient } = require("devtools/shared/client/debugger-client"); var { DebuggerServer } = require("devtools/server/main"); var { CallWatcherFront } = require("devtools/shared/fronts/call-watcher"); var { CanvasFront } = require("devtools/shared/fronts/canvas"); var { Toolbox } = require("devtools/client/framework/toolbox"); var { isWebGLSupported } = require("devtools/client/shared/webgl-utils"); @@ -174,18 +168,8 @@ function teardown({target}) { removeTab(tab); }); } function getSourceActor(aSources, aURL) { const item = aSources.getItemForAttachment(a => a.source.url === aURL); return item ? item.value : null; } - -async function validateDebuggerLocation(dbg, url, line) { - const location = dbg.selectors.getSelectedLocation(dbg.getState()); - const sourceUrl = dbg.selectors.getSelectedSource(dbg.getState()).url; - - is(sourceUrl, url, - "The expected source was shown in the debugger."); - is(location.line, line, - "The expected source line is highlighted in the debugger."); -}
--- a/devtools/client/debugger/new/test/mochitest/browser.ini +++ b/devtools/client/debugger/new/test/mochitest/browser.ini @@ -1,16 +1,15 @@ [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
--- a/devtools/client/debugger/new/test/mochitest/helpers.js +++ b/devtools/client/debugger/new/test/mochitest/helpers.js @@ -1,21 +1,16 @@ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ /** * Helper methods to drive with the debugger during mochitests. This file can be safely * required from other panel test files. */ -// Import helpers for the new debugger -Services.scriptloader.loadSubScript( - "chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/helpers/context.js", - this); - var { Toolbox } = require("devtools/client/framework/toolbox"); var { Task } = require("devtools/shared/task"); var asyncStorage = require("devtools/shared/async-storage"); const sourceUtils = { isLoaded: source => source.loadedState === "loaded" }; @@ -462,16 +457,33 @@ function isSelectedFrameSelected(dbg, st const isLoaded = source.loadedState && sourceUtils.isLoaded(source); if (!isLoaded) { return false; } return source.id == sourceId; } +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 + }; +} + /** * Clear all the debugger related preferences. */ function clearDebuggerPreferences() { asyncStorage.clear() Services.prefs.clearUserPref("devtools.recordreplay.enabled"); Services.prefs.clearUserPref("devtools.debugger.pause-on-exceptions"); Services.prefs.clearUserPref("devtools.debugger.pause-on-caught-exceptions");
deleted file mode 100644 --- a/devtools/client/debugger/new/test/mochitest/helpers/context.js +++ /dev/null @@ -1,23 +0,0 @@ -/* 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/framework/attach-thread.js +++ b/devtools/client/framework/attach-thread.js @@ -37,19 +37,26 @@ function handleThreadState(toolbox, even function attachThread(toolbox) { const target = toolbox.target; const { form: { chromeDebugger, actor } } = target; // Sourcemaps are always turned off when using the new debugger // frontend. This is because it does sourcemapping on the // client-side, so the server should not do it. - const useSourceMaps = false; - const autoBlackBox = false; - const ignoreFrameEnvironment = true; + let useSourceMaps = false; + let autoBlackBox = false; + let ignoreFrameEnvironment = false; + const newDebuggerEnabled = Services.prefs.getBoolPref("devtools.debugger.new-debugger-frontend"); + if (!newDebuggerEnabled) { + useSourceMaps = Services.prefs.getBoolPref("devtools.debugger.source-maps-enabled"); + autoBlackBox = Services.prefs.getBoolPref("devtools.debugger.auto-black-box"); + } else { + ignoreFrameEnvironment = true; + } const threadOptions = { useSourceMaps, autoBlackBox, ignoreFrameEnvironment }; return new Promise((resolve, reject) => { const handleResponse = ([res, threadClient]) => { if (res.error) { reject(new Error("Couldn't attach to thread: " + res.error)); return;
--- a/devtools/client/framework/test/browser_keybindings_01.js +++ b/devtools/client/framework/test/browser_keybindings_01.js @@ -46,16 +46,22 @@ function buildDevtoolsKeysetMap(keyset) function setupKeyBindingsTest() { for (const win of gDevToolsBrowser._trackedBrowserWindows) { buildDevtoolsKeysetMap(win.document.getElementById("devtoolsKeyset")); } } add_task(async function() { + // Use the new debugger frontend because the old one swallows the netmonitor shortcut: + // https://bugzilla.mozilla.org/show_bug.cgi?id=1370442#c7 + await SpecialPowers.pushPrefEnv({set: [ + ["devtools.debugger.new-debugger-frontend", true] + ]}); + await addTab(TEST_URL); await new Promise(done => waitForFocus(done)); setupKeyBindingsTest(); info("Test the first inspector key (there are 2 of them on Mac)"); const inspectorKeys = allKeys.filter(({ toolId }) => { return toolId === "inspector" || toolId === "inspectorMac";
--- a/devtools/client/framework/test/browser_source_map-01.js +++ b/devtools/client/framework/test/browser_source_map-01.js @@ -16,16 +16,18 @@ PromiseTestUtils.whitelistRejectionsGlob PromiseTestUtils.whitelistRejectionsGlobally(/Component not initialized/); // Empty page const PAGE_URL = `${URL_ROOT}doc_empty-tab-01.html`; const JS_URL = `${URL_ROOT}code_binary_search.js`; const COFFEE_URL = `${URL_ROOT}code_binary_search.coffee`; add_task(async function() { + await pushPref("devtools.debugger.new-debugger-frontend", true); + const toolbox = await openNewTabAndToolbox(PAGE_URL, "jsdebugger"); const service = toolbox.sourceMapURLService; // Inject JS script const sourceSeen = waitForSourceLoad(toolbox, JS_URL); await createScript(JS_URL); await sourceSeen;
--- a/devtools/client/framework/test/browser_source_map-absolute.js +++ b/devtools/client/framework/test/browser_source_map-absolute.js @@ -11,16 +11,18 @@ const { PromiseTestUtils } = scopedCuImp PromiseTestUtils.whitelistRejectionsGlobally(/this\.worker is null/); // Empty page const PAGE_URL = `${URL_ROOT}doc_empty-tab-01.html`; const JS_URL = `${URL_ROOT}code_binary_search_absolute.js`; const ORIGINAL_URL = `${URL_ROOT}code_binary_search.coffee`; add_task(async function() { + await pushPref("devtools.debugger.new-debugger-frontend", true); + const toolbox = await openNewTabAndToolbox(PAGE_URL, "jsdebugger"); const service = toolbox.sourceMapURLService; // Inject JS script const sourceSeen = waitForSourceLoad(toolbox, JS_URL); await createScript(JS_URL); await sourceSeen;
--- a/devtools/client/framework/test/browser_source_map-inline.js +++ b/devtools/client/framework/test/browser_source_map-inline.js @@ -13,16 +13,18 @@ PromiseTestUtils.whitelistRejectionsGlob const TEST_ROOT = "http://example.com/browser/devtools/client/framework/test/"; // Empty page const PAGE_URL = `${TEST_ROOT}doc_empty-tab-01.html`; const JS_URL = `${TEST_ROOT}code_inline_bundle.js`; const ORIGINAL_URL = "webpack:///code_inline_original.js"; add_task(async function() { + await pushPref("devtools.debugger.new-debugger-frontend", true); + const toolbox = await openNewTabAndToolbox(PAGE_URL, "jsdebugger"); const service = toolbox.sourceMapURLService; // Inject JS script const sourceSeen = waitForSourceLoad(toolbox, JS_URL); await createScript(JS_URL); await sourceSeen;
--- a/devtools/client/framework/test/browser_source_map-reload.js +++ b/devtools/client/framework/test/browser_source_map-reload.js @@ -11,16 +11,18 @@ const JS_URL = URL_ROOT + "sjs_code_relo const ORIGINAL_URL_1 = "webpack:///code_reload_1.js"; const ORIGINAL_URL_2 = "webpack:///code_reload_2.js"; const GENERATED_LINE = 86; const ORIGINAL_LINE = 13; add_task(async function() { + await pushPref("devtools.debugger.new-debugger-frontend", true); + // Start with the empty page, then navigate, so that we can properly // listen for new sources arriving. const toolbox = await openNewTabAndToolbox(INITIAL_URL, "webconsole"); const service = toolbox.sourceMapURLService; const tab = toolbox.target.tab; let sourceSeen = waitForSourceLoad(toolbox, JS_URL); tab.linkedBrowser.loadURI(PAGE_URL);
--- a/devtools/client/framework/test/browser_toolbox_split_console.js +++ b/devtools/client/framework/test/browser_toolbox_split_console.js @@ -9,16 +9,22 @@ // * toolbox.useKeyWithSplitConsole() // * toolbox.isSplitConsoleFocused let gToolbox = null; let panelWin = null; const URL = "data:text/html;charset=utf8,test split console key delegation"; +// 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"); +}); + add_task(async function() { const tab = await addTab(URL); const target = TargetFactory.forTab(tab); gToolbox = await gDevTools.showToolbox(target, "jsdebugger"); panelWin = gToolbox.getPanel("jsdebugger").panelWin; await gToolbox.openSplitConsole(); await testIsSplitConsoleFocused();
--- a/devtools/client/framework/test/browser_toolbox_view_source_01.js +++ b/devtools/client/framework/test/browser_toolbox_view_source_01.js @@ -6,26 +6,39 @@ /** * Tests that Toolbox#viewSourceInDebugger works when debugger is not * yet opened. */ var URL = `${URL_ROOT}doc_viewsource.html`; var JS_URL = `${URL_ROOT}code_math.js`; +// 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"); +}); + async function viewSource() { const toolbox = await openNewTabAndToolbox(URL); await toolbox.viewSourceInDebugger(JS_URL, 2); const debuggerPanel = toolbox.getPanel("jsdebugger"); ok(debuggerPanel, "The debugger panel was opened."); is(toolbox.currentToolId, "jsdebugger", "The debugger panel was selected."); - assertSelectedLocationInDebugger(debuggerPanel, 2, undefined); + const { DebuggerView } = debuggerPanel.panelWin; + const Sources = DebuggerView.Sources; + + is(Sources.selectedValue, getSourceActor(Sources, JS_URL), + "The correct source is shown in the debugger."); + is(DebuggerView.editor.getCursor().line + 1, 2, + "The correct line is highlighted in the debugger's source editor."); + await closeToolboxAndTab(toolbox); finish(); } function test() { viewSource().then(finish, (aError) => { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); finish();
--- a/devtools/client/framework/test/browser_toolbox_view_source_02.js +++ b/devtools/client/framework/test/browser_toolbox_view_source_02.js @@ -5,27 +5,47 @@ /** * Tests that Toolbox#viewSourceInDebugger works when debugger is already loaded. */ var URL = `${URL_ROOT}doc_viewsource.html`; var JS_URL = `${URL_ROOT}code_math.js`; +// 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"); +}); + async function viewSource() { const toolbox = await openNewTabAndToolbox(URL); - await toolbox.selectTool("jsdebugger"); + const { panelWin: debuggerWin } = await toolbox.selectTool("jsdebugger"); + const debuggerEvents = debuggerWin.EVENTS; + const { DebuggerView } = debuggerWin; + const Sources = DebuggerView.Sources; + + await debuggerWin.once(debuggerEvents.SOURCE_SHOWN); + ok("A source was shown in the debugger."); + + is(Sources.selectedValue, getSourceActor(Sources, JS_URL), + "The correct source is initially shown in the debugger."); + is(DebuggerView.editor.getCursor().line, 0, + "The correct line is initially highlighted in the debugger's source editor."); await toolbox.viewSourceInDebugger(JS_URL, 2); const debuggerPanel = toolbox.getPanel("jsdebugger"); ok(debuggerPanel, "The debugger panel was opened."); is(toolbox.currentToolId, "jsdebugger", "The debugger panel was selected."); - assertSelectedLocationInDebugger(debuggerPanel, 2, undefined); + is(Sources.selectedValue, getSourceActor(Sources, JS_URL), + "The correct source is shown in the debugger."); + is(DebuggerView.editor.getCursor().line + 1, 2, + "The correct line is highlighted in the debugger's source editor."); await closeToolboxAndTab(toolbox); finish(); } function test() { viewSource().then(finish, (aError) => { ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
--- a/devtools/client/framework/test/head.js +++ b/devtools/client/framework/test/head.js @@ -366,16 +366,8 @@ async function resizeWindow(toolbox, wid const originalHeight = hostWindow.outerHeight; const toWidth = width || originalWidth; const toHeight = height || originalHeight; const onResize = once(hostWindow, "resize"); hostWindow.resizeTo(toWidth, toHeight); await onResize; } - -function assertSelectedLocationInDebugger(debuggerPanel, line, column) { - const location = debuggerPanel._selectors.getSelectedLocation( - debuggerPanel._getState() - ); - is(location.line, line); - is(location.column, column); -}
--- a/devtools/client/framework/toolbox-options.js +++ b/devtools/client/framework/toolbox-options.js @@ -363,16 +363,21 @@ OptionsPanel.prototype = { const isNightly = AppConstants.NIGHTLY_BUILD; if (!isNightly) { return; } // Labels for these new buttons are nightly only and mostly intended for working on // devtools. const prefDefinitions = [{ + pref: "devtools.debugger.new-debugger-frontend", + label: L10N.getStr("toolbox.options.enableNewDebugger.label"), + id: "devtools-new-debugger", + parentId: "debugger-options" + }, { pref: "devtools.performance.new-panel-enabled", label: "Enable new performance recorder (then re-open DevTools)", id: "devtools-new-performance", parentId: "context-options" }]; const createPreferenceOption = ({pref, label, id}) => { const inputLabel = this.panelDoc.createElement("label");
--- a/devtools/client/framework/toolbox-process-window.js +++ b/devtools/client/framework/toolbox-process-window.js @@ -103,16 +103,17 @@ var connect = async function() { function setPrefDefaults() { Services.prefs.setBoolPref("devtools.inspector.showUserAgentStyles", true); Services.prefs.setBoolPref("devtools.performance.ui.show-platform-data", true); Services.prefs.setBoolPref("devtools.inspector.showAllAnonymousContent", true); Services.prefs.setBoolPref("browser.dom.window.dump.enabled", true); Services.prefs.setBoolPref("devtools.command-button-noautohide.enabled", true); // Bug 1225160 - Using source maps with browser debugging can lead to a crash Services.prefs.setBoolPref("devtools.debugger.source-maps-enabled", false); + Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", true); Services.prefs.setBoolPref("devtools.preference.new-panel-enabled", false); Services.prefs.setBoolPref("layout.css.emulate-moz-box-with-flex", false); Services.prefs.setBoolPref("devtools.performance.enabled", false); } window.addEventListener("load", async function() { gShortcuts = new KeyShortcuts({window});
--- a/devtools/client/inspector/markup/test/browser.ini +++ b/devtools/client/inspector/markup/test/browser.ini @@ -65,17 +65,16 @@ support-files = lib_react_16.2.0_min.js lib_react_dom_15.3.1_min.js lib_react_dom_15.4.1.js lib_react_dom_16.2.0_min.js lib_react_with_addons_15.3.1_min.js lib_react_with_addons_15.4.1.js react_external_listeners.js !/devtools/client/debugger/new/test/mochitest/helpers.js - !/devtools/client/debugger/new/test/mochitest/helpers/context.js !/devtools/client/inspector/test/head.js !/devtools/client/inspector/test/shared-head.js !/devtools/client/shared/test/shared-head.js !/devtools/client/shared/test/shared-redux-head.js !/devtools/client/shared/test/telemetry-test-helpers.js !/devtools/client/shared/test/test-actor.js !/devtools/client/shared/test/test-actor-registry.js
--- a/devtools/client/inspector/markup/test/browser_markup_shadowdom_open_debugger.js +++ b/devtools/client/inspector/markup/test/browser_markup_shadowdom_open_debugger.js @@ -10,21 +10,16 @@ // Test that the markup view is correctly updated to show those items if the custom // element definition happens after opening the inspector. /* 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); -/* 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); - const TEST_URL = `data:text/html;charset=utf-8,` + encodeURIComponent(` <test-component></test-component> <other-component>some-content</other-component> <script> "use strict"; window.attachTestComponent = function() { customElements.define("test-component", class extends HTMLElement {
--- a/devtools/client/shared/view-source.js +++ b/devtools/client/shared/view-source.js @@ -1,16 +1,17 @@ /* 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. * @@ -45,24 +46,83 @@ 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"); - const source = dbg.getSource(sourceURL); - if (source) { + + // 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) { await toolbox.selectTool("jsdebugger", reason); - dbg.selectSource(sourceURL, sourceLine); + + // 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); + } 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 @@ -151,18 +151,16 @@ 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 @@ -248,16 +246,17 @@ 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 @@ -16,16 +16,19 @@ add_task(async function() { 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); @@ -52,36 +55,34 @@ 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"); - await openDebugger(); - const dbg = createDebuggerContext(toolbox); + const {panel} = await openDebugger(); info("Waiting for pause"); - await pauseDebugger(dbg); - const stackFrames = dbg.selectors.getCallStackFrames(dbg.getState()); + const stackFrames = await pauseDebugger(panel); 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. - await dbg.actions.selectFrame(stackFrames[1]); + stackFrames.selectFrame(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", @@ -103,15 +104,23 @@ 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); } -async function pauseDebugger(dbg) { - info("Waiting for debugger to pause"); - ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() { - content.wrappedJSObject.firstCall(); +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(); + }); }); - 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,47 +2,45 @@ /* 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"; -requestLongerTimeout(5); - const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" + "test/mochitest/" + "test-click-function-to-source.html"; -const TEST_SCRIPT_URI = "http://example.com/browser/devtools/client/webconsole/" + - "test/mochitest/" + - "test-click-function-to-source.js"; +// Force the old debugger UI since it's directly used (see Bug 1301705) +pushPref("devtools.debugger.new-debugger-frontend", false); add_task(async function() { const hud = await openNewTabAndConsole(TEST_URI); info("Open the Debugger panel."); - await openDebugger(); + const {panel} = await openDebugger(); + const panelWin = panel.panelWin; 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 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"); + 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"); });
new file mode 100644 --- /dev/null +++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_closure_inspection.js @@ -0,0 +1,104 @@ +/* -*- 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 @@ -7,16 +7,19 @@ // from the js debugger. "use strict"; 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; @@ -24,46 +27,47 @@ 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"); - await openDebugger(); - const toolbox = gDevTools.getToolbox(hud.target); - const dbg = createDebuggerContext(toolbox); + const {panel} = await openDebugger(); + const {activeThread, StackFrames: stackFrames} = panel.panelWin.DebuggerController; 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 stackFrames = dbg.selectors.getCallStackFrames(dbg.getState()); + 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; 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(); - - await dbg.actions.selectFrame(stackFrames[1]); - + stackFrames.selectFrame(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()`"); @@ -73,16 +77,8 @@ 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 @@ -8,38 +8,40 @@ // evaluation over the protocol - see Bug 1088861. "use strict"; 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"); - await openDebugger(); + const {panel} = await openDebugger(); + const {activeThread} = panel.panelWin.DebuggerController; - const toolbox = gDevTools.getToolbox(hud.target); - const dbg = createDebuggerContext(toolbox); - + const onFirstCallFramesAdded = activeThread.addOneTimeListener("framesadded"); // 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 waitForPaused(dbg); + await onFirstCallFramesAdded; 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; @@ -50,14 +52,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"); - dbg.actions.resume(dbg.getState()); + activeThread.resume(); message = await onFirstCallMessageReceived; ok(firstCallEvaluationResult !== unresolvedSymbol, "firstCall() returned correct value"); });
--- 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,16 +14,19 @@ 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."); - const toolbox = gDevTools.getToolbox(target); - const dbg = createDebuggerContext(toolbox); - await pauseDebugger(dbg); + await waitForFrameAdded(); 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,15 +58,21 @@ 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 pauseDebugger(dbg) { - info("Waiting for debugger to pause"); - ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() { - content.wrappedJSObject.firstCall(); +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(); + }); }); - await waitForPaused(dbg); }
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_optimized_out_vars.js +++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_optimized_out_vars.js @@ -8,40 +8,52 @@ "use strict"; 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); - await openDebugger(); + const { toolbox, panel: debuggerPanel } = await openDebugger(); - const toolbox = gDevTools.getToolbox(hud.target); - const dbg = createDebuggerContext(toolbox); + const sources = debuggerPanel.panelWin.DebuggerView.Sources; + await debuggerPanel.addBreakpoint({ actor: sources.values[0], line: 18 }); + await ensureThreadClientState(debuggerPanel, "resumed"); - await addBreakpoint(dbg, "test-closure-optimized-out.html", 18); - await waitForThreadEvents(dbg, "resumed"); + const { FETCHED_SCOPES } = debuggerPanel.panelWin.EVENTS; + const fetchedScopes = debuggerPanel.panelWin.once(FETCHED_SCOPES); // Cause the debuggee to pause - await pauseDebugger(dbg); + ContentTask.spawn(gBrowser.selectedBrowser, {}, async function() { + const button = content.document.querySelector("button"); + button.click(); + }); + + await fetchedScopes; + ok(true, "Scopes were fetched"); 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"); }); -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); +// 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); + } }
--- a/devtools/client/webconsole/test/mochitest/browser_webconsole_sourcemap_nosource.js +++ b/devtools/client/webconsole/test/mochitest/browser_webconsole_sourcemap_nosource.js @@ -20,16 +20,19 @@ 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 @@ -14,18 +14,22 @@ const { PromiseTestUtils } = scopedCuImp PromiseTestUtils.whitelistRejectionsGlobally(/Component not initialized/); PromiseTestUtils.whitelistRejectionsGlobally(/this\.worker is null/); const TEST_URI = "http://example.com/browser/devtools/client/webconsole/" + "test/mochitest/" + "test-stacktrace-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 + Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", true); 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,28 +14,16 @@ 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.js */ -Services.scriptloader.loadSubScript( - "chrome://mochitests/content/browser/devtools/client/debugger/new/test/mochitest/helpers.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({ @@ -542,27 +530,19 @@ 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. - if (panel._view) { - panel._view.Variables.lazyEmpty = false; - } + panel._view.Variables.lazyEmpty = false; - // Old debugger - if (panel.panelWin && panel.panelWin.DebuggerController) { - await panel.panelWin.DebuggerController.waitForSourcesLoaded(); - } else { - // New debugger - await toolbox.threadClient.getSources(); - } + await panel.panelWin.DebuggerController.waitForSourcesLoaded(); return {target, toolbox, panel}; } async function openInspector(options = {}) { if (!options.tab) { options.tab = gBrowser.selectedTab; }