зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1488499 - Hide system addons in aboutdebugging-new if showSystemAddons pref is false;r=ladybenko
Differential Revision: https://phabricator.services.mozilla.com/D12462 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
01788b8f3c
Коммит
378cd2a356
|
@ -147,7 +147,13 @@ function requestExtensions() {
|
|||
|
||||
try {
|
||||
const { addons } = await clientWrapper.listAddons();
|
||||
const extensions = addons.filter(a => a.debuggable);
|
||||
let extensions = addons.filter(a => a.debuggable);
|
||||
|
||||
// Filter out system addons unless the dedicated preference is set to true.
|
||||
if (!getState().ui.showSystemAddons) {
|
||||
extensions = extensions.filter(e => !e.isSystem);
|
||||
}
|
||||
|
||||
if (runtime.type !== RUNTIMES.THIS_FIREFOX) {
|
||||
// manifestURL can only be used when debugging local addons, remove this
|
||||
// information for the extension data.
|
||||
|
@ -155,6 +161,7 @@ function requestExtensions() {
|
|||
extension.manifestURL = null;
|
||||
});
|
||||
}
|
||||
|
||||
const installedExtensions = extensions.filter(e => !e.temporarilyInstalled);
|
||||
const temporaryExtensions = extensions.filter(e => e.temporarilyInstalled);
|
||||
|
||||
|
|
|
@ -67,6 +67,8 @@ const PAGES = {
|
|||
const PREFERENCES = {
|
||||
// Temporary preference without any default value until network locations are enabled.
|
||||
NETWORK_ENABLED: "devtools.aboutdebugging.network",
|
||||
// Preference that drives the display of system addons in about:debugging.
|
||||
SHOW_SYSTEM_ADDONS: "devtools.aboutdebugging.showSystemAddons",
|
||||
// Temporary preference without any default value until wifi is enabled.
|
||||
WIFI_ENABLED: "devtools.aboutdebugging.wifi",
|
||||
};
|
||||
|
|
|
@ -47,7 +47,10 @@ function getUiState() {
|
|||
const locations = getNetworkLocations();
|
||||
const networkEnabled = Services.prefs.getBoolPref(PREFERENCES.NETWORK_ENABLED, false);
|
||||
const wifiEnabled = Services.prefs.getBoolPref(PREFERENCES.WIFI_ENABLED, false);
|
||||
return new UiState(locations, collapsibilities, networkEnabled, wifiEnabled);
|
||||
const showSystemAddons = Services.prefs.getBoolPref(PREFERENCES.SHOW_SYSTEM_ADDONS,
|
||||
false);
|
||||
return new UiState(locations, collapsibilities, networkEnabled, wifiEnabled,
|
||||
showSystemAddons);
|
||||
}
|
||||
|
||||
exports.configureStore = configureStore;
|
||||
|
|
|
@ -14,7 +14,7 @@ const {
|
|||
} = require("../constants");
|
||||
|
||||
function UiState(locations = [], debugTargetCollapsibilities = {},
|
||||
networkEnabled = false, wifiEnabled = false) {
|
||||
networkEnabled = false, wifiEnabled = false, showSystemAddons = false) {
|
||||
return {
|
||||
adbAddonStatus: null,
|
||||
debugTargetCollapsibilities,
|
||||
|
@ -22,6 +22,7 @@ function UiState(locations = [], debugTargetCollapsibilities = {},
|
|||
networkEnabled,
|
||||
networkLocations: locations,
|
||||
selectedPage: null,
|
||||
showSystemAddons,
|
||||
wifiEnabled,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
[DEFAULT]
|
||||
tags = devtools
|
||||
subsuite = devtools
|
||||
prefs =
|
||||
# showSystemAddons has different values depending on the build flags,
|
||||
# ensure consistent test behavior by always setting this to false.
|
||||
devtools.aboutdebugging.showSystemAddons=false
|
||||
support-files =
|
||||
debug-target-pane_collapsibilities_head.js
|
||||
head-addons-script.js
|
||||
|
@ -29,6 +33,7 @@ skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug
|
|||
[browser_aboutdebugging_sidebar_usb_runtime_refresh.js]
|
||||
[browser_aboutdebugging_sidebar_usb_status.js]
|
||||
skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug 1499638
|
||||
[browser_aboutdebugging_system_addons.js]
|
||||
[browser_aboutdebugging_tab_favicons.js]
|
||||
[browser_aboutdebugging_thisfirefox.js]
|
||||
[browser_aboutdebugging_thisfirefox_runtime_info.js]
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from mocks/head-client-wrapper-mock.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
CHROME_URL_ROOT + "mocks/head-client-wrapper-mock.js", this);
|
||||
/* import-globals-from mocks/head-runtime-client-factory-mock.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
CHROME_URL_ROOT + "mocks/head-runtime-client-factory-mock.js", this);
|
||||
|
||||
// Test that system addons are only displayed when the showSystemAddons preference is
|
||||
// true.
|
||||
|
||||
const SYSTEM_ADDON =
|
||||
createAddonData({ id: "system", name: "System Addon", isSystem: true });
|
||||
const INSTALLED_ADDON =
|
||||
createAddonData({ id: "installed", name: "Installed Addon", isSystem: false });
|
||||
|
||||
add_task(async function testShowSystemAddonsFalse() {
|
||||
const thisFirefoxClient = setupThisFirefoxMock();
|
||||
thisFirefoxClient.listAddons = () => ({ addons: [SYSTEM_ADDON, INSTALLED_ADDON] });
|
||||
|
||||
info("Hide system addons in aboutdebugging via preference");
|
||||
await pushPref("devtools.aboutdebugging.showSystemAddons", false);
|
||||
|
||||
const { document, tab } = await openAboutDebugging();
|
||||
|
||||
const hasSystemAddon = !!findDebugTargetByText("System Addon", document);
|
||||
const hasInstalledAddon = !!findDebugTargetByText("Installed Addon", document);
|
||||
ok(!hasSystemAddon, "System addon is hidden when system addon pref is false");
|
||||
ok(hasInstalledAddon, "Installed addon is displayed when system addon pref is false");
|
||||
|
||||
await removeTab(tab);
|
||||
});
|
||||
|
||||
add_task(async function testShowSystemAddonsTrue() {
|
||||
const thisFirefoxClient = setupThisFirefoxMock();
|
||||
thisFirefoxClient.listAddons = () => ({ addons: [SYSTEM_ADDON, INSTALLED_ADDON] });
|
||||
|
||||
info("Show system addons in aboutdebugging via preference");
|
||||
await pushPref("devtools.aboutdebugging.showSystemAddons", true);
|
||||
|
||||
const { document, tab } = await openAboutDebugging();
|
||||
const hasSystemAddon = !!findDebugTargetByText("System Addon", document);
|
||||
const hasInstalledAddon = !!findDebugTargetByText("Installed Addon", document);
|
||||
ok(hasSystemAddon, "System addon is displayed when system addon pref is true");
|
||||
ok(hasInstalledAddon, "Installed addon is displayed when system addon pref is true");
|
||||
|
||||
await removeTab(tab);
|
||||
});
|
||||
|
||||
// Create a basic mock for this-firefox client, and setup a runtime-client-factory mock
|
||||
// to return our mock client when needed.
|
||||
function setupThisFirefoxMock() {
|
||||
const runtimeClientFactoryMock = createRuntimeClientFactoryMock();
|
||||
const thisFirefoxClient = createThisFirefoxClientMock();
|
||||
runtimeClientFactoryMock.createClientForRuntime = runtime => {
|
||||
const { RUNTIMES } = require("devtools/client/aboutdebugging-new/src/constants");
|
||||
if (runtime.id === RUNTIMES.THIS_FIREFOX) {
|
||||
return { clientWrapper: thisFirefoxClient };
|
||||
}
|
||||
throw new Error("Unexpected runtime id " + runtime.id);
|
||||
};
|
||||
|
||||
info("Enable mocks");
|
||||
enableRuntimeClientFactoryMock(runtimeClientFactoryMock);
|
||||
registerCleanupFunction(() => {
|
||||
disableRuntimeClientFactoryMock();
|
||||
});
|
||||
|
||||
return thisFirefoxClient;
|
||||
}
|
||||
|
||||
// Create basic addon data as the DebuggerClient would return it (debuggable and non
|
||||
// temporary).
|
||||
function createAddonData({ id, name, isSystem }) {
|
||||
return {
|
||||
actor: `actorid-${id}`,
|
||||
iconURL: `moz-extension://${id}/icon-url.png`,
|
||||
id,
|
||||
manifestURL: `moz-extension://${id}/manifest-url.json`,
|
||||
name,
|
||||
isSystem,
|
||||
temporarilyInstalled: false,
|
||||
debuggable: true,
|
||||
};
|
||||
}
|
Загрузка…
Ссылка в новой задаче