| <!DOCTYPE html> |
| <script src="../../resources/js-test.js"></script> |
| <script> |
| var copyEventSeen; |
| var cutEventSeen; |
| |
| function runTest() |
| { |
| if (window.testRunner) |
| window.testRunner.setJavaScriptCanAccessClipboard(false); |
| else |
| return; |
| clickButton("copy"); |
| clickButton("cut"); |
| } |
| |
| function clickButton(id) |
| { |
| var button = document.getElementById(id); |
| eventSender.mouseMoveTo(button.offsetLeft + button.offsetWidth / 2, button.offsetTop + button.offsetHeight / 2); |
| eventSender.mouseDown(); |
| eventSender.mouseUp(); |
| } |
| |
| function onClickCopy() |
| { |
| copyEventSeen = false; |
| shouldBeTrue("document.execCommand('copy')"); |
| shouldBeTrue("copyEventSeen"); |
| } |
| |
| function onClickCut() |
| { |
| cutEventSeend = false; |
| shouldBeTrue("document.execCommand('cut')"); |
| shouldBeTrue("cutEventSeen"); |
| } |
| |
| function onCopy() |
| { |
| copyEventSeen = true; |
| } |
| |
| function onCut() |
| { |
| cutEventSeen = true; |
| } |
| </script> |
| <body onload="runTest()" oncopy="onCopy()" oncut="onCut()"> |
| <p>To manually test, click one of the buttons below. The result should be two 'PASS' events for either button. |
| <div> |
| <button id="copy" onclick="onClickCopy()">Copy</button> |
| <button id="cut" onclick="onClickCut()">Cut</button> |
| </div> |
| <div id="console"></div> |
| </body> |