selection-not-application-textarea.html (1699B)
1 <!DOCTYPE html> 2 <meta charset=utf-8> 3 <title>text field selection (textarea)</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 test(function() { 11 var el = document.createElement("textarea"); 12 assert_equals(el.selectionStart, 0, "initial selectionStart"); 13 assert_equals(el.selectionEnd, 0, "initial selectionEnd"); 14 // The initial selection direction must be "none" if the platform supports that 15 // direction, or "forward" otherwise. 16 assert_in_array(el.selectionDirection, ["none", "forward"]); 17 18 const initialDirection = el.selectionDirection; 19 el.selectionDirection = "none"; 20 assert_equals(el.selectionDirection, initialDirection); 21 22 el.value = "foo"; 23 el.selectionStart = 1; 24 el.selectionEnd = 1; 25 el.selectionDirection = "forward"; 26 assert_equals(el.selectionStart, 1, "updated selectionStart"); 27 assert_equals(el.selectionEnd, 1, "updated selectionEnd"); 28 assert_equals(el.selectionDirection, "forward", "updated selectionDirection"); 29 30 el.setRangeText("foobar"); 31 el.setSelectionRange(0, 1); 32 assert_equals(el.selectionStart, 0, "final selectionStart"); 33 assert_equals(el.selectionEnd, 1, "final selectionEnd"); 34 assert_in_array(el.selectionDirection, ["none", "forward"]); 35 36 const finalDirection = el.selectionDirection; 37 el.finalDirection = "forward"; 38 assert_equals(el.selectionDirection, finalDirection); 39 }, "text field selection for the input textarea"); 40 </script>