Bug 1408066 - Addon.js install fails if path is incorrect. r?whimboo draft
authorBenjamin Forehand Jr <bennyjr169@gmail.com>
Thu, 19 Oct 2017 23:31:52 -0700
changeset 686388 237d2c7e4c866d2223fb12d834d64a7bd64ad6b4
parent 680024 196dadb2fe500e75c6fbddcac78106648676cf10
child 737378 c083d3fe56b5b15249ac16daa3c277a5d492edb7
push id86188
push userbmo:bforehand@mozilla.com
push dateWed, 25 Oct 2017 21:38:12 +0000
reviewerswhimboo
bugs1408066
milestone58.0a1
Bug 1408066 - Addon.js install fails if path is incorrect. r?whimboo MozReview-Commit-ID: Eu5RUGU2bY4
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,18 +83,24 @@ 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;
+  let file;
+
+  try {
+    file = new FileUtils.File(path);
+  } catch (e) {
+    throw new UnknownError(`${path} is not an absolute path.`);
+  }
 
   if (!file.exists()) {
     throw new UnknownError(`Could not find add-on at '${path}'`);
   }
 
   try {
     if (temporary) {
       addon = await AddonManager.installTemporaryAddon(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,12 @@ 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_with_relative_path(self):
+        with self.assertRaisesRegexp(AddonInstallException, "is not an absolute path."):
+            self.addons.install('webextension.xpi')