blob: c8f520f8b0b0e185b0ba689332bda21e69e1e6b4 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<div id="editable" contenteditable onbeforeinput=handleBeforeInput(event)>def</div>
<script src="../../resources/dump-as-markup.js"></script>
<script type="text/javascript">
Markup.description(`To manually test this, ensure that typing or attempting to delete text via the Delete key does not change the DOM.`);
var allowTyping = !!window.eventSender;
(function() {
if (!window.internals || !window.eventSender || !window.testRunner)
return;
document.querySelector("#editable").focus();
Markup.dump("editable", "initially");
eventSender.keyDown("a", []);
eventSender.keyDown("b", []);
eventSender.keyDown("c", []);
Markup.dump("editable", "after attempting to type (typing is allowed)");
allowTyping = false;
eventSender.keyDown("d", []);
eventSender.keyDown("e", []);
eventSender.keyDown("f", []);
Markup.dump("editable", "after attempting to type (typing is prohibited)");
testRunner.execCommand("DeleteForward");
testRunner.execCommand("DeleteBackward");
testRunner.execCommand("DeleteForward");
Markup.dump("editable", "after attempting to delete (deleting is prohibited)");
allowTyping = true;
testRunner.execCommand("DeleteBackward");
testRunner.execCommand("DeleteForward");
testRunner.execCommand("DeleteBackward");
Markup.dump("editable", "after attempting to delete (deleting is allowed)");
})();
function handleBeforeInput(event)
{
if (allowTyping)
return;
if (event.inputType === "insertText" || event.inputType === "deleteContentBackward" || event.inputType === "deleteContentForward")
event.preventDefault();
}
</script>
</body>
</html>