double-click-range-selection-in-floating-list-item.html (2035B)
1 <!DOCTYPE html> 2 <meta charset="utf-8" /> 3 <title> 4 This test is for testing the range selection of floating list item on 5 double 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 .fl, 14 li { 15 float: left; 16 margin-right: 40px; 17 } 18 </style> 19 <div> 20 <ul> 21 <li id="first">First</li> 22 <li>Second</li> 23 </ul> 24 </div> 25 <div> 26 <strong id="sfirst" class="fl">first</strong 27 ><strong class="fl">second</strong> 28 </div> 29 <script> 30 function runTests() { 31 promise_test(async () => { 32 const first = document.getElementById("first"); 33 first.focus(); 34 let actions = new test_driver.Actions() 35 .pointerMove(0, 0, { origin: first }) 36 .pointerDown() 37 .pointerUp() 38 .pointerDown() 39 .pointerUp(); 40 await actions.send(); 41 const selection = window.getSelection(); 42 let selectedText = selection.toString(); 43 assert_equals( 44 selectedText, 45 "First", 46 "Selected Text Should be equal to first list item" 47 ); 48 }, "Double click on one floating list item should not select more than one list item"); 49 50 promise_test(async () => { 51 const sfirst = document.getElementById("sfirst"); 52 sfirst.focus(); 53 let actions = new test_driver.Actions() 54 .pointerMove(0, 0, { origin: sfirst }) 55 .pointerDown() 56 .pointerUp() 57 .pointerDown() 58 .pointerUp(); 59 await actions.send(); 60 const selection = window.getSelection(); 61 let selectedText = selection.toString(); 62 assert_equals( 63 selectedText, 64 "first", 65 "Selected Text Should be equal to first list item" 66 ); 67 }, "Double click on one floating strong text should not select more than one item"); 68 } 69 70 window.addEventListener("load", runTests, { once: true }); 71 </script>