OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>text field selection: select()</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 <textarea>foobar</textarea> |
| 10 <script> |
| 11 var input_types = ["text", "search", "tel", "url", "password"], |
| 12 t1 = async_test("select() on textarea queues select event"), |
| 13 q1 = false; |
| 14 |
| 15 input_types.forEach(function(type) { |
| 16 var input = document.createElement("input"), |
| 17 t = async_test("select() on input type " + type + " queues select event"
), |
| 18 q = false; |
| 19 t.step(function() { |
| 20 input.type = type; |
| 21 input.value = "foobar"; |
| 22 document.body.appendChild(input); |
| 23 input.onselect = t.step_func_done(function(e) { |
| 24 assert_true(q, "event should be queued"); |
| 25 assert_true(e.isTrusted, "event is trusted"); |
| 26 assert_true(e.bubbles, "event bubbles"); |
| 27 assert_false(e.cancelable, "event is not cancelable"); |
| 28 }); |
| 29 input.select(); |
| 30 q=true; |
| 31 }); |
| 32 }); |
| 33 |
| 34 document.querySelector("textarea").onselect = t1.step_func_done(function(e) { |
| 35 assert_true(q1, "event should be queued"); |
| 36 assert_true(e.isTrusted, "event is trusted"); |
| 37 assert_true(e.bubbles, "event bubbles"); |
| 38 assert_false(e.cancelable, "event is not cancelable"); |
| 39 }); |
| 40 |
| 41 t1.step(function() { |
| 42 document.querySelector("textarea").select(); |
| 43 q1=true; |
| 44 }); |
| 45 </script> |
OLD | NEW |