diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/clipboard-apis/clipboard-events-synthetic.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/clipboard-apis/clipboard-events-synthetic.html')
-rw-r--r-- | testing/web-platform/tests/clipboard-apis/clipboard-events-synthetic.html | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/testing/web-platform/tests/clipboard-apis/clipboard-events-synthetic.html b/testing/web-platform/tests/clipboard-apis/clipboard-events-synthetic.html new file mode 100644 index 0000000000..8786829752 --- /dev/null +++ b/testing/web-platform/tests/clipboard-apis/clipboard-events-synthetic.html @@ -0,0 +1,32 @@ +<!doctype html> +<title>synthetic clipboard events should not be composed</title> +<link rel="help" href="https://w3c.github.io/clipboard-apis/#clipboard-event-copy"> +<link rel="help" href="https://w3c.github.io/clipboard-apis/#clipboard-event-cut"> +<link rel="help" href="https://w3c.github.io/clipboard-apis/#clipboard-event-paste"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id=log></div> +<script> +const EVENTS = [ 'copy', 'cut', 'paste' ]; + +function testEvent(eventName, init, composed_flag_expectation, testName) { + async_test(test => { + document.addEventListener(eventName, test.step_func_done(e => { + assert_false(e.isTrusted, `synthetic ${eventName} event is untrusted`); + assert_equals(e.composed, composed_flag_expectation, + `composed flag should be ${composed_flag_expectation}`); + })); + const event = new ClipboardEvent(eventName, init); + document.dispatchEvent(event); + }, testName); +} + +EVENTS.forEach(name => { + testEvent(name, { bubbles: true, cancellable: true }, false, + `Unspecified synthetic ${name} event should not be composed.`); + testEvent(name, { bubbles: true, cancelable: true, composed: true }, true, + `Synthetic ${name} event can be explicitly composed.`); + testEvent(name, { bubbles: true, cancelable: true, composed: false }, false, + `Synthetic ${name} event can be explicitly uncomposed.`); +}); +</script> |