Bug 1528781 - Hide tabs for This Firefox behind a preference;r=Ola,daisuke

Differential Revision: https://phabricator.services.mozilla.com/D24378

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Julian Descottes 2019-03-25 16:09:57 +00:00
Родитель 25dbad7cb2
Коммит aa6b2752d1
6 изменённых файлов: 73 добавлений и 24 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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,

Просмотреть файл

@ -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);
});
}

Просмотреть файл

@ -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);
});

Просмотреть файл

@ -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");

Просмотреть файл

@ -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.