Backed out changeset 1d2f59732f03 (bug 1195349) for test_cssColor.js failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Sun, 30 Aug 2015 17:33:38 -0400
changeset 260042 810257543b7cefaac9d60f16f1684e7516b3e674
parent 260041 f72069ed655ccb5a4f237ffbd17d5f07a37d624d
child 260043 4ff42aa327c39115013d5ce30a791d9b2fe8f849
push id29298
push userryanvm@gmail.com
push dateMon, 31 Aug 2015 02:09:10 +0000
treeherdermozilla-central@f2518b8a7b97 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1195349
milestone43.0a1
backs out1d2f59732f03e6538e56e8e65242c4a5b83ac4db
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 1d2f59732f03 (bug 1195349) for test_cssColor.js failures.
toolkit/devtools/css-color.js
toolkit/devtools/tests/unit/test_cssColor.js
toolkit/devtools/tests/unit/xpcshell.ini
--- a/toolkit/devtools/css-color.js
+++ b/toolkit/devtools/css-color.js
@@ -52,38 +52,34 @@ const SPECIALVALUES = new Set([
 
 function CssColor(colorValue) {
   this.newColor(colorValue);
 }
 
 module.exports.colorUtils = {
   CssColor: CssColor,
   rgbToHsl: rgbToHsl,
-  setAlpha: setAlpha,
-  classifyColor: classifyColor
+  setAlpha: setAlpha
 };
 
 /**
  * Values used in COLOR_UNIT_PREF
  */
 CssColor.COLORUNIT = {
   "authored": "authored",
   "hex": "hex",
   "name": "name",
   "rgb": "rgb",
   "hsl": "hsl"
 };
 
 CssColor.prototype = {
   _colorUnit: null,
 
-  // The value as-authored.
   authored: null,
-  // A lower-cased copy of |authored|.
-  lowerCased: null,
 
   get colorUnit() {
     if (this._colorUnit === null) {
       let defaultUnit = Services.prefs.getCharPref(COLOR_UNIT_PREF);
       this._colorUnit = CssColor.COLORUNIT[defaultUnit];
     }
     return this._colorUnit;
   },
@@ -111,17 +107,17 @@ CssColor.prototype = {
       let tuple = this._getRGBATuple();
       return !(tuple.r || tuple.g || tuple.b || tuple.a);
     } catch(e) {
       return false;
     }
   },
 
   get specialValue() {
-    return SPECIALVALUES.has(this.lowerCased) ? this.authored : null;
+    return SPECIALVALUES.has(this.authored) ? this.authored : null;
   },
 
   get name() {
     let invalidOrSpecialValue = this._getInvalidOrSpecialValue();
     if (invalidOrSpecialValue !== false) {
       return invalidOrSpecialValue;
     }
 
@@ -170,64 +166,64 @@ CssColor.prototype = {
   },
 
   get rgb() {
     let invalidOrSpecialValue = this._getInvalidOrSpecialValue();
     if (invalidOrSpecialValue !== false) {
       return invalidOrSpecialValue;
     }
     if (!this.hasAlpha) {
-      if (this.lowerCased.startsWith("rgb(")) {
-        // The color is valid and begins with rgb(.
+      if (this.authored.startsWith("rgb(")) {
+        // The color is valid and begins with rgb(. Return the authored value.
         return this.authored;
       }
       let tuple = this._getRGBATuple();
       return "rgb(" + tuple.r + ", " + tuple.g + ", " + tuple.b + ")";
     }
     return this.rgba;
   },
 
   get rgba() {
     let invalidOrSpecialValue = this._getInvalidOrSpecialValue();
     if (invalidOrSpecialValue !== false) {
       return invalidOrSpecialValue;
     }
-    if (this.lowerCased.startsWith("rgba(")) {
-      // The color is valid and begins with rgba(.
+    if (this.authored.startsWith("rgba(")) {
+      // The color is valid and begins with rgba(. Return the authored value.
         return this.authored;
     }
     let components = this._getRGBATuple();
     return "rgba(" + components.r + ", " +
                      components.g + ", " +
                      components.b + ", " +
                      components.a + ")";
   },
 
   get hsl() {
     let invalidOrSpecialValue = this._getInvalidOrSpecialValue();
     if (invalidOrSpecialValue !== false) {
       return invalidOrSpecialValue;
     }
-    if (this.lowerCased.startsWith("hsl(")) {
-      // The color is valid and begins with hsl(.
+    if (this.authored.startsWith("hsl(")) {
+      // The color is valid and begins with hsl(. Return the authored value.
       return this.authored;
     }
     if (this.hasAlpha) {
       return this.hsla;
     }
     return this._hsl();
   },
 
   get hsla() {
     let invalidOrSpecialValue = this._getInvalidOrSpecialValue();
     if (invalidOrSpecialValue !== false) {
       return invalidOrSpecialValue;
     }
-    if (this.lowerCased.startsWith("hsla(")) {
-      // The color is valid and begins with hsla(.
+    if (this.authored.startsWith("hsla(")) {
+      // The color is valid and begins with hsla(. Return the authored value.
       return this.authored;
     }
     if (this.hasAlpha) {
       let a = this._getRGBATuple().a;
       return this._hsl(a);
     }
     return this._hsl(1);
   },
@@ -255,21 +251,17 @@ CssColor.prototype = {
 
   /**
    * Change color
    *
    * @param  {String} color
    *         Any valid color string
    */
   newColor: function(color) {
-    // Store a lower-cased version of the color to help with format
-    // testing.  The original text is kept as well so it can be
-    // returned when needed.
-    this.lowerCased = color.toLowerCase();
-    this.authored = color;
+    this.authored = color.toLowerCase();
     return this;
   },
 
   nextColorUnit: function() {
     // Reorder the formats array to have the current format at the
     // front so we can cycle through.
     let formats = ["authored", "hex", "hsl", "rgb", "name"];
     let putOnEnd = formats.splice(0, formats.indexOf(this.colorUnit));
@@ -322,17 +314,17 @@ CssColor.prototype = {
     let tuple = DOMUtils.colorToRGBA(this.authored);
 
     tuple.a = parseFloat(tuple.a.toFixed(1));
 
     return tuple;
   },
 
   _hsl: function(maybeAlpha) {
-    if (this.lowerCased.startsWith("hsl(") && maybeAlpha === undefined) {
+    if (this.authored.startsWith("hsl(") && maybeAlpha === undefined) {
       // We can use it as-is.
       return this.authored;
     }
 
     let {r, g, b} = this._getRGBATuple();
     let [h,s,l] = rgbToHsl([r,g,b]);
     if (maybeAlpha !== undefined) {
       return "hsla(" + h + ", " + s + "%, " + l + "%, " + maybeAlpha + ")";
@@ -418,32 +410,11 @@ function setAlpha(colorValue, alpha) {
   if (!(alpha >= 0 && alpha <= 1)) {
     alpha = 1;
   }
 
   let { r, g, b } = color._getRGBATuple();
   return "rgba(" + r + ", " + g + ", " + b + ", " + alpha + ")";
 }
 
-/**
- * Given a color, classify its type as one of the possible color
- * units, as known by |CssColor.colorUnit|.
- *
- * @param  {String} value
- *         The color, in any form accepted by CSS.
- * @return {String}
- *         The color classification, one of "rgb", "hsl", "hex", or "name".
- */
-function classifyColor(value) {
-  value = value.toLowerCase();
-  if (value.startsWith("rgb(") || value.startsWith("rgba(")) {
-    return CssColor.COLORUNIT.rgb;
-  } else if (value.startsWith("hsl(") || value.startsWith("hsla(")) {
-    return CssColor.COLORUNIT.hsl;
-  } else if (/^#[0-9a-f]+$/.exec(value)) {
-    return CssColor.COLORUNIT.hex;
-  }
-  return CssColor.COLORUNIT.name;
-}
-
 loader.lazyGetter(this, "DOMUtils", function () {
   return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
 });
deleted file mode 100644
--- a/toolkit/devtools/tests/unit/test_cssColor.js
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
-   http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Test classifyColor.
-
-"use strict";
-
-const loader = new DevToolsLoader();
-const require = loader.require;
-const {colorUtils} = require("devtools/css-color");
-
-const CLASSIFY_TESTS = [
-  { input: "rgb(255,0,192)", output: "rgb" },
-  { input: "RGB(255,0,192)", output: "rgb" },
-  { input: "rgba(255,0,192, 0.25)", output: "rgb" },
-  { input: "hsl(5, 5, 5)", output: "hsl" },
-  { input: "hsla(5, 5, 5, 0.25)", output: "hsl" },
-  { input: "hSlA(5, 5, 5, 0.25)", output: "hsl" },
-  { input: "#f0c", output: "hex" },
-  { input: "#fe01cb", output: "hex" },
-  { input: "#FE01CB", output: "hex" },
-  { input: "blue", output: "name" },
-  { input: "orange", output: "name" }
-];
-
-function run_test() {
-  for (let test of CLASSIFY_TESTS) {
-    let result = colorUtils.classifyColor(test.input);
-    equal(result, test.output, "test classifyColor(" + test.input + ")");
-  }
-}
--- a/toolkit/devtools/tests/unit/xpcshell.ini
+++ b/toolkit/devtools/tests/unit/xpcshell.ini
@@ -11,13 +11,12 @@ support-files =
 [test_fetch-http.js]
 [test_fetch-resource.js]
 [test_independent_loaders.js]
 [test_invisible_loader.js]
 [test_safeErrorString.js]
 [test_defineLazyPrototypeGetter.js]
 [test_async-utils.js]
 [test_consoleID.js]
-[test_cssColor.js]
 [test_prettifyCSS.js]
 [test_require_lazy.js]
 [test_require.js]
 [test_stack.js]