Bug 1446450 - Add webextensions unit test for additionalErrors;r=aswan
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 25 Feb 2019 13:09:41 +0000
changeset 519063 c5e6c33c5737ccffebed78226e95e35f865a9aa0
parent 519062 6ab8ccf59cae44471b849874f785ee5c819ec98f
child 519064 ef831b231f7dbc497a6e26a5f46d042afd677da1
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1446450
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1446450 - Add webextensions unit test for additionalErrors;r=aswan Depends on D20651 Addressing suggestion from D20648 :) Differential Revision: https://phabricator.services.mozilla.com/D20703
toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
@@ -46,16 +46,53 @@ add_task(async function test_implicit_id
   // file url of the installed xpi file.
   equal(addon.sourceURI && addon.sourceURI.spec,
         Services.io.newFileURI(xpifile).spec,
         "SourceURI of the add-on has the expected value");
 
   await addon.uninstall();
 });
 
+// Test that extension install error attach the detailed error messages to the
+// Error object.
+add_task(async function test_invalid_extension_install_errors() {
+  const manifest = {
+    name: "invalid",
+    applications: {
+      gecko: {
+        id: "invalid@tests.mozilla.org",
+      },
+    },
+    description: "extension with an invalid 'matches' value",
+    manifest_version: 2,
+    content_scripts: [{
+      "matches": "*://*.foo.com/*",
+      "js": ["content.js"],
+    }],
+    version: "1.0",
+  };
+
+  const addonDir = await promiseWriteWebManifestForExtension(manifest, gTmpD,
+                                                "the-addon-sub-dir");
+
+  await Assert.rejects(
+    AddonManager.installTemporaryAddon(addonDir),
+    err => {
+      return err.additionalErrors.length == 1 &&
+             err.additionalErrors[0] ==
+              `Reading manifest: Error processing content_scripts.0.matches: ` +
+              `Expected array instead of "*://*.foo.com/*"`;
+    },
+    "Exception has the proper additionalErrors details"
+  );
+
+  Services.obs.notifyObservers(addonDir, "flush-cache-entry");
+  addonDir.remove(true);
+});
+
 // We should be able to temporarily install an unsigned web extension
 // that does not have an ID in its manifest.
 add_task(async function test_unsigned_no_id_temp_install() {
   AddonTestUtils.useRealCertChecks = true;
   const manifest = {
     name: "no ID",
     description: "extension without an ID",
     manifest_version: 2,