[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.22
[framework/web/webkit-efl.git] / LayoutTests / inspector / styles / styles-invalid-color-values.html
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/elements-test.js"></script>
5 <script>
6 function test()
7 {
8     var colors = [
9         // Each of these is red. Some may need to be clipped to [0, 255].
10         'red',
11         '#F00',
12         'rgb(255,0,0)',
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%)
16
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)
20     ];
21
22     InspectorTest.runTestSuite([
23         function testColors(next)
24         {
25             for (var i = 0; i < colors.length; ++i)
26                 dumpColorRepresentationsForColor(colors[i]);
27             next();
28         },
29     ]);
30
31     function dumpColorRepresentationsForColor(colorString)
32     {
33         try {
34             var color = new WebInspector.Color(colorString);
35         } catch (e) {
36             InspectorTest.addResult("FAIL: Error parsing color '" + colorString + "'.");
37             return;
38         }
39
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))
48                 continue;
49             // Advanced colors do not have HEX representations.
50             if (!color.simple && (colorFormat === cf.ShortHEX || colorFormat === cf.HEX))
51                 continue;
52             // If there is no ShortHEX then skip it.
53             if (colorFormat === cf.ShortHEX && !color.hasShortHex())
54                 continue;
55             // If there is no nickname, then skip it.
56             if (colorFormat === cf.Nickname && !color.nickname)
57                 continue;
58             InspectorTest.addResult('  ' + colorFormat + ": " + color.toString(colorFormat));
59         }
60     }
61 }
62 </script>
63 </head>
64
65 <body onload="runTest()">
66 <p>
67 Tests that the displayed string for colors correctly handles clipped CSS values and RGB percentages.
68 </p>
69
70 </body>
71 </html>