Bug 1408066 - Addon.js install fails if path is incorrect. r?whimboo
MozReview-Commit-ID: Eu5RUGU2bY4
--- 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')