Bug 1435191 - Enforce limit in additional_backgrounds field draft
authorVivek Dhingra <vivek3zero@gmail.com>
Sat, 14 Apr 2018 00:12:02 -0400
changeset 782070 4b27bb830c30fb52bbed74ac480f29735045bb91
parent 782042 37b810a21cbcfdee92f22eea6ce70a19e135e7f7
push id106478
push userbmo:vivek3zero@gmail.com
push dateSat, 14 Apr 2018 05:17:17 +0000
bugs1435191
milestone61.0a1
Bug 1435191 - Enforce limit in additional_backgrounds field This patch adds a check to make sure themes do not load more than 15 images, when making use of via additional_backgrounds property. If there are more than 15 images, theme will not be loaded. MozReview-Commit-ID: 9ogj4asv9cq
toolkit/components/extensions/parent/ext-theme.js
--- a/toolkit/components/extensions/parent/ext-theme.js
+++ b/toolkit/components/extensions/parent/ext-theme.js
@@ -80,17 +80,20 @@ class Theme {
       this.loadIcons(details.icons);
     }
 
     if (details.properties) {
       this.loadProperties(details.properties);
     }
 
     // Lightweight themes require accentcolor and textcolor to be defined.
-    if (this.lwtStyles.accentcolor &&
+    // If lightweight themes have additionalBackgrounds, it should have no more than 15 images
+    if (this.lwtStyles.additionalBackgrounds && this.lwtStyles.additionalBackgrounds.length > 15) {
+      this.logger.warn("Your theme includes more than 15 images in images: 'additional_backgrounds'");
+    } else if (this.lwtStyles.accentcolor &&
         this.lwtStyles.textcolor) {
       if (this.windowId) {
         windowOverrides.set(this.windowId, this);
       } else {
         windowOverrides.clear();
         defaultTheme = this;
       }
       onUpdatedEmitter.emit("theme-updated", this.details, this.windowId);