Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / pasteboard / clipboard-customData.html
blobf387d705afd045dc415d3f17367f1820a0395b90
1 <!DOCTYPE html>
2 <html>
3 <head>
4 </head>
5 <body>
6 <p>Simple test that custom clipboard MIME types can be set during copy events
7 and retrieved during paste events. The test can be manually run by copying
8 any text on this page and then pasting anywhere. On success, the word SUCCESS
9 will appear below.
10 <div id="log"></div>
11 <script>
12 function copy(event) {
13 event.clipboardData.setData('text', 'sample');
14 event.clipboardData.setData('custom-data', 'hello world');
15 event.preventDefault();
18 function paste(event) {
19 var failed = false;
20 if (event.clipboardData.types.indexOf('text/plain') < 0
21 || event.clipboardData.types.indexOf('custom-data') < 0)
22 failed = true;
23 if (event.clipboardData.getData('text') != 'sample'
24 || event.clipboardData.getData('custom-data') != 'hello world')
25 failed = true;
26 document.getElementById('log').innerText = failed ? 'FAILURE' : 'SUCCESS';
27 event.preventDefault();
29 document.body.addEventListener('copy', copy);
30 document.body.addEventListener('paste', paste);
32 function runTest() {
33 if (!window.testRunner)
34 return;
36 testRunner.dumpAsText();
37 document.execCommand('copy');
38 document.execCommand('paste');
40 runTest();
41 </script>
42 </body>
43 </html>