Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /input-events/textarea-insertfrompaste-type-inputevent-data-withnewline-atstart.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<html>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<textarea id="text" cols=60>Copying and pasting second line including interchange newline
at the start should set the event.data with the selected part for inputType
insertFromPaste</textarea>
<script>
const text = document.getElementById("text");
let eventData;
text.addEventListener('input', (evt) => {
if(evt.inputType == 'insertFromPaste')
eventData = evt.data;
});
test(function () {
text.focus();
// Selecting second line inluding interchange newline at start
text.setSelectionRange(61, 137);
const selectedData = getSelection().toString();
// Copy and paste should fire input event with inputType insertFromPaste.
document.execCommand("copy");
document.execCommand("paste");
// Event data should now be set with the second line of the text
assert_equals(selectedData, "\nat the start should set the event.data with the selected part for inputType");
assert_equals(eventData, selectedData);
}, 'Input event data for inputType insertFromPaste should be set');
</script>
</body>
</html>