Bug 1408066 - Addon.js install fails if path is incorrect. r?davehunt
MozReview-Commit-ID: L1uDoXDmg2V
--- a/testing/marionette/addon.js
+++ b/testing/marionette/addon.js
@@ -84,28 +84,29 @@ async function installAddon(file) {
* @return {Promise.<string>}
* Addon ID.
*
* @throws {UnknownError}
* If there is a problem installing the addon.
*/
addon.install = async function(path, temporary = false) {
let addon;
+ var file;
try {
- let file = new FileUtils.File(path);
- if (!file.exists()) {
- throw new UnknownError();
- }
+ file = new FileUtils.File(path);
} catch (e) {
throw new UnknownError(
- `Could not find add-on at '${path}'`);
+ `Bad path. Please provide the full path to the add-on.`);
}
- let file = new FileUtils.File(path);
+ if (!file.exists()) {
+ throw new UnknownError(
+ `Could not find add-on at '${path}'`);
+ }
try {
if (temporary) {
addon = await AddonManager.installTemporaryAddon(file);
} else {
addon = await installAddon(file);
}
} catch (e) {
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py
@@ -93,13 +93,13 @@ class TestAddons(MarionetteTestCase):
self.addons.install(addon_path)
def test_install_nonexistent_addon(self):
addon_path = os.path.join(here, "does-not-exist.xpi")
with self.assertRaisesRegexp(AddonInstallException, "Could not find add-on at"):
self.addons.install(addon_path)
- def test_install_incorrect_path(self):
- addon_path = os.path.join('bad/path', 'does-not-exist.xpi')
+ def test_install_incorrect_relative_path(self):
+ addon_path = os.path.join('bad/path', 'webextension.xpi')
- with self.assertRaisesRegexp(AddonInstallException, "Could not find add-on at"):
+ with self.assertRaisesRegexp(AddonInstallException, "Bad path. The path must be the full path to the add-on."):
self.addons.install(addon_path)