Bug 1401324 - Add mochitest for remembering temporary addon folder; r=daisuke
authorJulian Descottes <jdescottes@mozilla.com>
Tue, 07 May 2019 06:37:19 +0000
changeset 531667 1f27cacfb9cf3cb7d16925ab1ab70617e05f7f73
parent 531666 ecc1127396f971e2bddee56a4d101129ec067e2f
child 531668 067fd517e656b6276034dca9f0ed139fcf55b450
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaisuke
bugs1401324
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 1401324 - Add mochitest for remembering temporary addon folder; r=daisuke Depends on D29141 Differential Revision: https://phabricator.services.mozilla.com/D30005
devtools/client/aboutdebugging-new/test/browser/browser.ini
devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_temporary_install_path.js
--- a/devtools/client/aboutdebugging-new/test/browser/browser.ini
+++ b/devtools/client/aboutdebugging-new/test/browser/browser.ini
@@ -38,16 +38,17 @@ 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_install_path.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]
new file mode 100644
--- /dev/null
+++ b/devtools/client/aboutdebugging-new/test/browser/browser_aboutdebugging_addons_temporary_install_path.js
@@ -0,0 +1,61 @@
+/* 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 the the path used to install a temporary addon is saved in a preference and reused
+ * next time the feature is used.
+ */
+
+const EXTENSION_PATH = "resources/test-temporary-extension/manifest.json";
+const EXTENSION_NAME = "test-temporary-extension";
+const LAST_DIR_PREF = "devtools.aboutdebugging.tmpExtDirPath";
+
+// Check that the preference is updated when trying to install a temporary extension.
+add_task(async function testPreferenceUpdatedAfterInstallingExtension() {
+  registerCleanupFunction(() => {
+    Services.prefs.clearUserPref(LAST_DIR_PREF);
+  });
+  const { document, tab, window } = await openAboutDebugging();
+  await selectThisFirefoxPage(document, window.AboutDebugging.store);
+
+  await installTemporaryExtension(EXTENSION_PATH, EXTENSION_NAME, document);
+
+  info("Check whether the selected dir sets into the pref");
+  const lastDirPath = Services.prefs.getCharPref(LAST_DIR_PREF, "");
+  const expectedPath = getTestFilePath("resources/test-temporary-extension");
+  is(lastDirPath, expectedPath, "The selected dir should set into the pref");
+
+  await waitUntil(() => findDebugTargetByText(EXTENSION_NAME, document));
+  await removeTemporaryExtension(EXTENSION_NAME, document);
+  await removeTab(tab);
+});
+
+// Check that the preference is updated when trying to install a temporary extension.
+add_task(async function testPreferenceRetrievedWhenInstallingExtension() {
+  const selectedDir = getTestFilePath("resources/packaged-extension");
+
+  await pushPref(LAST_DIR_PREF, selectedDir);
+
+  const { document, tab, window } = await openAboutDebugging();
+  await selectThisFirefoxPage(document, window.AboutDebugging.store);
+
+  const MockFilePicker = SpecialPowers.MockFilePicker;
+  MockFilePicker.init(window);
+  const onFilePickerShown = new Promise(resolve => {
+    MockFilePicker.showCallback = fp => {
+      resolve(fp);
+    };
+  });
+  document.querySelector(".qa-temporary-extension-install-button").click();
+
+  info("Check whether the shown dir is same as the pref");
+  const fp = await onFilePickerShown;
+  is(fp.displayDirectory.path, selectedDir, "Shown directory sets as same as the pref");
+
+  await removeTab(tab);
+});