Bug 1440069 - Don't try to resolve empty headerURLs. r=aswan draft
authorTim Nguyen <ntim.bugs@gmail.com>
Wed, 21 Feb 2018 21:20:09 +0000
changeset 758100 4d02d34546bf02f076ba5b07397b6aa92f0c1b03
parent 758099 20d1242828ef7e64541810e39f9b9d2a259e9fe0
push id99945
push userbmo:ntim.bugs@gmail.com
push dateWed, 21 Feb 2018 21:21:18 +0000
reviewersaswan
bugs1440069
milestone60.0a1
Bug 1440069 - Don't try to resolve empty headerURLs. r=aswan MozReview-Commit-ID: ILMx3aNOJxV
toolkit/components/extensions/schemas/theme.json
toolkit/components/extensions/test/browser/browser_ext_themes_lwtsupport.js
--- a/toolkit/components/extensions/schemas/theme.json
+++ b/toolkit/components/extensions/schemas/theme.json
@@ -37,34 +37,46 @@
             "maxItems": 4,
             "items": {
               "type": "number"
             }
           }
         ]
       },
       {
+        "id": "ThemeImage",
+        "choices": [
+          {
+            "type": "string",
+            "enum": [""]
+          },
+          {
+            "$ref": "ImageDataOrExtensionURL"
+          }
+        ]
+      },
+      {
         "id": "ThemeType",
         "type": "object",
         "properties": {
           "images": {
             "type": "object",
             "optional": true,
             "properties": {
               "additional_backgrounds": {
                 "type": "array",
-                "items": { "$ref": "ImageDataOrExtensionURL" },
+                "items": { "$ref": "ThemeImage" },
                 "optional": true
               },
               "headerURL": {
-                "$ref": "ImageDataOrExtensionURL",
+                "$ref": "ThemeImage",
                 "optional": true
               },
               "theme_frame": {
-                "$ref": "ImageDataOrExtensionURL",
+                "$ref": "ThemeImage",
                 "optional": true
               }
             },
             "additionalProperties": { "$ref": "UnrecognizedProperty" }
           },
           "colors": {
             "type": "object",
             "optional": true,
--- a/toolkit/components/extensions/test/browser/browser_ext_themes_lwtsupport.js
+++ b/toolkit/components/extensions/test/browser/browser_ext_themes_lwtsupport.js
@@ -63,16 +63,66 @@ add_task(async function test_LWT_image_a
   let docEl = window.document.documentElement;
   Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
   Assert.ok(!docEl.hasAttribute("lwtheme-image"), "LWT image attribute should not be set");
   await extension.unload();
   Assert.ok(!docEl.hasAttribute("lwtheme"), "LWT attribute should not be set");
   Assert.ok(!docEl.hasAttribute("lwtheme-image"), "LWT image attribute should not be set");
 });
 
+add_task(async function test_LWT_image_attribute_with_empty_headerURL() {
+  let extension = ExtensionTestUtils.loadExtension({
+    manifest: {
+      "theme": {
+        "images": {
+          "headerURL": ""
+        },
+        "colors": {
+          "accentcolor": ACCENT_COLOR,
+          "textcolor": TEXT_COLOR,
+        },
+      },
+    },
+  });
+
+  await extension.startup();
+
+  let docEl = window.document.documentElement;
+  Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
+  Assert.ok(!docEl.hasAttribute("lwtheme-image"), "LWT image attribute should not be set");
+  await extension.unload();
+  Assert.ok(!docEl.hasAttribute("lwtheme"), "LWT attribute should not be set");
+  Assert.ok(!docEl.hasAttribute("lwtheme-image"), "LWT image attribute should not be set");
+});
+
+add_task(async function test_LWT_image_attribute_with_empty_theme_frame() {
+  let extension = ExtensionTestUtils.loadExtension({
+    manifest: {
+      "theme": {
+        "images": {
+          "theme_frame": ""
+        },
+        "colors": {
+          "accentcolor": ACCENT_COLOR,
+          "textcolor": TEXT_COLOR,
+        },
+      },
+    },
+  });
+
+  await extension.startup();
+
+  let docEl = window.document.documentElement;
+  Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
+  Assert.ok(!docEl.hasAttribute("lwtheme-image"), "LWT image attribute should not be set");
+  await extension.unload();
+  Assert.ok(!docEl.hasAttribute("lwtheme"), "LWT attribute should not be set");
+  Assert.ok(!docEl.hasAttribute("lwtheme-image"), "LWT image attribute should not be set");
+});
+
 add_task(async function test_LWT_requires_accentcolor_defined_textcolor_only() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "theme": {
         "colors": {
           "textcolor": TEXT_COLOR,
         },
       },