OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>text field selection</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/#textFieldSelection"
> |
| 6 <script src="../../../../../../resources/testharness.js"></script> |
| 7 <script src="../../../../../../resources/testharnessreport.js"></script> |
| 8 <div id="log"></div> |
| 9 <script> |
| 10 var types = ["hidden", "email", "datetime", "date", "month", "week", "time", "
number", "range", "color", "checkbox", "radio", "file", "submit", "image", "rese
t", "button"]; //types for which the API doesn't apply |
| 11 var types2 = ["text", "search", "tel", "url", "password"]; //types for which t
he API applies |
| 12 |
| 13 types.forEach(function(type){ |
| 14 test(function(){ |
| 15 var el = document.createElement("input"); |
| 16 el.type = type; |
| 17 assert_throws("InvalidStateError", function(){ |
| 18 el.selectionStart; |
| 19 }); |
| 20 assert_throws("InvalidStateError", function(){ |
| 21 el.selectionEnd; |
| 22 }); |
| 23 assert_throws("InvalidStateError", function(){ |
| 24 el.selectionDirection; |
| 25 }); |
| 26 assert_throws("InvalidStateError", function(){ |
| 27 el.setRangeText("foobar"); |
| 28 }); |
| 29 assert_throws("InvalidStateError", function(){ |
| 30 el.setSelectionRange(0, 1); |
| 31 }); |
| 32 }, "text field selection for the input " + type); |
| 33 }); |
| 34 |
| 35 types2.forEach(function(type) { |
| 36 test(function() { |
| 37 var el = document.createElement("input"); |
| 38 el.type = type; |
| 39 assert_equals(el.selectionStart, 0); |
| 40 assert_equals(el.selectionEnd, 0); |
| 41 el.selectionStart = 1; |
| 42 el.selectionEnd = 1; |
| 43 el.selectionDirection = "forward"; |
| 44 el.setRangeText("foobar"); |
| 45 el.setSelectionRange(0, 1); |
| 46 }, "text field selection for the input " + type); |
| 47 }); |
| 48 </script> |
OLD | NEW |