Bug 1509791: Add a test for reloading error. r=ladybenko,Ola
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Tue, 09 Apr 2019 16:28:42 +0000
changeset 469737 c250a69bbdd7
parent 469736 f7418820531d
child 469738 3d6dae43b215
push id35880
push usercbrindusan@mozilla.com
push dateWed, 17 Apr 2019 09:36:19 +0000
treeherdermozilla-central@79e6ed0b08d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersladybenko, Ola
bugs1509791
milestone68.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 1509791: Add a test for reloading error. r=ladybenko,Ola Depends on D25203 Differential Revision: https://phabricator.services.mozilla.com/D25205
devtools/client/aboutdebugging-new/src/components/debugtarget/TemporaryExtensionAdditionalActions.js
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_temporary_reload_error.js
--- a/devtools/client/aboutdebugging-new/src/components/debugtarget/TemporaryExtensionAdditionalActions.js
+++ b/devtools/client/aboutdebugging-new/src/components/debugtarget/TemporaryExtensionAdditionalActions.js
@@ -41,16 +41,17 @@ class TemporaryExtensionAdditionalAction
     const { reloadError } = this.props.target.details;
 
     if (!reloadError) {
       return null;
     }
 
     return Message(
       {
+        className: "qa-temporary-extension-reload-error",
         level: MESSAGE_LEVEL.ERROR,
         key: "reload-error",
       },
       dom.p({ className: "technical-text" }, reloadError),
     );
   }
 
   render() {
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -38,16 +38,18 @@ tags = webextensions
 [browser_aboutdebugging_addons_debug_setting_usb.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]
 skip-if = (os == 'win') # On windows the AddonManager locks the XPI file loaded as a temporary extension and we can not test the reload of the extension.
 [browser_aboutdebugging_addons_temporary_id_message.js]
 [browser_aboutdebugging_addons_temporary_install_error.js]
+[browser_aboutdebugging_addons_temporary_reload_error.js]
+skip-if = (os == 'win') # On windows the AddonManager locks the XPI file loaded as a temporary extension and we can not test the reload of the extension.
 [browser_aboutdebugging_addons_warnings.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_temporary_reload_error.js
@@ -0,0 +1,51 @@
+/* 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 the reload button updates the addon list with the correct metadata.
+add_task(async function() {
+  const { document, tab, window } = await openAboutDebugging();
+  await selectThisFirefoxPage(document, window.AboutDebugging.store);
+
+  const EXTENSION_ID = "test-devtools@mozilla.org";
+  const EXTENSION_NAME = "Temporary web extension";
+
+  const addonFile = await installTemporaryExtensionFromXPI({
+    id: EXTENSION_ID,
+    name: EXTENSION_NAME,
+  }, document);
+
+  const target = findDebugTargetByText(EXTENSION_NAME, document);
+  ok(!!target, "The temporary extension is installed with the expected name");
+
+  info("Update the name of the temporary extension in the manifest");
+  updateTemporaryXPI({}, addonFile);
+
+  info("Click on the reload button for the invalid temporary extension");
+  const reloadButton = target.querySelector(".js-temporary-extension-reload-button");
+  reloadButton.click();
+
+  info("Wait until the error message appears");
+  await waitUntil(() => target.querySelector(".qa-temporary-extension-reload-error"));
+  ok(true, "The error message of reloading appears");
+
+  info("Click on the reload button for the valid temporary extension");
+  updateTemporaryXPI({ id: EXTENSION_ID, name: EXTENSION_NAME }, addonFile);
+  reloadButton.click();
+
+  info("Wait until the error message disappears");
+  await waitUntil(() => !target.querySelector(".qa-temporary-extension-reload-error"));
+  ok(true, "The error message of reloading disappears");
+
+  info("Click on the remove button for the temporary extension");
+  const removeButton = target.querySelector(".js-temporary-extension-remove-button");
+  removeButton.click();
+
+  info("Wait until the debug target with the extension disappears");
+  await waitUntil(() => !findDebugTargetByText(EXTENSION_NAME, document));
+
+  await removeTab(tab);
+});