selection-change-not-fired-if-selection-set-to-root.html (1105B)
1 <!doctype HTML> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/resources/testdriver.js"></script> 5 <script src="/resources/testdriver-vendor.js"></script> 6 <script src="../include/editor-test-utils.js"></script> 7 8 <body> 9 <div contenteditable="true" id="target"> 10 </div> 11 <script> 12 // Selectionchange event should not get fired if the selection is already set to the beginning of the root 13 promise_test(async () => { 14 let selectionChangeCount = 0; 15 const target = document.getElementById("target"); 16 await new test_driver.click(target); 17 await EditorTestUtils.waitForRender(); 18 document.addEventListener("selectionchange", () => ++selectionChangeCount); 19 await new test_driver.send_keys(target, "\uE003"); 20 await EditorTestUtils.waitForRender(); 21 assert_equals(selectionChangeCount, 0, "Selectionchange event should not get fired"); 22 }, "Selectionchange event should not get fired when the selection is already set to the beginning of the root "); 23 </script> 24 </body>