| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>Form input type=color</title> |
| 4 <link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org"> |
| 5 <link rel=help href="https://html.spec.whatwg.org/multipage/multipage/common-mic
rosyntaxes.html#colors"> |
| 6 <link rel=help href="https://html.spec.whatwg.org/multipage/multipage/states-of-
the-type-attribute.html#color-state-(type=color)"> |
| 7 <script src="../../../../../../resources/testharness.js"></script> |
| 8 <script src="../../../../../../resources/testharnessreport.js"></script> |
| 9 <div id="log"></div> |
| 10 <script> |
| 11 var colors = [ |
| 12 {value: "", expected: "#000000", testname: "Empty value should return #00000
0"}, |
| 13 {expected: "#000000", testname: "Missing value should return #000000"}, |
| 14 {value: "#ffffff", expected: "#ffffff", testname: "Valid simple color: shoul
d return #ffffff"}, |
| 15 {value: "#FFFFFF", expected: "#ffffff", testname: "Valid simple color (conta
ining LATIN CAPITAL LETTERS): should return #ffffff (converted to ASCII lowercas
e)"}, |
| 16 {value: "#0F0F0F", expected: "#0f0f0f", testname: "Zero-padding"}, |
| 17 {value: "#fff", expected: "#000000", testname: "Invalid simple color: not 7
characters long"}, |
| 18 {value: "fffffff", expected: "#000000", testname: "Invalid simple color: no
starting # sign"}, |
| 19 {value: "#gggggg", expected: "#000000", testname: "Invalid simple color: non
ASCII hex digits"}, |
| 20 {value: "foobar", expected: "#000000", testname: "Invalid simple color: foob
ar"}, |
| 21 {value: "#ffffff\u0000", expected: "#000000", testname: "Invalid color: trai
ling Null (U+0000)"}, |
| 22 {value: "#ffffff;", expected: "#000000", testname: "Invalid color: trailing
;"}, |
| 23 {value: " #ffffff", expected: "#000000", testname: "Invalid color: leading s
pace"}, |
| 24 {value: "#ffffff ", expected: "#000000", testname: "Invalid color: trailing
space"}, |
| 25 {value: " #ffffff ", expected: "#000000", testname: "Invalid color: leading+
trailing spaces"}, |
| 26 {value: "crimson", expected: "#000000", testname: "Invalid color: keyword cr
imson"}, |
| 27 {value: "bisque", expected: "#000000", testname: "Invalid color: keyword bis
que"}, |
| 28 {value: "currentColor", expected: "#000000", testname: "Invalid color: keywo
rd currentColor"}, |
| 29 {value: "transparent", expected: "#000000", testname: "Invalid color: keywor
d transparent"}, |
| 30 {value: "ActiveBorder", expected: "#000000", testname: "Invalid color: keywo
rd ActiveBorder"}, |
| 31 {value: "inherit", expected: "#000000", testname: "Invalid color: keyword in
herit"}, |
| 32 {value: "rgb(1,1,1)", expected: "#000000", testname: "Invalid color: rgb(1,1
,1)"}, |
| 33 {value: "rgb(1,1,1,1)", expected: "#000000", testname: "Invalid color: rgb(1
,1,1,1)"}, |
| 34 {value: "#FFFFF\u1F4A9", expected: "#000000", testname: "Invalid color: PILE
OF POO (U+1F4A9)"} |
| 35 ]; |
| 36 for (var i = 0; i < colors.length; i++) { |
| 37 var w = colors[i]; |
| 38 test(function() { |
| 39 var input = document.createElement("input"); |
| 40 input.type = "color"; |
| 41 input.value = w.value; |
| 42 assert_equals(input.value, w.expected); |
| 43 }, w.testname); |
| 44 } |
| 45 </script> |
| OLD | NEW |