blob: e712a1e55a4c0bd47452ac8202641b443899a556 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<button onclick="runTest()">1. Copy</button>
<div><br></div>
<div id="source" oncopy="copy(event)" contenteditable>http://webkit.org/b/&#x1F914;?x=8 + 6</div>
<div id="destination" onpaste="paste(event)" contenteditable>2. Paste here</div>
<script>
const originalURL = document.getElementById('source').textContent;
function copy(event) {
event.clipboardData.setData('url', originalURL);
event.preventDefault();
}
function paste(event) {
parent.postMessage({
originalURL,
url: event.clipboardData.getData('url'),
types: event.clipboardData.types,
items: Array.from(event.clipboardData.items).map((item) => ({kind: item.kind, type: item.type})),
}, '*');
}
function runTest() {
if (window.internals)
internals.withUserGesture(() => { document.getElementById('source').focus(); });
document.execCommand('selectAll');
document.execCommand('copy');
if (window.internals)
internals.withUserGesture(() =>{ document.getElementById('destination').focus(); });
if (window.testRunner)
document.execCommand('paste');
}
if (window.testRunner)
runTest();
</script>
</body>
</html>