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