Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /clipboard-apis/events/copy-event.html - WPT Dashboard Interop Dashboard
<!doctype html>
<title>The copy event</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<div id=log></div>
<button id="copy">Trigger copy</button>
<input id="copyTarget" value="this text should be copied">
<script>
async_test(t => {
let button = document.getElementById("copy");
button.addEventListener("click", function(e) {
let input = document.getElementById("copyTarget");
input.focus();
input.select();
document.execCommand("copy");
});
document.oncopy = t.step_func_done(event => {
// Nothing can be asserted about the event target until
// assert_equals(event.target, document.body, 'event.target');
assert_true(event.isTrusted, 'event.isTrusted');
assert_true(event.composed, 'event.composed');
});
test_driver.click(button);
});
</script>