blob: f387d705afd045dc415d3f17367f1820a0395b90 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>Simple test that custom clipboard MIME types can be set during copy events
and retrieved during paste events. The test can be manually run by copying
any text on this page and then pasting anywhere. On success, the word SUCCESS
will appear below.
<div id="log"></div>
<script>
function copy(event) {
event.clipboardData.setData('text', 'sample');
event.clipboardData.setData('custom-data', 'hello world');
event.preventDefault();
}
function paste(event) {
var failed = false;
if (event.clipboardData.types.indexOf('text/plain') < 0
|| event.clipboardData.types.indexOf('custom-data') < 0)
failed = true;
if (event.clipboardData.getData('text') != 'sample'
|| event.clipboardData.getData('custom-data') != 'hello world')
failed = true;
document.getElementById('log').innerText = failed ? 'FAILURE' : 'SUCCESS';
event.preventDefault();
}
document.body.addEventListener('copy', copy);
document.body.addEventListener('paste', paste);
function runTest() {
if (!window.testRunner)
return;
testRunner.dumpAsText();
document.execCommand('copy');
document.execCommand('paste');
}
runTest();
</script>
</body>
</html>