| <meta name="viewport" content="width=device-width"> |
| <script src="../../../resources/js-test.js"></script> |
| <script src="../../../resources/ui-helper.js"></script> |
| <p id="manual-instructions" class="hide">To run this test by hand, place the text insertion point before the 'h' in the text below and press Control + k.</p> |
| <div id="test" contenteditable="true">ah</div> |
| window.jsTestIsAsync = true; |
| let testElement = document.getElementById("test"); |
| let mutationObserver = null; |
| function handleMutation() |
| mutationObserver.disconnect(); |
| shouldBeEqualToString('document.getElementById("test").textContent', "a"); |
| document.body.removeChild(testElement); |
| document.getElementById("manual-instructions").classList.remove("hidden"); |
| mutationObserver = new MutationObserver(handleMutation); |
| mutationObserver.observe(testElement, { subtree:true, characterData: true }); |
| window.getSelection().setBaseAndExtent(testElement.firstChild, 1, testElement.firstChild, 1); // Put caret before the 'h'. |
| UIHelper.keyDown("k", ["ctrlKey"]); |
| await UIHelper.activateElement(testElement); |
| testElement.addEventListener("focus", handleFocus, { once: true }); |
| description("Tests that pressing Control + k in a content-editable field deletes to the end of the paragraph."); |