OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <title>The selection interface members</title> |
| 3 <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"> |
| 4 <link rel="help" href="https://html.spec.whatwg.org/multipage/#textFieldSelectio
n"> |
| 5 <script src="../../../../../../resources/testharness.js"></script> |
| 6 <script src="../../../../../../resources/testharnessreport.js"></script> |
| 7 <div id="log"></div> |
| 8 <script> |
| 9 test(function() { |
| 10 var valid = ["text", "search", "url", "tel", "email", "password"]; |
| 11 var invalid = ["hidden", "datetime", "date", "month", "week", "datetime-local"
, |
| 12 "number", "range", "color", "checkbox", "radio", "button", |
| 13 "file", "submit", "image", "reset"]; |
| 14 valid.forEach(function(aType) { |
| 15 test(function() { |
| 16 var input = document.createElement("input"); |
| 17 input.type = aType; |
| 18 assert_equals(input.type, aType, "Input type unsupported") |
| 19 input.select(); |
| 20 var a = input.selectionStart; |
| 21 input.selectionStart = 0; |
| 22 a = input.selectionEnd; |
| 23 input.selectionEnd = 0; |
| 24 input.setSelectionRange(0, 0); |
| 25 }, "Selection attributes should apply to type " + aType) |
| 26 }) |
| 27 |
| 28 invalid.forEach(function(aType) { |
| 29 test(function() { |
| 30 var input = document.createElement("input"); |
| 31 input.type = aType; |
| 32 assert_equals(input.type, aType, "Input type unsupported") |
| 33 assert_throws("INVALID_STATE_ERR", function() { input.select(); }, "Should
throw with type " + aType); |
| 34 assert_throws("INVALID_STATE_ERR", function() { var a = input.selectionSta
rt; }); |
| 35 assert_throws("INVALID_STATE_ERR", function() { input.selectionStart = 0;
}); |
| 36 assert_throws("INVALID_STATE_ERR", function() { var a = input.selectionEnd
; }); |
| 37 assert_throws("INVALID_STATE_ERR", function() { input.selectionEnd = 0; })
; |
| 38 assert_throws("INVALID_STATE_ERR", function() { input.setSelectionRange(0,
0); }); |
| 39 }, "Selection attributes should not apply to type " + aType) |
| 40 }) |
| 41 }); |
| 42 </script> |
OLD | NEW |