| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> | 2 <meta charset="utf-8"> |
| 3 <title>The constraint validation API Test: element.reportValidity()</title> | 3 <title>The constraint validation API Test: element.reportValidity()</title> |
| 4 <link rel="author" title="Intel" href="http://www.intel.com/"> | 4 <link rel="author" title="Intel" href="http://www.intel.com/"> |
| 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-cva-reportval
idity"> | 5 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-cva-reportval
idity"> |
| 6 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-constraint-va
lidation-api"> | 6 <link rel="help" href="https://html.spec.whatwg.org/multipage/#the-constraint-va
lidation-api"> |
| 7 <script src="/resources/testharness.js"></script> | 7 <script src="/resources/testharness.js"></script> |
| 8 <script src="/resources/testharnessreport.js"></script> | 8 <script src="/resources/testharnessreport.js"></script> |
| 9 <script src="support/validator.js"></script> | 9 <script src="support/validator.js"></script> |
| 10 <div id="log"></div> | 10 <div id="log"></div> |
| 11 <script> | 11 <script> |
| 12 var testElements = [ | 12 var testElements = [ |
| 13 { | 13 { |
| 14 tag: "input", | 14 tag: "input", |
| 15 types: ["text", "search", "tel", "password"], | 15 types: ["text", "search", "tel", "password"], |
| 16 testData: [ | 16 testData: [ |
| 17 {conditions: {}, expected: true, name: "[target] no constraint"}, | 17 {conditions: {}, expected: true, name: "[target] no constraint"}, |
| 18 {conditions: {maxLength: "4", value: "abcdef"}, expected: false, name: "
[target] suffering from being too long", dirty: true}, | 18 {conditions: {maxLength: "4", value: "abcdef"}, expected: true, name: "[
target] not suffering from being too long", dirty: true}, |
| 19 {conditions: {pattern: "[A-Z]", value: "abc"}, expected: false, name: "[
target] suffering from a pattern mismatch"}, | 19 {conditions: {pattern: "[A-Z]", value: "abc"}, expected: false, name: "[
target] suffering from a pattern mismatch"}, |
| 20 {conditions: {required: true, value: ""}, expected: false, name: "[targe
t] suffering from being missing"} | 20 {conditions: {required: true, value: ""}, expected: false, name: "[targe
t] suffering from being missing"} |
| 21 ] | 21 ] |
| 22 }, | 22 }, |
| 23 { | 23 { |
| 24 tag: "input", | 24 tag: "input", |
| 25 types: ["url"], | 25 types: ["url"], |
| 26 testData: [ | 26 testData: [ |
| 27 {conditions: {}, expected: true, name: "[target] no constraint"}, | 27 {conditions: {}, expected: true, name: "[target] no constraint"}, |
| 28 {conditions: {maxLength: "20", value: "http://www.example.com"}, expecte
d: false, name: "[target] suffering from being too long", dirty: true}, | 28 {conditions: {maxLength: "20", value: "http://www.example.com"}, expecte
d: true, name: "[target] not suffering from being too long", dirty: true}, |
| 29 {conditions: {pattern: "http://www.example.com", value: "http://www.exam
ple.net"}, expected: false, name: "[target] suffering from a pattern mismatch"}, | 29 {conditions: {pattern: "http://www.example.com", value: "http://www.exam
ple.net"}, expected: false, name: "[target] suffering from a pattern mismatch"}, |
| 30 {conditions: {value: "abc"}, expected: false, name: "[target] suffering
from a type mismatch"}, | 30 {conditions: {value: "abc"}, expected: false, name: "[target] suffering
from a type mismatch"}, |
| 31 {conditions: {required: true, value: ""}, expected: false, name: "[targe
t] suffering from being missing"} | 31 {conditions: {required: true, value: ""}, expected: false, name: "[targe
t] suffering from being missing"} |
| 32 ] | 32 ] |
| 33 }, | 33 }, |
| 34 { | 34 { |
| 35 tag: "input", | 35 tag: "input", |
| 36 types: ["email"], | 36 types: ["email"], |
| 37 testData: [ | 37 testData: [ |
| 38 {conditions: {}, expected: true, name: "[target] no constraint"}, | 38 {conditions: {}, expected: true, name: "[target] no constraint"}, |
| 39 {conditions: {maxLength: "10", value: "test@example.com"}, expected: fal
se, name: "[target] suffering from being too long", dirty: true}, | 39 {conditions: {maxLength: "10", value: "test@example.com"}, expected: tru
e, name: "[target] not suffering from being too long", dirty: true}, |
| 40 {conditions: {pattern: "test@example.com", value: "test@example.net"}, e
xpected: false, name: "[target] suffering from a pattern mismatch"}, | 40 {conditions: {pattern: "test@example.com", value: "test@example.net"}, e
xpected: false, name: "[target] suffering from a pattern mismatch"}, |
| 41 {conditions: {value: "abc"}, expected: false, name: "[target] suffering
from a type mismatch"}, | 41 {conditions: {value: "abc"}, expected: false, name: "[target] suffering
from a type mismatch"}, |
| 42 {conditions: {required: true, value: ""}, expected: false, name: "[targe
t] suffering from being missing"} | 42 {conditions: {required: true, value: ""}, expected: false, name: "[targe
t] suffering from being missing"} |
| 43 ] | 43 ] |
| 44 }, | 44 }, |
| 45 { | 45 { |
| 46 tag: "input", | 46 tag: "input", |
| 47 types: ["datetime-local"], | 47 types: ["datetime-local"], |
| 48 testData: [ | 48 testData: [ |
| 49 {conditions: {}, expected: true, name: "[target] no constraint"}, | 49 {conditions: {}, expected: true, name: "[target] no constraint"}, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 types: [], | 136 types: [], |
| 137 testData: [ | 137 testData: [ |
| 138 {conditions: {}, expected: true, name: "[target] no constraint"}, | 138 {conditions: {}, expected: true, name: "[target] no constraint"}, |
| 139 {conditions: {required: true, value: ""}, expected: false, name: "[targe
t] suffering from being missing"} | 139 {conditions: {required: true, value: ""}, expected: false, name: "[targe
t] suffering from being missing"} |
| 140 ] | 140 ] |
| 141 } | 141 } |
| 142 ]; | 142 ]; |
| 143 | 143 |
| 144 validator.run_test(testElements, "reportValidity"); | 144 validator.run_test(testElements, "reportValidity"); |
| 145 </script> | 145 </script> |
| OLD | NEW |