double-click-range-selection-in-list-item.html (2099B)
1 <!DOCTYPE html> 2 <meta charset="utf-8" /> 3 <title> 4 This test is for testing the range selection of list item on double 5 click. 6 </title> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/resources/testdriver.js"></script> 10 <script src="/resources/testdriver-actions.js"></script> 11 <script src="/resources/testdriver-vendor.js"></script> 12 <style> 13 .inline-block { 14 display: inline-block; 15 width: 50px; 16 height: 20px; 17 background-color: lightblue; 18 } 19 </style> 20 <div> 21 <ul> 22 <li id="first">First</li> 23 <li>Second</li> 24 </ul> 25 </div> 26 <div> 27 This is some 28 <span id="atomicinline" class="inline-block">atomicinline</span> text. 29 </div> 30 <script> 31 function runTests() { 32 promise_test(async () => { 33 const first = document.getElementById("first"); 34 first.focus(); 35 let actions = new test_driver.Actions() 36 .pointerMove(0, 0, { origin: "viewport" }) 37 .pointerDown() 38 .pointerUp() 39 .pointerDown() 40 .pointerUp(); 41 await actions.send(); 42 const selection = window.getSelection(); 43 let selectedText = selection.toString(); 44 assert_equals( 45 selectedText, 46 "First", 47 "Selected Text Should be equal to first list item" 48 ); 49 }, "Double click on one list item should not select more than one list item"); 50 51 promise_test(async () => { 52 const atomic_inline = document.getElementById("atomicinline"); 53 atomic_inline.focus(); 54 let actions = new test_driver.Actions() 55 .pointerMove(0, 0, { origin: atomic_inline }) 56 .pointerDown() 57 .pointerUp() 58 .pointerDown() 59 .pointerUp(); 60 await actions.send(); 61 const selection = window.getSelection(); 62 let selectedText = selection.toString(); 63 assert_equals( 64 selectedText, 65 "atomicinline", 66 "Selected Text Should be equal to atomicinline" 67 ); 68 }, "Double click on one text item should select only one text item"); 69 } 70 71 window.addEventListener("load", runTests, { once: true }); 72 </script>