Backed out changeset 9d0fc1d12d9a (bug 1449327) for browser-chrome failures at toolkit/components/extensions/test/browser/browser_ext_themes_sanitization.js
authorCoroiu Cristina <ccoroiu@mozilla.com>
Tue, 10 Apr 2018 20:44:49 +0300
changeset 412692 60de60fe27339fc2dcf5f47a31a68c7e6bdd58b0
parent 412691 53109cc01f60ddbfb7e85d47cc49c3ff92d894de
child 412693 5fa8c1abc6b6ae913af02e9c5e00e5ab54c85fc7
push id101981
push useraiakab@mozilla.com
push dateTue, 10 Apr 2018 22:18:59 +0000
treeherdermozilla-inbound@9ad2b8aabfae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1449327
milestone61.0a1
backs out9d0fc1d12d9a29d989df38bf74747490a86b114f
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 9d0fc1d12d9a (bug 1449327) for browser-chrome failures at toolkit/components/extensions/test/browser/browser_ext_themes_sanitization.js
toolkit/components/extensions/test/browser/browser.ini
toolkit/components/extensions/test/browser/browser_ext_themes_sanitization.js
toolkit/modules/LightweightThemeConsumer.jsm
--- a/toolkit/components/extensions/test/browser/browser.ini
+++ b/toolkit/components/extensions/test/browser/browser.ini
@@ -20,10 +20,9 @@ support-files =
 [browser_ext_themes_toolbar_fields_focus.js]
 [browser_ext_themes_toolbar_fields.js]
 [browser_ext_themes_toolbars.js]
 [browser_ext_themes_toolbarbutton_icons.js]
 [browser_ext_themes_toolbarbutton_colors.js]
 [browser_ext_themes_theme_transition.js]
 [browser_ext_themes_arrowpanels.js]
 [browser_ext_themes_tab_selected.js]
-[browser_ext_themes_autocomplete_popup.js]
-[browser_ext_themes_sanitization.js]
+[browser_ext_themes_autocomplete_popup.js]
\ No newline at end of file
deleted file mode 100644
--- a/toolkit/components/extensions/test/browser/browser_ext_themes_sanitization.js
+++ /dev/null
@@ -1,128 +0,0 @@
-"use strict";
-
-// This test checks color sanitization in various situations
-
-add_task(async function test_sanitization_invalid() {
-  // This test checks that invalid values are sanitized
-  let extension = ExtensionTestUtils.loadExtension({
-    manifest: {
-      "theme": {
-        "colors": {
-          "accentcolor": ACCENT_COLOR,
-          "textcolor": TEXT_COLOR,
-          "toolbar_bottom_separator": "ntimsfavoriteblue",
-        },
-      },
-    },
-  });
-
-  let docEl = document.documentElement;
-
-  let transitionPromise = waitForTransition(docEl, "background-color");
-  await extension.startup();
-  await transitionPromise;
-
-  let toolbox = document.querySelector("#navigator-toolbox");
-  Assert.equal(
-    window.getComputedStyle(toolbox, "::after").borderBottomColor,
-    "rgb(0, 0, 0)",
-    "All invalid values should always compute to black."
-  );
-
-  await extension.unload();
-});
-
-add_task(async function test_sanitization_css_variables() {
-  // This test checks that CSS variables are sanitized
-  let extension = ExtensionTestUtils.loadExtension({
-    manifest: {
-      "theme": {
-        "colors": {
-          "accentcolor": ACCENT_COLOR,
-          "textcolor": TEXT_COLOR,
-          "toolbar_bottom_separator": "var(--arrowpanel-dimmed)",
-        },
-      },
-    },
-  });
-
-  let docEl = document.documentElement;
-
-  let transitionPromise = waitForTransition(docEl, "background-color");
-  await extension.startup();
-  await transitionPromise;
-
-  let toolbox = document.querySelector("#navigator-toolbox");
-  Assert.equal(
-    window.getComputedStyle(toolbox, "::after").borderBottomColor,
-    "rgb(0, 0, 0)",
-    "All CSS variables should always compute to black."
-  );
-
-  await extension.unload();
-});
-
-add_task(async function test_sanitization_transparent() {
-  // This test checks whether transparent values are applied properly
-  let extension = ExtensionTestUtils.loadExtension({
-    manifest: {
-      "theme": {
-        "colors": {
-          "accentcolor": ACCENT_COLOR,
-          "textcolor": TEXT_COLOR,
-          "toolbar_top_separator": "transparent",
-          "toolbar_bottom_separator": "transparent",
-        },
-      },
-    },
-  });
-
-  let docEl = document.documentElement;
-
-  let transitionPromise = waitForTransition(docEl, "background-color");
-  await extension.startup();
-  await transitionPromise;
-
-  let navbar = document.querySelector("#nav-bar");
-  Assert.ok(
-    window.getComputedStyle(navbar).boxShadow.includes("rgba(0, 0, 0, 0)"),
-    "Top separator should be transparent"
-  );
-
-  let toolbox = document.querySelector("#navigator-toolbox");
-  Assert.equal(
-    window.getComputedStyle(toolbox, "::after").borderBottomColor,
-    "rgba(0, 0, 0, 0)",
-    "Bottom separator should be transparent"
-  );
-
-  await extension.unload();
-});
-
-add_task(async function test_sanitization_transparent_accentcolor() {
-  // This test checks whether transparent accentcolor falls back to white.
-  let extension = ExtensionTestUtils.loadExtension({
-    manifest: {
-      "theme": {
-        "colors": {
-          "accentcolor": "transparent",
-          "textcolor": TEXT_COLOR,
-        },
-      },
-    },
-  });
-
-  let docEl = document.documentElement;
-
-  let transitionPromise = waitForTransition(docEl, "background-color");
-  await extension.startup();
-  await transitionPromise;
-
-  Assert.equal(
-    window.getComputedStyle(docEl).backgroundColor,
-    "rgb(255, 255, 255)",
-    "Accent color should be white",
-  );
-
-  await extension.unload();
-});
--- a/toolkit/modules/LightweightThemeConsumer.jsm
+++ b/toolkit/modules/LightweightThemeConsumer.jsm
@@ -7,17 +7,17 @@ var EXPORTED_SYMBOLS = ["LightweightThem
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 
 const toolkitVariableMap = [
   ["--lwt-accent-color", {
     lwtProperty: "accentcolor",
     processColor(rgbaChannels, element) {
-      if (!rgbaChannels || rgbaChannels.a == 0) {
+      if (!rgbaChannels) {
         return "white";
       }
       // Remove the alpha channel
       const {r, g, b} = rgbaChannels;
       return `rgb(${r}, ${g}, ${b})`;
     }
   }],
   ["--lwt-text-color", {
@@ -204,24 +204,27 @@ function _sanitizeCSSColor(doc, cssColor
   if (!cssColor) {
     return null;
   }
   // style.color normalizes color values and rejects invalid ones, so a
   // simple round trip gets us a sanitized color value.
   let span = doc.createElementNS("http://www.w3.org/1999/xhtml", "span");
   span.style.color = cssColor;
   cssColor = doc.defaultView.getComputedStyle(span).color;
+  if (cssColor == "rgba(0, 0, 0, 0)") {
+    return null;
+  }
   return cssColor;
 }
 
 function _parseRGBA(aColorString) {
   if (!aColorString) {
     return null;
   }
   var rgba = aColorString.replace(/(rgba?\()|(\)$)/g, "").split(",");
   rgba = rgba.map(x => parseFloat(x));
   return {
     r: rgba[0],
     g: rgba[1],
     b: rgba[2],
-    a: 3 in rgba ? rgba[3] : 1,
+    a: rgba[3] || 1,
   };
 }