Clipboard events should be composed.

Automate some of the copy event tests which tested for this, since there
seems we/WPT don't have a lot of coverage for them.

Differential Revision: https://phabricator.services.mozilla.com/D103428

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1689317
gecko-commit: d5eeffaaf436f5aeb01d2ac8868027a8266158ee
gecko-reviewers: smaug
diff --git a/clipboard-apis/events/copy-event-manual.html b/clipboard-apis/events/copy-event-manual.html
deleted file mode 100644
index 9f9f195..0000000
--- a/clipboard-apis/events/copy-event-manual.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!doctype html>
-<title>The copy event</title>
-<link rel="help" href="https://w3c.github.io/clipboard-apis/#clipboard-event-copy">
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<div id=log></div>
-<p>Select and copy any part of this text to continue.
-<script>
-setup({explicit_timeout: true});
-async_test(t => {
-  document.oncopy = t.step_func_done(event => {
-    // Nothing can be asserted about the event target until
-    // https://github.com/w3c/clipboard-apis/issues/70 is resolved.
-    // assert_equals(event.target, document.body, 'event.target');
-    assert_true(event.isTrusted, 'event.isTrusted');
-    assert_true(event.composed, 'event.composed');
-  });
-});
-</script>
diff --git a/clipboard-apis/events/copy-event.html b/clipboard-apis/events/copy-event.html
new file mode 100644
index 0000000..c8c0593
--- /dev/null
+++ b/clipboard-apis/events/copy-event.html
@@ -0,0 +1,33 @@
+<!doctype html>
+<title>The copy event</title>
+<link rel="help" href="https://w3c.github.io/clipboard-apis/#clipboard-event-copy">
+<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
+    // https://github.com/w3c/clipboard-apis/issues/70 is resolved.
+    // 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>