Fix Bug 1419109 - Empty default icon shows blank icon in toolbar r=mixedpuppy
☠☠ backed out by 2bb5deb58950 ☠ ☠
authorVarun Dey <varundey20@gmail.com>
Thu, 10 Jan 2019 18:05:12 +0000
changeset 513654 a3bbf490ea419b2c01a4447d45e7fe0a116144f1
parent 513653 1218e374fbc71f64a3e671731004294053df2e22
child 513655 2bb5deb589500edcab98659c4a6659d9bf3e5ffa
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1419109
milestone66.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
Fix Bug 1419109 - Empty default icon shows blank icon in toolbar r=mixedpuppy If the extension had either default_icon or one of it's property as an empty string, it would show a black icon in the toolbar. With this patch, it checks if any of default_icon property is empty and throws an error on extension load. Differential Revision: https://phabricator.services.mozilla.com/D16070
toolkit/components/extensions/schemas/manifest.json
toolkit/components/extensions/test/xpcshell/test_ext_manifest.js
toolkit/components/extensions/test/xpcshell/xpcshell.ini
--- a/toolkit/components/extensions/schemas/manifest.json
+++ b/toolkit/components/extensions/schemas/manifest.json
@@ -402,16 +402,22 @@
         "pattern": "^https?://.*$"
       },
       {
         "id": "ExtensionURL",
         "type": "string",
         "format": "strictRelativeUrl"
       },
       {
+        "id": "ExtensionFileUrl",
+        "type": "string",
+        "format": "strictRelativeUrl",
+        "pattern": "^\\w"
+      },
+      {
         "id": "ImageDataOrExtensionURL",
         "type": "string",
         "format": "imageDataOrStrictRelativeUrl"
       },
       {
         "id": "ExtensionID",
         "choices": [
           {
@@ -540,21 +546,21 @@
         }
       },
       {
         "id": "IconPath",
         "choices": [
           {
             "type": "object",
             "patternProperties": {
-              "^[1-9]\\d*$": { "$ref": "ExtensionURL" }
+              "^[1-9]\\d*$": { "$ref": "ExtensionFileUrl" }
             },
             "additionalProperties": false
           },
-          { "$ref": "ExtensionURL" }
+          { "$ref": "ExtensionFileUrl" }
         ]
       },
       {
         "id": "IconImageData",
         "choices": [
           {
             "type": "object",
             "patternProperties": {
new file mode 100644
--- /dev/null
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_manifest.js
@@ -0,0 +1,49 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+add_task(async function test_manifest() {
+  let normalized = await ExtensionTestUtils.normalizeManifest({
+    "browser_action": {
+      "default_icon": "",
+    },
+  });
+
+  equal(normalized.error,
+        `Error processing browser_action.default_icon: Value "" must either: be an object value, or match the pattern /^\\w/`,
+        "Should have an error");
+  Assert.deepEqual(normalized.errors, [], "Should not have a warning");
+
+  normalized = await ExtensionTestUtils.normalizeManifest({
+    "browser_action": {
+      "default_icon": {
+        "16": "",
+      },
+    },
+  });
+
+  equal(normalized.error,
+        "Error processing browser_action.default_icon: Value must either: .16 must match the pattern /^\\w/, or be a string value",
+        "Should have an error");
+  Assert.deepEqual(normalized.errors, [], "Should not have a warning");
+
+  normalized = await ExtensionTestUtils.normalizeManifest({
+    "browser_action": {
+      "default_icon": {
+        "16": "icon.png",
+      },
+    },
+  });
+
+  equal(normalized.error, undefined, "Should not have an error");
+  Assert.deepEqual(normalized.errors, [], "Should not have a warning");
+
+  normalized = await ExtensionTestUtils.normalizeManifest({
+    "browser_action": {
+      "default_icon": "icon.png",
+    },
+  });
+
+  equal(normalized.error, undefined, "Should not have an error");
+  Assert.deepEqual(normalized.errors, [], "Should not have a warning");
+});
--- a/toolkit/components/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell.ini
@@ -28,16 +28,17 @@ tags = webextensions in-process-webexten
 [test_MatchPattern.js]
 [test_WebExtensionContentScript.js]
 [test_WebExtensionPolicy.js]
 
 [test_csp_custom_policies.js]
 [test_csp_validator.js]
 [test_ext_contexts.js]
 [test_ext_json_parser.js]
+[test_ext_manifest.js]
 [test_ext_manifest_content_security_policy.js]
 [test_ext_manifest_incognito.js]
 [test_ext_manifest_minimum_chrome_version.js]
 [test_ext_manifest_minimum_opera_version.js]
 [test_ext_manifest_themes.js]
 [test_ext_permission_warnings.js]
 [test_ext_schemas.js]
 [test_ext_schemas_roots.js]