| <!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> |