OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>Form input type=week</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/#weeks"> |
| 6 <link rel=help href="https://html.spec.whatwg.org/multipage/#week-state-(type=we
ek)"> |
| 7 <script src="../../../../../../resources/testharness.js"></script> |
| 8 <script src="../../../../../../resources/testharnessreport.js"></script> |
| 9 <div id="log"></div> |
| 10 <script> |
| 11 var weeks = [ |
| 12 {value: "", expected: "", testname: "empty value"}, |
| 13 {value: "2014-W52", expected: "2014-W52", testname: "Valid value: Value shou
ld be 2014-W52"}, |
| 14 {value: "2014-W53", expected: "", testname: "2014 has 52 weeks: Value should
be empty"}, |
| 15 {value: "2015-W53", expected: "2015-W53", testname: "2015 has 53 weeks: Valu
e should be 2015-W53"}, |
| 16 {value: "2014", expected: "", testname: "Invalid value: year only"}, |
| 17 {value: "2014W", expected: "", testname: "Invalid value: no week number"}, |
| 18 {value: "2014W52", expected: "", testname: "Invalid value: no '-' (U+002D)"}
, |
| 19 {value: "-W52", expected: "", testname: "Invalid value: yearless week"}, |
| 20 {value: "W52", expected: "", testname: "Invalid value: yearless week and no
'-' (U+002D)"}, |
| 21 {value: "2014-W03", attributes: { min: "2014-W02" }, expected: "2014-W03", t
estname: "Value >= min attribute"}, |
| 22 {value: "2014-W01", attributes: { min: "2014-W02" }, expected: "2014-W02", t
estname: "Value < min attribute"}, |
| 23 {value: "2014-W10", attributes: { max: "2014-W11" }, expected: "2014-W10", t
estname: "Value <= max attribute"}, |
| 24 {value: "2014-W12", attributes: { max: "2014-W11" }, expected: "2014-W11", t
estname: "Value > max attribute"} |
| 25 ]; |
| 26 for (var i = 0; i < weeks.length; i++) { |
| 27 var w = weeks[i]; |
| 28 test(function() { |
| 29 var input = document.createElement("input"); |
| 30 input.type = "week"; |
| 31 input.value = w.value; |
| 32 for(var attr in w.attributes) { |
| 33 input[attr] = w.attributes[attr]; |
| 34 } |
| 35 assert_equals(input.value, w.expected); |
| 36 }, w.testname); |
| 37 } |
| 38 </script> |
OLD | NEW |