Bug 1389488 - Check that add-on file exists before forwarding request to AddonManager
MozReview-Commit-ID: 6b6QS9y6vPj
--- a/testing/marionette/addon.js
+++ b/testing/marionette/addon.js
@@ -86,16 +86,20 @@ async function installAddon(file) {
*
* @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;
+ 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) {
throw new UnknownError(
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py
@@ -86,8 +86,14 @@ class TestAddons(MarionetteTestCase):
self.addons.install(addon_path)
self.assertNotIn("{d3e7c1f1-2e35-4a49-89fe-9f46eb8abf0a}", self.all_addon_ids)
def test_install_unsigned_addon_fails(self):
addon_path = os.path.join(here, "webextension-unsigned.xpi")
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)