Files
firefox/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_system_addons.js
T
Alexandre Poirot 3e32f9edd3 Bug 1506546 - Refactor about:debuggings. r=yulia,jdescottes
I did a dedicated patch for converting both about:debuggings as it is slightly more
complex as we have to tweak redux data, wrappers, mocks.
This patch also convert a manual "reload" request being done by about:debugging
and instead use protocol.js front to do it.
Also, I moved isLegacyTemporaryExtension to the front as it depends on accessing the form
and it should be better to keep form processing to the fronts, if possible.

MozReview-Commit-ID: 16qZkuCBp9b

Depends on D12576

Differential Revision: https://phabricator.services.mozilla.com/D12577
2018-11-27 19:17:11 +00:00

90 lines
3.3 KiB
JavaScript

/* 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 = () => ([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 = () => ([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 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,
};
}