blob: b5b44ecf93c80ab2c7dda2ce231896d896207f64 [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;
internals.settings.setInputEventsEnabled(true);
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>