selection-direction-on-single-click.html (1303B)
1 <!DOCTYPE html> 2 <html> 3 <body> 4 <meta name="author" title="Sean Feng" href="mailto:sean@seanfeng.dev"> 5 <meta name="assert" content="Selection on clicks: direction should return none, forwad, or backward"> 6 <link rel="help" href="https://w3c.github.io/selection-api/#dom-selection-direction"> 7 <link rel="help" href="https://github.com/w3c/selection-api/issues/177"> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="/resources/testdriver.js"></script> 11 <script src="/resources/testdriver-actions.js"></script> 12 <script src='/resources/testdriver-vendor.js'></script> 13 <div id="container">hello, world</div> 14 <script> 15 16 promise_test(async () => { 17 container.innerHTML = 'hello, world'; 18 const click = new test_driver.Actions() 19 .pointerMove(0, 0, container.firstChild) 20 .pointerDown() 21 .pointerUp() 22 .send(); 23 await click; 24 25 const sel = getSelection(); 26 assert_equals(sel.anchorNode, container.firstChild); 27 assert_equals(sel.anchorOffset, 0); 28 assert_equals(sel.focusNode, container.firstChild); 29 assert_equals(sel.focusOffset, 0); 30 assert_true(sel.isCollapsed); 31 assert_equals(sel.direction, 'none'); 32 }, 'direction returns "none" when the selection is collapsed'); 33 34 </script> 35 </body> 36 </html>