Bug 1500374 - Add test for temporary id message;r=daisuke
authorJulian Descottes <jdescottes@mozilla.com>
Fri, 18 Jan 2019 13:52:11 +0000
changeset 514429 7aa26271b4c584966b70f16f395e98791211be7e
parent 514428 1a9e703e70d1ab05dc51605afaf44936c77d3568
child 514430 1c06ef2cea48149efe62ce4e207c6fadded245fd
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaisuke
bugs1500374
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1500374 - Add test for temporary id message;r=daisuke Depends on D16572 Differential Revision: https://phabricator.services.mozilla.com/D16573
devtools/client/aboutdebugging-new/src/components/debugtarget/TemporaryExtensionDetail.js
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_temporary_addon_buttons.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_temporary_id_message.js
devtools/client/aboutdebugging-new/test/browser/helper-addons.js
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/TemporaryExtensionDetail.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/TemporaryExtensionDetail.js
@@ -30,22 +30,24 @@ class TemporaryExtensionDetail extends P
     };
   }
 
   renderTemporaryIdMessage() {
     return Localized(
       {
         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",
       }),
     );
   }
 
   render() {
     return dom.div(
       {},
       this.renderTemporaryIdMessage(),
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -23,16 +23,17 @@ support-files =
   !/devtools/client/shared/test/shared-redux-head.js
   !/devtools/client/shared/test/telemetry-test-helpers.js
 
 [browser_aboutdebugging_addons_debug_nobg.js]
 [browser_aboutdebugging_addons_manifest_url.js]
 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
 [browser_aboutdebugging_connection_prompt_setting.js]
 [browser_aboutdebugging_debug-target-pane_collapsibilities_interaction.js]
 [browser_aboutdebugging_debug-target-pane_collapsibilities_preference.js]
 [browser_aboutdebugging_debug-target-pane_empty.js]
 [browser_aboutdebugging_debug-target-pane_usb_runtime.js]
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_temporary_addon_buttons.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_temporary_addon_buttons.js
@@ -69,17 +69,11 @@ add_task(async function() {
   const target = findDebugTargetByText(PACKAGED_EXTENSION_NAME, document);
 
   const reloadButton = target.querySelector(".js-temporary-extension-reload-button");
   ok(!reloadButton, "No reload button displayed for a regularly installed extension");
 
   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);
 });
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_temporary_id_message.js
@@ -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);
+});
--- a/devtools/client/aboutdebugging-new/test/browser/helper-addons.js
+++ b/devtools/client/aboutdebugging-new/test/browser/helper-addons.js
@@ -78,16 +78,26 @@ async function removeTemporaryExtension(
   const temporaryExtensionItem = findDebugTargetByText(name, document);
   temporaryExtensionItem.querySelector(".js-temporary-extension-remove-button").click();
 
   info("Wait until the debug target item disappears");
   await waitUntil(() => !findDebugTargetByText(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;
   MockFilePicker.init(window);
   MockFilePicker.setFiles([_getSupportsFile(path).file]);
 }
 /* exported prepareMockFilePicker */