forked from burg/timelapse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
can-read-in-copy-and-cut-events.html
42 lines (39 loc) · 1.18 KB
/
can-read-in-copy-and-cut-events.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
<head>
<script>
function log(text) {
var log = document.getElementById('log');
log.appendChild(document.createTextNode(text));
log.appendChild(document.createElement('br'));
}
function copyTest(e) {
e.clipboardData.setData('text/plain', 'copy test');
if (event.clipboardData.types.indexOf('text/plain') < 0 ||
event.clipboardData.getData('text/plain') != 'copy test')
log('copy: FAILED');
else
log('copy: SUCCESS');
}
function cutTest(e) {
e.clipboardData.setData('text/plain', 'cut test');
if (event.clipboardData.types.indexOf('text/plain') < 0 ||
event.clipboardData.getData('text/plain') != 'cut test')
log('cut: FAILED');
else
log('cut: SUCCESS');
}
function runTest() {
if (!window.testRunner)
return;
testRunner.dumpAsText();
document.execCommand('copy');
document.execCommand('cut');
}
</script>
</head>
<body onload="runTest()" oncopy="copyTest(event)" oncut="cutTest(event)">
<p>Simple test that data set during a copy/cut event can be read back. To run
the test manually, simply select any text and initiate a copy/cut operation.
<div id="log"></div>
</html>