3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/elements-test.js"></script>
9 // Each of these is red. Some may need to be clipped to [0, 255].
13 'rgb(300,0,0)', // clipped to rgb(255,0,0)
14 'rgb(255,-10,0)', // clipped to rgb(255,0,0)
15 'rgb(110%, 0%, 0%)', // clipped to rgb(100%,0%,0%)
17 // Each of these has their alpha clipped [0.0, 1.0].
18 'rgba(255, 0, 0, -5)', // clipped to rgba(255,0,0,0)
19 'rgba(255, 0, 0, 5)', // clipped to rgba(255,0,0,1)
22 InspectorTest.runTestSuite([
23 function testColors(next)
25 for (var i = 0; i < colors.length; ++i)
26 dumpColorRepresentationsForColor(colors[i]);
31 function dumpColorRepresentationsForColor(colorString)
34 var color = new WebInspector.Color(colorString);
36 InspectorTest.addResult("FAIL: Error parsing color '" + colorString + "'.");
40 InspectorTest.addResult("");
41 InspectorTest.addResult("color: " + colorString);
42 InspectorTest.addResult(" simple: " + color.simple);
43 var cf = WebInspector.StylesSidebarPane.ColorFormat;
44 for (var colorFormatKey in cf) {
45 var colorFormat = cf[colorFormatKey];
46 // Simple colors do not have RGBA and HSLA representations.
47 if (color.simple && (colorFormat === cf.RGBA || colorFormat === cf.HSLA))
49 // Advanced colors do not have HEX representations.
50 if (!color.simple && (colorFormat === cf.ShortHEX || colorFormat === cf.HEX))
52 // If there is no ShortHEX then skip it.
53 if (colorFormat === cf.ShortHEX && !color.hasShortHex())
55 // If there is no nickname, then skip it.
56 if (colorFormat === cf.Nickname && !color.nickname)
58 InspectorTest.addResult(' ' + colorFormat + ": " + color.toString(colorFormat));
65 <body onload="runTest()">
67 Tests that the displayed string for colors correctly handles clipped CSS values and RGB percentages.