Bug 1500374 - Add test for temporary id message;r=daisuke

Depends on D16572

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Julian Descottes 2019-01-18 13:52:11 +00:00
parent d0c2570c41
commit 1e9fe745d5
5 changed files with 85 additions and 8 deletions

View File

@ -35,12 +35,14 @@ class TemporaryExtensionDetail extends PureComponent {
{
id: "about-debugging-tmp-extension-temporary-id",
a: dom.a({
className: "js-temporary-id-link",
href: TEMP_ID_DOC_URL,
target: "_blank",
}),
},
dom.div({
className: "temporary-extension-detail__temporary-id-message",
className: "temporary-extension-detail__temporary-id-message " +
"js-temporary-id-message",
}),
);
}

View File

@ -28,6 +28,7 @@ support-files =
skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug 1499638
[browser_aboutdebugging_addons_remote_runtime.js]
[browser_aboutdebugging_addons_temporary_addon_buttons.js]
[browser_aboutdebugging_addons_temporary_id_message.js]
[browser_aboutdebugging_connect_networklocations.js]
[browser_aboutdebugging_connect_toggle_usb_devices.js]
skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug 1499638

View File

@ -74,12 +74,6 @@ add_task(async function() {
const removeButton = target.querySelector(".js-temporary-extension-remove-button");
ok(!removeButton, "No remove button displayed for a regularly installed extension");
info("Retrieve the extension instance from the addon manager, and uninstall it");
const extension = await AddonManager.getAddonByID(PACKAGED_EXTENSION_ID);
extension.uninstall();
info("Wait until the addon disappears from about:debugging");
await waitUntil(() => !findDebugTargetByText(PACKAGED_EXTENSION_NAME, document));
await removeExtension(PACKAGED_EXTENSION_ID, PACKAGED_EXTENSION_NAME, document);
await removeTab(tab);
});

View File

@ -0,0 +1,70 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from helper-addons.js */
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-addons.js", this);
// Test that temporary extensions show a message about temporary ids, with a learn more
// link.
add_task(async function() {
const EXTENSION_NAME = "Temporary web extension";
const EXTENSION_ID = "test-devtools@mozilla.org";
const { document, tab } = await openAboutDebugging();
const manifest = {
"manifest_version": 2,
"name": EXTENSION_NAME,
"version": "1.0",
"applications": {
"gecko": {
"id": EXTENSION_ID,
},
},
};
const tempExt = new TemporaryExtension(EXTENSION_ID);
tempExt.writeManifest(manifest);
info("Install a temporary extension");
await AddonManager.installTemporaryAddon(tempExt.sourceDir);
info("Wait until a debug target item appears");
await waitUntil(() => findDebugTargetByText(EXTENSION_NAME, document));
const target = findDebugTargetByText(EXTENSION_NAME, document);
const message = target.querySelector(".js-temporary-id-message");
ok(!!message, "Temporary id message is displayed for temporary extensions");
const link = target.querySelector(".js-temporary-id-link");
ok(!!link, "Temporary id link is displayed for temporary extensions");
await removeTemporaryExtension(EXTENSION_NAME, document);
info("Remove the temporary web extension");
tempExt.remove();
await removeTab(tab);
});
// Test that the message and the link are not displayed for a regular extension.
add_task(async function() {
const PACKAGED_EXTENSION_ID = "packaged-extension@tests";
const PACKAGED_EXTENSION_NAME = "Packaged extension";
const { document, tab } = await openAboutDebugging();
await installRegularAddon("resources/packaged-extension/packaged-extension.xpi");
info("Wait until extension appears in about:debugging");
await waitUntil(() => findDebugTargetByText(PACKAGED_EXTENSION_NAME, document));
const target = findDebugTargetByText(PACKAGED_EXTENSION_NAME, document);
const tmpIdMessage = target.querySelector(".js-temporary-id-message");
ok(!tmpIdMessage, "No temporary id message is displayed for a regular extension");
await removeExtension(PACKAGED_EXTENSION_ID, PACKAGED_EXTENSION_NAME, document);
await removeTab(tab);
});

View File

@ -83,6 +83,16 @@ async function removeTemporaryExtension(name, document) {
}
/* exported removeTemporaryExtension */
async function removeExtension(id, name, document) {
info("Retrieve the extension instance from the addon manager, and uninstall it");
const extension = await AddonManager.getAddonByID(id);
extension.uninstall();
info("Wait until the addon disappears from about:debugging");
await waitUntil(() => !findDebugTargetByText(name, document));
}
/* exported removeExtension */
function prepareMockFilePicker(path) {
// Mock the file picker to select a test addon
const MockFilePicker = SpecialPowers.MockFilePicker;