blob: f6b4b4f6e88ecc16d00229ef9502e25cd24142b4 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<input id="field" onfocus=handleFocus() value="helloworld" onbeforeinput=handleBeforeInput(event)></div>
<script src="../../resources/dump-as-markup.js"></script>
<script>
Markup.description(`To manually test this, select the text in the input and attempt to cut. The value of the input should not change.`);
var allowCut = false;
(function() {
if (!window.internals || !window.eventSender || !window.testRunner)
return;
internals.settings.setInputEventsEnabled(true);
document.querySelector("#field").focus();
})();
function handleBeforeInput(event)
{
if (allowCut)
return;
if (event.inputType === "deleteByCut")
event.preventDefault();
}
function handleFocus()
{
document.querySelector("#field").select();
Markup.dump("field", "initial value");
testRunner.execCommand("Cut");
Markup.dump("field", "after prevented cut");
allowCut = true;
testRunner.execCommand("Cut");
Markup.dump("field", "after allowed cut");
}
</script>
</body>
</html>