blob: f8ea4b37687da5043f7ad5652d372059e9e19966 [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, copy any text and try to paste into the input field. The value of the input should not change.`);
var allowPaste = false;
(function() {
if (!window.internals || !window.eventSender || !window.testRunner)
return;
document.querySelector("input").focus();
})();
function handleBeforeInput(event)
{
if (allowPaste)
return;
if (event.inputType == "insertFromPaste")
event.preventDefault();
}
function handleFocus()
{
document.querySelector("input").select();
Markup.dump("field", "initial value");
testRunner.execCommand("Cut");
Markup.dump("field", "after the cut");
testRunner.execCommand("Paste");
Markup.dump("field", "after prevented paste");
allowPaste = true;
testRunner.execCommand("Paste");
Markup.dump("field", "after allowed paste");
}
</script>
</body>
</html>