Backed out changeset 005957262022 (bug 1373850) for eslint failures
authorPhil Ringnalda <philringnalda@gmail.com>
Mon, 26 Jun 2017 19:20:33 -0700
changeset 366099 8cfe015562d688e076b0688c830028a7cbb9c538
parent 366098 55f9e6931cbbc39bf3b66a69ab7b58d18369cc84
child 366103 bda394665daaaf0899717f220aa8345fe697e5dc
push id45496
push userphilringnalda@gmail.com
push dateTue, 27 Jun 2017 02:20:41 +0000
treeherderautoland@8cfe015562d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1373850
milestone56.0a1
backs out005957262022a299f2e27b2f97540e488f0d0fd0
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
Backed out changeset 005957262022 (bug 1373850) for eslint failures MozReview-Commit-ID: 7W04mXlcYsl
toolkit/components/extensions/ext-theme.js
toolkit/components/extensions/schemas/theme.json
toolkit/components/extensions/test/browser/browser_ext_themes_dynamic_updates.js
--- a/toolkit/components/extensions/ext-theme.js
+++ b/toolkit/components/extensions/ext-theme.js
@@ -276,25 +276,12 @@ this.theme = class extends ExtensionAPI 
             // WebExtensions using the Theme API will not have a theme defined
             // in the manifest. Therefore, we need to initialize the theme the
             // first time browser.theme.update is called.
             this.theme = new Theme(extension.baseURI, extension.logger);
           }
 
           this.theme.load(details);
         },
-        reset: () => {
-          if (!gThemesEnabled) {
-            // Return early if themes are disabled.
-            return;
-          }
-
-          if (!this.theme) {
-            // If no theme has been initialized, nothing to do.
-            return;
-          }
-
-          this.theme.unload();
-        }
       },
     };
   }
 };
--- a/toolkit/components/extensions/schemas/theme.json
+++ b/toolkit/components/extensions/schemas/theme.json
@@ -453,19 +453,12 @@
         "description": "Make complete or partial updates to the theme. Resolves when the update has completed.",
         "parameters": [
           {
             "name": "details",
             "$ref": "manifest.ThemeType",
             "description": "The properties of the theme to update."
           }
         ]
-      },
-      {
-        "name": "reset",
-        "type": "function",
-        "async": true,
-        "description": "Removes the updates made to the theme.",
-        "parameters": []
       }
     ]
   }
 ]
--- a/toolkit/components/extensions/test/browser/browser_ext_themes_dynamic_updates.js
+++ b/toolkit/components/extensions/test/browser/browser_ext_themes_dynamic_updates.js
@@ -7,38 +7,32 @@ const TEXT_COLOR_1 = "#fac96e";
 
 // PNG image data for the Mozilla dino head.
 const BACKGROUND_2 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==";
 const ACCENT_COLOR_2 = "#03fe03";
 const TEXT_COLOR_2 = "#0ef325";
 
 function hexToRGB(hex) {
   hex = parseInt((hex.indexOf("#") > -1 ? hex.substring(1) : hex), 16);
-  return "rgb(" + [hex >> 16, (hex & 0x00FF00) >> 8, (hex & 0x0000FF)].join(", ") + ")";
+  return [hex >> 16, (hex & 0x00FF00) >> 8, (hex & 0x0000FF)];
 }
 
-function validateTheme(backgroundImage, accentColor, textColor, isLWT) {
+function validateTheme(backgroundImage, accentColor, textColor) {
   let docEl = window.document.documentElement;
   let style = window.getComputedStyle(docEl);
 
-  if (isLWT) {
-    Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
-    Assert.equal(docEl.getAttribute("lwthemetextcolor"), "bright",
-      "LWT text color attribute should be set");
-  };
+  Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
+  Assert.equal(docEl.getAttribute("lwthemetextcolor"), "bright",
+    "LWT text color attribute should be set");
 
   Assert.ok(style.backgroundImage.includes(backgroundImage), "Expected correct background image");
-  if (accentColor.startsWith('#')) {
-    accentColor = hexToRGB(accentColor);
-  }
-  if (textColor.startsWith('#')) {
-    textColor = hexToRGB(textColor);
-  }
-  Assert.equal(style.backgroundColor, accentColor, "Expected correct accent color");
-  Assert.equal(style.color, textColor, "Expected correct text color");
+  Assert.equal(style.backgroundColor, "rgb(" + hexToRGB(accentColor).join(", ") + ")",
+    "Expected correct accent color");
+  Assert.equal(style.color, "rgb(" + hexToRGB(textColor).join(", ") + ")",
+    "Expected correct text color");
 }
 
 add_task(async function setup() {
   await SpecialPowers.pushPrefEnv({
     set: [["extensions.webextensions.themes.enabled", true]],
   });
 });
 
@@ -48,64 +42,53 @@ add_task(async function test_dynamic_the
       permissions: ["theme"],
     },
     files: {
       "image1.png": BACKGROUND_1,
       "image2.png": BACKGROUND_2,
     },
     background() {
       browser.test.onMessage.addListener((msg, details) => {
-        if (msg === "update-theme") {
-          browser.theme.update(details).then(() => {
-            browser.test.sendMessage("theme-updated");
-          });
-        } else {
-          browser.theme.reset().then(() => {
-            browser.test.sendMessage("theme-reset");
-          });
+        if (msg != "update-theme") {
+          browser.test.fail("expected 'update-theme' message");
         }
+
+        browser.theme.update(details);
+        browser.test.sendMessage("theme-updated");
       });
     },
   });
 
-  let defaultStyle = window.getComputedStyle(window.document.documentElement);
   await extension.startup();
 
   extension.sendMessage("update-theme", {
     "images": {
       "headerURL": "image1.png",
     },
     "colors": {
       "accentcolor": ACCENT_COLOR_1,
       "textcolor": TEXT_COLOR_1,
     },
   });
 
   await extension.awaitMessage("theme-updated");
 
-  validateTheme("image1.png", ACCENT_COLOR_1, TEXT_COLOR_1, true);
+  validateTheme("image1.png", ACCENT_COLOR_1, TEXT_COLOR_1);
 
   extension.sendMessage("update-theme", {
     "images": {
       "headerURL": "image2.png",
     },
     "colors": {
       "accentcolor": ACCENT_COLOR_2,
       "textcolor": TEXT_COLOR_2,
     },
   });
 
   await extension.awaitMessage("theme-updated");
 
-  validateTheme("image2.png", ACCENT_COLOR_2, TEXT_COLOR_2, true);
-
-  extension.sendMessage("reset-theme");
-
-  await extension.awaitMessage("theme-reset");
-
-  let {backgroundImage, backgroundColor, color} = defaultStyle;
-  validateTheme(backgroundImage, backgroundColor, color, false);
+  validateTheme("image2.png", ACCENT_COLOR_2, TEXT_COLOR_2);
 
   await extension.unload();
 
   let docEl = window.document.documentElement;
   Assert.ok(!docEl.hasAttribute("lwtheme"), "LWT attribute should not be set");
 });