blob: 6430e3c216b7e74330e71d47f7813cb57dfc7493 [file] [log] [blame]
<!DOCTYPE html>
<html>
<style>
html, body {
margin: 0;
font-family: -apple-system;
}
#source, #destination {
width: 100%;
margin: 0;
}
#destination {
border: 1px blue green;
height: 1024px;
}
#source {
font-size: 150px;
white-space: nowrap;
height: 200px;
}
</style>
<body>
<textarea id="source">Plain text</textarea>
<div id="destination" contenteditable></div>
<pre id="output"></pre>
</body>
<script>
// The contents of this `result` dictionary will contain a map of {event type => {MIME type => data}}.
result = {};
function updateResultWithEvent(event) {
const eventData = {};
for (const type of event.clipboardData.types)
eventData[type] = event.clipboardData.getData(type);
result[event.type] = eventData;
output.textContent = JSON.stringify(result, null, " ");
event.preventDefault();
}
source.setSelectionRange(0, source.value.length);
destination.addEventListener("paste", updateResultWithEvent);
if (window.testRunner && window.internals) {
internals.settings.setCustomPasteboardDataEnabled(true);
testRunner.dumpAsText();
testRunner.execCommand("Copy");
destination.focus();
testRunner.execCommand("Paste");
}
</script>
</html>