Bug 1512303 - Add test for manifest URL link in about:debugging;r=ladybenko
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 17 Dec 2018 11:12:44 +0000
changeset 450904 327dfbe04cb400535b8bf4444960aebdf7854114
parent 450903 dc3530dc609514afa8250b20afc6dfaa659cb736
child 450905 c4e9eae1c922def57704130e1ccb77c685373a0a
push id35220
push useraciure@mozilla.com
push dateMon, 17 Dec 2018 16:40:36 +0000
treeherdermozilla-central@183b5d2173b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersladybenko
bugs1512303
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 1512303 - Add test for manifest URL link in about:debugging;r=ladybenko Differential Revision: https://phabricator.services.mozilla.com/D14389
devtools/client/aboutdebugging-new/src/components/debugtarget/ExtensionDetail.js
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_manifest_url.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_connect_toggle_usb_devices.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_status.js
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_stop_adb.js
devtools/client/aboutdebugging-new/test/browser/head.js
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/ExtensionDetail.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/ExtensionDetail.js
@@ -35,17 +35,17 @@ class ExtensionDetail extends PureCompon
       uuid,
       Localized(
         {
           id: "about-debugging-extension-manifest-link",
           key: "manifest",
         },
         dom.a(
           {
-            className: "extension-detail__manifest",
+            className: "extension-detail__manifest js-manifest-url",
             href: manifestURL,
             target: "_blank",
           },
           "Manifest URL",
         )
       ),
     ];
 
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -16,16 +16,18 @@ support-files =
   resources/service-workers/*
   resources/test-adb-extension/*
   resources/test-temporary-extension/*
   test-tab-favicons.html
   !/devtools/client/shared/test/shared-head.js
   !/devtools/client/shared/test/shared-redux-head.js
   !/devtools/client/shared/test/telemetry-test-helpers.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_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]
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_manifest_url.js
@@ -0,0 +1,61 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* import-globals-from head-addons-script.js */
+
+"use strict";
+
+const { adbAddon } = require("devtools/shared/adb/adb-addon");
+
+const ABD_ADDON_NAME = "ADB binary provider";
+
+// Load addons helpers
+Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-addons-script.js", this);
+
+// Test that manifest URLs for addon targets show the manifest correctly in a new tab.
+// This test reuses the ADB extension to be sure to have a valid manifest URL to open.
+add_task(async function() {
+  await pushPref("devtools.remote.adb.extensionURL",
+                 CHROME_URL_ROOT + "resources/test-adb-extension/adb-extension-#OS#.xpi");
+
+  const { document, tab, window } = await openAboutDebugging();
+  const usbStatusElement = document.querySelector(".js-sidebar-usb-status");
+
+  info("Install ADB");
+  adbAddon.install("internal");
+  await waitUntil(() => usbStatusElement.textContent.includes("USB devices enabled"));
+  await waitForAdbStart();
+
+  info("Wait until the debug target for ADB appears");
+  await waitUntil(() => findDebugTargetByText(ABD_ADDON_NAME, document));
+  const adbExtensionItem = findDebugTargetByText(ABD_ADDON_NAME, document);
+
+  const manifestUrlElement = adbExtensionItem.querySelector(".js-manifest-url");
+  ok(manifestUrlElement, "A link to the manifest is displayed");
+
+  info("Click on the manifest URL and wait for the new tab to open");
+  const onTabOpened = once(gBrowser.tabContainer, "TabOpen");
+  manifestUrlElement.click();
+  const { target } = await onTabOpened;
+  await BrowserTestUtils.browserLoaded(target.linkedBrowser);
+
+  info("Retrieve the text content of the new tab");
+  const textContent = await ContentTask.spawn(target.linkedBrowser, {}, function() {
+    return content.wrappedJSObject.document.body.textContent;
+  });
+
+  const manifestObject = JSON.parse(textContent);
+  ok(manifestObject, "The displayed content is a valid JSON object");
+  is(manifestObject.name, ABD_ADDON_NAME, "Manifest tab shows the expected content");
+
+  info("Close the manifest.json tab");
+  await removeTab(target);
+
+  info("Uninstall the adb extension and wait for the message to udpate");
+  adbAddon.uninstall();
+  await waitUntil(() => usbStatusElement.textContent.includes("USB devices disabled"));
+  await waitForAdbStop();
+
+  await waitForRequestsToSettle(window.AboutDebugging.store);
+  await removeTab(tab);
+});
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_connect_toggle_usb_devices.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_connect_toggle_usb_devices.js
@@ -1,15 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const { AddonManager } = require("resource://gre/modules/AddonManager.jsm");
-const { adbProcess } = require("devtools/shared/adb/adb-process");
 
 /**
  * Check that USB Devices scanning can be enabled and disabled from the connect page.
  */
 add_task(async function() {
   await pushPref("devtools.remote.adb.extensionURL",
                  CHROME_URL_ROOT + "resources/test-adb-extension/adb-extension-#OS#.xpi");
 
@@ -42,21 +41,22 @@ add_task(async function() {
   const addon = await AddonManager.getAddonByID(adbExtensionId);
   Assert.deepEqual(addon.installTelemetryInfo, { source: "about:debugging" },
     "Got the expected addon.installTelemetryInfo");
 
   // Right now we are resuming as soon as "USB devices enabled" is displayed, but ADB
   // might still be starting up. If we move to uninstall directly, the ADB startup will
   // fail and we will have an unhandled promise rejection.
   // See Bug 1498469.
-  info("Wait until ADB has started.");
-  await waitUntil(() => adbProcess.ready);
+  await waitForAdbStart();
 
   info("Click on the toggle button");
   usbToggleButton.click();
 
   info("Wait until the toggle button text is updated");
   await waitUntil(() => usbToggleButton.textContent.includes("Enable"));
   ok(document.querySelector(".js-connect-usb-disabled-message"),
     "The message about enabling USB devices is rendered again");
 
+  await waitForAdbStop();
+
   await removeTab(tab);
 });
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_status.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_sidebar_usb_status.js
@@ -1,15 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const { adbAddon } = require("devtools/shared/adb/adb-addon");
-const { adbProcess } = require("devtools/shared/adb/adb-process");
 
 /**
  * This test asserts that the sidebar shows a message describing the status of the USB
  * devices scanning.
  */
 add_task(async function() {
   await pushPref("devtools.remote.adb.extensionURL",
                  CHROME_URL_ROOT + "resources/test-adb-extension/adb-extension-#OS#.xpi");
@@ -20,22 +19,21 @@ add_task(async function() {
   ok(usbStatusElement, "Sidebar shows the USB status element");
   ok(usbStatusElement.textContent.includes("USB devices disabled"),
     "USB status element has the expected content");
 
   info("Install the adb extension and wait for the message to udpate");
   // Use "internal" as the install source to avoid triggering telemetry.
   adbAddon.install("internal");
   await waitUntil(() => usbStatusElement.textContent.includes("USB devices enabled"));
-
   // Right now we are resuming as soon as "USB devices enabled" is displayed, but ADB
   // might still be starting up. If we move to uninstall directly, the ADB startup will
   // fail and we will have an unhandled promise rejection.
   // See Bug 1498469.
-  info("Wait until ADB has started.");
-  await waitUntil(() => adbProcess.ready);
+  await waitForAdbStart();
 
   info("Uninstall the adb extension and wait for the message to udpate");
   adbAddon.uninstall();
   await waitUntil(() => usbStatusElement.textContent.includes("USB devices disabled"));
+  await waitForAdbStop();
 
   await removeTab(tab);
 });
--- a/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_stop_adb.js
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_stop_adb.js
@@ -1,15 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const { adbAddon } = require("devtools/shared/adb/adb-addon");
-const { adbProcess } = require("devtools/shared/adb/adb-process");
 const { check } = require("devtools/shared/adb/adb-running-checker");
 
 /**
  * Check that ADB is stopped:
  * - when the adb extension is uninstalled
  * - when no consumer is registered
  */
 add_task(async function() {
@@ -54,26 +53,8 @@ add_task(async function() {
   info("Reinstall the addon, this should start ADB again");
   adbAddon.install("internal");
   await waitForAdbStart();
 
   info("Close the last tab, this should stop ADB");
   await removeTab(thirdTab);
   await waitForAdbStop();
 });
-
-async function waitForAdbStart() {
-  info("Wait for ADB to start");
-  return asyncWaitUntil(async () => {
-    const isProcessReady = adbProcess.ready;
-    const isRunning = await check();
-    return isProcessReady && isRunning;
-  });
-}
-
-async function waitForAdbStop() {
-  info("Wait for ADB to stop");
-  return asyncWaitUntil(async () => {
-    const isProcessReady = adbProcess.ready;
-    const isRunning = await check();
-    return !isProcessReady && !isRunning;
-  });
-}
--- a/devtools/client/aboutdebugging-new/test/browser/head.js
+++ b/devtools/client/aboutdebugging-new/test/browser/head.js
@@ -188,8 +188,32 @@ async function selectRuntime(deviceName,
   const sidebarItem = findSidebarItemByText(deviceName, document);
   sidebarItem.querySelector(".js-sidebar-link").click();
 
   await waitUntil(() => {
     const runtimeInfo = document.querySelector(".js-runtime-info");
     return runtimeInfo && runtimeInfo.textContent.includes(name);
   });
 }
+
+// Returns a promise that resolves when the adb process exists and is running.
+async function waitForAdbStart() {
+  info("Wait for ADB to start");
+  const { adbProcess } = require("devtools/shared/adb/adb-process");
+  const { check } = require("devtools/shared/adb/adb-running-checker");
+  return asyncWaitUntil(async () => {
+    const isProcessReady = adbProcess.ready;
+    const isRunning = await check();
+    return isProcessReady && isRunning;
+  });
+}
+
+// Returns a promise that resolves when the adb process is no longer running.
+async function waitForAdbStop() {
+  info("Wait for ADB to stop");
+  const { adbProcess } = require("devtools/shared/adb/adb-process");
+  const { check } = require("devtools/shared/adb/adb-running-checker");
+  return asyncWaitUntil(async () => {
+    const isProcessReady = adbProcess.ready;
+    const isRunning = await check();
+    return !isProcessReady && !isRunning;
+  });
+}