summaryrefslogtreecommitdiffstats
path: root/layout/inspector/tests/test_color_to_rgba.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /layout/inspector/tests/test_color_to_rgba.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'layout/inspector/tests/test_color_to_rgba.html')
-rw-r--r--layout/inspector/tests/test_color_to_rgba.html55
1 files changed, 55 insertions, 0 deletions
diff --git a/layout/inspector/tests/test_color_to_rgba.html b/layout/inspector/tests/test_color_to_rgba.html
new file mode 100644
index 000000000..d8279e384
--- /dev/null
+++ b/layout/inspector/tests/test_color_to_rgba.html
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Test inDOMUtils::ColorToRGBA</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript;version=1.8">
+ let utils = SpecialPowers.Cc["@mozilla.org/inspector/dom-utils;1"]
+ .getService(SpecialPowers.Ci.inIDOMUtils);
+
+ testColor("red", {r:255, g:0, b:0, a:1});
+ testColor("#f00", {r:255, g:0, b:0, a:1});
+ testColor("#ff0000", {r:255, g:0, b:0, a:1});
+ testColor("ff0000", null);
+ testColor("rgb(255,0,0)", {r:255, g:0, b:0, a:1});
+ testColor("rgba(255,0,0)", {r:255, g:0, b:0, a:1});
+ testColor("rgb(255,0,0,0.7)", {r:255, g:0, b:0, a:0.7});
+ testColor("rgba(255,0,0,0.7)", {r:255, g:0, b:0, a:0.7});
+ testColor("rgb(50%,75%,60%)", {r:128, g:191, b:153, a:1});
+ testColor("rgba(50%,75%,60%)", {r:128, g:191, b:153, a:1});
+ testColor("rgb(100%,50%,25%,0.7)", {r:255, g:128, b:64, a:0.7});
+ testColor("rgba(100%,50%,25%,0.7)", {r:255, g:128, b:64, a:0.7});
+ testColor("hsl(320,30%,10%)", {r:33, g:17, b:28, a:1});
+ testColor("hsla(320,30%,10%)", {r:33, g:17, b:28, a:1});
+ testColor("hsl(170,60%,40%,0.9)", {r:40, g:163, b:142, a:0.9});
+ testColor("hsla(170,60%,40%,0.9)", {r:40, g:163, b:142, a:0.9});
+
+ function testColor(color, expected) {
+ let rgb = utils.colorToRGBA(color);
+
+ if (rgb === null) {
+ ok(expected === null, "color: " + color + " returns null");
+ return;
+ }
+
+ let {r, g, b, a} = rgb;
+
+ is(r, expected.r, "color: " + color + ", red component is converted correctly");
+ is(g, expected.g, "color: " + color + ", green component is converted correctly");
+ is(b, expected.b, "color: " + color + ", blue component is converted correctly");
+ is(Math.round(a * 10) / 10, expected.a, "color: " + color + ", alpha component is a converted correctly");
+ }
+ </script>
+</head>
+<body>
+<h1>Test inDOMUtils::ColorToRGBA</h1>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>