diff --git a/devtools/client/aboutdebugging-new/src/constants.js b/devtools/client/aboutdebugging-new/src/constants.js index 586eeb1f7dd7..2b41ff791fbd 100644 --- a/devtools/client/aboutdebugging-new/src/constants.js +++ b/devtools/client/aboutdebugging-new/src/constants.js @@ -95,6 +95,8 @@ const PAGE_TYPES = { }; const PREFERENCES = { + // Preference that drives the display of the "Tabs" category on This Firefox. + LOCAL_TAB_DEBUGGING_ENABLED: "devtools.aboutdebugging.local-tab-debugging", // Preference that drives the display of the "Processes" debug target category. PROCESS_DEBUGGING_ENABLED: "devtools.aboutdebugging.process-debugging", // Preference that drives the display of system addons in about:debugging. diff --git a/devtools/client/aboutdebugging-new/src/modules/debug-target-support.js b/devtools/client/aboutdebugging-new/src/modules/debug-target-support.js index 929a46493e8c..39cbe95719e1 100644 --- a/devtools/client/aboutdebugging-new/src/modules/debug-target-support.js +++ b/devtools/client/aboutdebugging-new/src/modules/debug-target-support.js @@ -13,6 +13,11 @@ function isProcessDebuggingSupported() { return Services.prefs.getBoolPref(PREFERENCES.PROCESS_DEBUGGING_ENABLED, false); } +// Process target debugging is disabled by default. +function isLocalTabDebuggingSupported() { + return Services.prefs.getBoolPref(PREFERENCES.LOCAL_TAB_DEBUGGING_ENABLED, false); +} + const ALL_DEBUG_TARGET_PANES = [ DEBUG_TARGET_PANE.INSTALLED_EXTENSION, ...(isProcessDebuggingSupported() ? [DEBUG_TARGET_PANE.PROCESSES] : []), @@ -27,11 +32,13 @@ const ALL_DEBUG_TARGET_PANES = [ const REMOTE_DEBUG_TARGET_PANES = ALL_DEBUG_TARGET_PANES.filter(p => p !== DEBUG_TARGET_PANE.TEMPORARY_EXTENSION); -// Main process debugging is not available for This Firefox. -// At the moment only the main process is listed under processes, so remove the category -// for this runtime. -const THIS_FIREFOX_DEBUG_TARGET_PANES = ALL_DEBUG_TARGET_PANES.filter(p => - p !== DEBUG_TARGET_PANE.PROCESSES); +const THIS_FIREFOX_DEBUG_TARGET_PANES = ALL_DEBUG_TARGET_PANES + // Main process debugging is not available for This Firefox. + // At the moment only the main process is listed under processes, so remove the category + // for this runtime. + .filter(p => p !== DEBUG_TARGET_PANE.PROCESSES) + // Showing tab targets for This Firefox is behind a preference. + .filter(p => p !== DEBUG_TARGET_PANE.TAB || isLocalTabDebuggingSupported()); const SUPPORTED_TARGET_PANE_BY_RUNTIME = { [RUNTIMES.THIS_FIREFOX]: THIS_FIREFOX_DEBUG_TARGET_PANES, diff --git a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_debug-target-pane_usb_runtime.js b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_debug-target-pane_usb_runtime.js index 22c82f9be521..3887a2badc1a 100644 --- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_debug-target-pane_usb_runtime.js +++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_debug-target-pane_usb_runtime.js @@ -13,8 +13,15 @@ const RUNTIME_APP_NAME = "TestApp"; // Test that the expected supported categories are displayed for USB runtimes. add_task(async function() { const mocks = new Mocks(); + await checkTargetPanes({ enableLocalTabs: false }, mocks); - const { document, tab, window } = await openAboutDebugging(); + info("Check that enableLocalTabs has no impact on the categories displayed for remote" + + " runtimes."); + await checkTargetPanes({ enableLocalTabs: true }, mocks); +}); + +async function checkTargetPanes({ enableLocalTabs }, mocks) { + const { document, tab, window } = await openAboutDebugging({ enableLocalTabs }); await selectThisFirefoxPage(document, window.AboutDebugging.store); mocks.createUSBRuntime(RUNTIME_ID, { @@ -51,4 +58,4 @@ add_task(async function() { await waitUntil(() => !findSidebarItemByText(RUNTIME_DEVICE_NAME, document)); await removeTab(tab); -}); +} diff --git a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_thisfirefox.js b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_thisfirefox.js index bf9eace9c3a8..c32292fce699 100644 --- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_thisfirefox.js +++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_thisfirefox.js @@ -3,11 +3,6 @@ "use strict"; -/** - * Check that the This Firefox page is displayed by default when opening the new - * about:debugging and that it contains the expected categories. - */ - const EXPECTED_TARGET_PANES = [ "Temporary Extensions", "Extensions", @@ -17,30 +12,56 @@ const EXPECTED_TARGET_PANES = [ "Other Workers", ]; -add_task(async function() { - const { document, tab, window } = await openAboutDebugging(); +/** + * Check that the This Firefox runtime page contains the expected categories if + * the preference to enable local tab debugging is true. + */ +add_task(async function testThisFirefoxWithLocalTab() { + const { document, tab, window } = await openAboutDebugging({ enableLocalTabs: true }); await selectThisFirefoxPage(document, window.AboutDebugging.store); + // Expect all target panes to be displayed including tabs. + await checkThisFirefoxTargetPanes(document, EXPECTED_TARGET_PANES); + + await removeTab(tab); +}); + +/** + * Check that the This Firefox runtime page contains the expected categories if + * the preference to enable local tab debugging is false. + */ +add_task(async function testThisFirefoxWithoutLocalTab() { + const { document, tab, window } = await openAboutDebugging({ enableLocalTabs: false }); + await selectThisFirefoxPage(document, window.AboutDebugging.store); + + // Expect all target panes but tabs to be displayed. + const expectedTargetPanesWithoutTabs = EXPECTED_TARGET_PANES.filter(p => p !== "Tabs"); + await checkThisFirefoxTargetPanes(document, expectedTargetPanesWithoutTabs); + + await removeTab(tab); +}); + +async function checkThisFirefoxTargetPanes(doc, expectedTargetPanes) { + const win = doc.ownerGlobal; // Check that the selected sidebar item is "This Firefox"/"This Nightly"/... - const selectedSidebarItem = document.querySelector(".js-sidebar-item-selected"); + const selectedSidebarItem = doc.querySelector(".js-sidebar-item-selected"); ok(selectedSidebarItem, "An item is selected in the sidebar"); - const thisFirefoxString = getThisFirefoxString(window); + const thisFirefoxString = getThisFirefoxString(win); is(selectedSidebarItem.textContent, thisFirefoxString, "The selected sidebar item is " + thisFirefoxString); - const paneTitlesEls = document.querySelectorAll(".js-debug-target-pane-title"); - is(paneTitlesEls.length, EXPECTED_TARGET_PANES.length, - "This Firefox has the expecte number of debug target categories"); + const paneTitlesEls = doc.querySelectorAll(".js-debug-target-pane-title"); + is(paneTitlesEls.length, expectedTargetPanes.length, + "This Firefox has the expected number of debug target categories"); const paneTitles = [...paneTitlesEls].map(el => el.textContent); - for (let i = 0; i < EXPECTED_TARGET_PANES.length; i++) { - const expectedPaneTitle = EXPECTED_TARGET_PANES[i]; + for (let i = 0; i < expectedTargetPanes.length; i++) { + const expectedPaneTitle = expectedTargetPanes[i]; const actualPaneTitle = paneTitles[i]; ok(actualPaneTitle.startsWith(expectedPaneTitle), `Expected debug target category found: ${ expectedPaneTitle }`); } +} - await removeTab(tab); -}); diff --git a/devtools/client/aboutdebugging-new/test/browser/head.js b/devtools/client/aboutdebugging-new/test/browser/head.js index c79adb47fa69..95f3571fbba8 100644 --- a/devtools/client/aboutdebugging-new/test/browser/head.js +++ b/devtools/client/aboutdebugging-new/test/browser/head.js @@ -43,11 +43,15 @@ async function enableNewAboutDebugging() { await pushPref("devtools.aboutdebugging.new-enabled", true); } -async function openAboutDebugging({ enableWorkerUpdates } = {}) { +async function openAboutDebugging({ enableWorkerUpdates, enableLocalTabs = true } = {}) { if (!enableWorkerUpdates) { silenceWorkerUpdates(); } + // This preference changes value depending on the build type, tests need to use a + // consistent value regarless of the build used. + await pushPref("devtools.aboutdebugging.local-tab-debugging", enableLocalTabs); + await enableNewAboutDebugging(); info("opening about:debugging"); diff --git a/devtools/client/preferences/devtools-client.js b/devtools/client/preferences/devtools-client.js index b1a04d985e86..2c19c4b15cc0 100644 --- a/devtools/client/preferences/devtools-client.js +++ b/devtools/client/preferences/devtools-client.js @@ -341,6 +341,14 @@ pref("devtools.responsive.showUserAgentInput", false); // Enable new about:debugging. pref("devtools.aboutdebugging.new-enabled", false); + +// Show tab debug targets for This Firefox (on by default for local builds). +#ifdef MOZILLA_OFFICIAL + pref("devtools.aboutdebugging.local-tab-debugging", false); +#else + pref("devtools.aboutdebugging.local-tab-debugging", true); +#endif + // Show process debug targets. pref("devtools.aboutdebugging.process-debugging", false); // Stringified array of network locations that users can connect to.