Bug 1408066 - Addon.js install fails if path is incorrect. r?davehunt draft
authorBenjamin Forehand Jr <bennyjr169@gmail.com>
Thu, 19 Oct 2017 23:31:52 -0700
changeset 684061 ff4effb8642c69a4901755de1f4253cbfd2b8f8b
parent 680024 196dadb2fe500e75c6fbddcac78106648676cf10
child 736791 c6225f4ec75a75408d3041f1ecff9e63f9220758
push id85532
push userbmo:bforehand@mozilla.com
push dateFri, 20 Oct 2017 17:49:04 +0000
reviewersdavehunt
bugs1408066
milestone58.0a1
Bug 1408066 - Addon.js install fails if path is incorrect. r?davehunt MozReview-Commit-ID: LyJOlGEFe8X
testing/marionette/addon.js
testing/marionette/harness/marionette_harness/tests/unit/test_addons.py
--- a/testing/marionette/addon.js
+++ b/testing/marionette/addon.js
@@ -83,21 +83,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 file = new FileUtils.File(path);
   let addon;
+  var file;
+
+  try {
+    file = new FileUtils.File(path);
+  } catch (e) {
+    throw new UnknownError(
+        `Please provide the absolute path to the add-on.`);
+  }
 
   if (!file.exists()) {
-    throw new UnknownError(`Could not find add-on at '${path}'`);
+    throw new UnknownError(
+      `Could not find add-on at '${path}'`);
   }
 
   try {
     if (temporary) {
       addon = await AddonManager.installTemporaryAddon(file);
     } else {
       addon = await installAddon(file);
     }
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py
@@ -92,8 +92,14 @@ class TestAddons(MarionetteTestCase):
         with self.assertRaises(AddonInstallException):
             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_relative_path(self):
+        addon_path = os.path.join('relative/path', 'webextension.xpi')
+
+        with self.assertRaisesRegexp(AddonInstallException, "Please provide the absolute path to the add-on"):
+            self.addons.install(addon_path)