OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../../resources/js-test.js"></script> |
| 3 <body> |
| 4 <div id="divTag" contenteditable='true' onpaste='handlepaste(this,event)' oncopy
='handlecopy(this,event)' oncut='handlecut(this,event)'>DefaultText</div> |
| 5 |
| 6 <script> |
| 7 description("Tests clipboard synthetic events"); |
| 8 |
| 9 function handlepaste(elem,e) |
| 10 { |
| 11 if(e && e.clipboardData && e.clipboardData.getData) { |
| 12 elem.innerHTML = e.clipboardData.getData('text/plain'); |
| 13 } |
| 14 } |
| 15 |
| 16 function handlecopy(elem,e) |
| 17 { |
| 18 if(e && e.clipboardData && e.clipboardData.getData) { |
| 19 elem.innerHTML = e.clipboardData.getData('text/plain'); |
| 20 } |
| 21 } |
| 22 |
| 23 function handlecut(elem,e) |
| 24 { |
| 25 if(e && e.clipboardData && e.clipboardData.getData) { |
| 26 elem.innerHTML = e.clipboardData.getData('text/plain'); |
| 27 } |
| 28 } |
| 29 |
| 30 var cutevent = new ClipboardEvent('cut', { data: 'hellodata', dataType: 'text/pl
ain' }); |
| 31 var copyevent = new ClipboardEvent('copy', { data: 'hellodata', dataType: 'text/
plain' }); |
| 32 var pasteevent = new ClipboardEvent('paste', { data: 'hellodata', dataType: 'tex
t/plain' }); |
| 33 |
| 34 var divtag = document.getElementById("divTag"); |
| 35 divtag.dispatchEvent(cutevent); |
| 36 shouldBeEqualToString("divTag.textContent", "helloData"); |
| 37 |
| 38 divtag.dispatchEvent(copyevent); |
| 39 shouldBeEqualToString("divTag.textContent", "helloData"); |
| 40 |
| 41 divtag.dispatchEvent(pasteevent); |
| 42 shouldBeEqualToString("divTag.textContent", "helloData"); |
| 43 |
| 44 </script> |
| 45 </body> |
OLD | NEW |