| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Named Colors Test</title> | 4 <title>Named Colors Test</title> |
| 5 <script> | 5 <script> |
| 6 | 6 |
| 7 if (window.testRunner) | 7 if (window.testRunner) |
| 8 testRunner.dumpAsText(); | 8 testRunner.dumpAsText(); |
| 9 | 9 |
| 10 // Named colors and their rgb values as per the css3 specification. | 10 // Named colors and their rgb values as per the CSS Color specification. |
| 11 // http://www.w3.org/TR/css3-color/#svg-color | 11 // http://dev.w3.org/csswg/css-color/#named-colors |
| 12 var colors = [ | 12 var colors = [ |
| 13 ['aliceblue', '240,248,255'], | 13 ['aliceblue', '240,248,255'], |
| 14 ['antiquewhite', '250,235,215'], | 14 ['antiquewhite', '250,235,215'], |
| 15 ['aqua', '0,255,255'], | 15 ['aqua', '0,255,255'], |
| 16 ['aquamarine', '127,255,212'], | 16 ['aquamarine', '127,255,212'], |
| 17 ['azure', '240,255,255'], | 17 ['azure', '240,255,255'], |
| 18 ['beige', '245,245,220'], | 18 ['beige', '245,245,220'], |
| 19 ['bisque', '255,228,196'], | 19 ['bisque', '255,228,196'], |
| 20 ['black', '0,0,0'], | 20 ['black', '0,0,0'], |
| 21 ['blanchedalmond', '255,235,205'], | 21 ['blanchedalmond', '255,235,205'], |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 ['palegreen', '152,251,152'], | 122 ['palegreen', '152,251,152'], |
| 123 ['paleturquoise', '175,238,238'], | 123 ['paleturquoise', '175,238,238'], |
| 124 ['palevioletred', '219,112,147'], | 124 ['palevioletred', '219,112,147'], |
| 125 ['papayawhip', '255,239,213'], | 125 ['papayawhip', '255,239,213'], |
| 126 ['peachpuff', '255,218,185'], | 126 ['peachpuff', '255,218,185'], |
| 127 ['peru', '205,133,63'], | 127 ['peru', '205,133,63'], |
| 128 ['pink', '255,192,203'], | 128 ['pink', '255,192,203'], |
| 129 ['plum', '221,160,221'], | 129 ['plum', '221,160,221'], |
| 130 ['powderblue', '176,224,230'], | 130 ['powderblue', '176,224,230'], |
| 131 ['purple', '128,0,128'], | 131 ['purple', '128,0,128'], |
| 132 ['rebeccapurple', '102,51,153'], |
| 132 ['red', '255,0,0'], | 133 ['red', '255,0,0'], |
| 133 ['rosybrown', '188,143,143'], | 134 ['rosybrown', '188,143,143'], |
| 134 ['royalblue', '65,105,225'], | 135 ['royalblue', '65,105,225'], |
| 135 ['saddlebrown', '139,69,19'], | 136 ['saddlebrown', '139,69,19'], |
| 136 ['salmon', '250,128,114'], | 137 ['salmon', '250,128,114'], |
| 137 ['sandybrown', '244,164,96'], | 138 ['sandybrown', '244,164,96'], |
| 138 ['seagreen', '46,139,87'], | 139 ['seagreen', '46,139,87'], |
| 139 ['seashell', '255,245,238'], | 140 ['seashell', '255,245,238'], |
| 140 ['sienna', '160,82,45'], | 141 ['sienna', '160,82,45'], |
| 141 ['silver', '192,192,192'], | 142 ['silver', '192,192,192'], |
| (...skipping 20 matching lines...) Expand all Loading... |
| 162 function testColor(colorName, expected) | 163 function testColor(colorName, expected) |
| 163 { | 164 { |
| 164 var element = document.createElement("div"); | 165 var element = document.createElement("div"); |
| 165 var statusSpan = document.createElement("span"); | 166 var statusSpan = document.createElement("span"); |
| 166 element.appendChild(statusSpan); | 167 element.appendChild(statusSpan); |
| 167 var colorSpan = document.createElement("span"); | 168 var colorSpan = document.createElement("span"); |
| 168 colorSpan.appendChild(document.createTextNode(colorName)); | 169 colorSpan.appendChild(document.createTextNode(colorName)); |
| 169 colorSpan.style.backgroundColor = colorName; | 170 colorSpan.style.backgroundColor = colorName; |
| 170 element.appendChild(colorSpan); | 171 element.appendChild(colorSpan); |
| 171 document.body.appendChild(element); | 172 document.body.appendChild(element); |
| 172 | 173 |
| 173 var value = document.defaultView.getComputedStyle(colorSpan, "").getProp
ertyValue("background-color"); | 174 var value = document.defaultView.getComputedStyle(colorSpan, "").getProp
ertyValue("background-color"); |
| 174 var actual = value.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/).splice(1).joi
n(','); | 175 var actual = value.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/).splice(1).joi
n(','); |
| 175 if (actual == expected) { | 176 if (actual == expected) { |
| 176 statusSpan.appendChild(document.createTextNode('PASS ')); | 177 statusSpan.appendChild(document.createTextNode('PASS ')); |
| 177 element.appendChild(document.createTextNode(' is ' + actual)); | 178 element.appendChild(document.createTextNode(' is ' + actual)); |
| 178 } else { | 179 } else { |
| 179 statusSpan.appendChild(document.createTextNode('FAIL ')); | 180 statusSpan.appendChild(document.createTextNode('FAIL ')); |
| 180 element.appendChild(document.createTextNode(' was ' + actual + ', ex
pected ' + expected)); | 181 element.appendChild(document.createTextNode(' was ' + actual + ', ex
pected ' + expected)); |
| 181 } | 182 } |
| 182 } | 183 } |
| 183 | 184 |
| 184 function test() | 185 function test() |
| 185 { | 186 { |
| 186 for (var color, i = 0; color = colors[i]; i++) { | 187 for (var color, i = 0; color = colors[i]; i++) { |
| 187 testColor(color[0], color[1]); | 188 testColor(color[0], color[1]); |
| 188 } | 189 } |
| 189 } | 190 } |
| 190 | 191 |
| 191 </script> | 192 </script> |
| 192 </head> | 193 </head> |
| 193 <body onload="test()"> | 194 <body onload="test()"> |
| 194 </body> | 195 </body> |
| 195 </html> | 196 </html> |
| OLD | NEW |