Fix Bug 1419109 - Empty default icon shows blank icon in toolbar r=mixedpuppy
authorVarun Dey <varundey20@gmail.com>
Thu, 17 Jan 2019 18:52:00 +0000
changeset 514346 d7bf0d21448d4c1564f3d5e512167d2b8f887264
parent 514345 f412108e7d77f62d7eea2461e7e76e007356fa7b
child 514347 698395a5488d459236dc0bc34eb6648ff2913730
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,18 @@ 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]
+skip-if = toolkit == 'android' # browser_action icon testing not supported on android
 [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]