diff options
Diffstat (limited to 'testing/web-platform/tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/synthetic-errorevent-click.html')
-rw-r--r-- | testing/web-platform/tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/synthetic-errorevent-click.html | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/synthetic-errorevent-click.html b/testing/web-platform/tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/synthetic-errorevent-click.html new file mode 100644 index 0000000000..75a1772485 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/scripting/events/event-handler-processing-algorithm-error/synthetic-errorevent-click.html @@ -0,0 +1,78 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>Event handlers processing algorithm: click events using ErrorEvent</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-event-handler-processing-algorithm"> +<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> + +<div id="log"></div> + +<script> +"use strict"; +promise_test(t => { + document.onclick = t.step_func((...args) => { + assert_equals(args.length, 1); + return true; + }); + + const eventWatcher = new EventWatcher(t, document, "click"); + const promise = eventWatcher.wait_for("click").then(e => { + assert_equals(e.defaultPrevented, false); + }); + + document.dispatchEvent(new ErrorEvent("click", { cancelable: true })); + + return promise; +}, "click event is normal (return true does not cancel; one arg) on Document, with a synthetic ErrorEvent"); + +promise_test(t => { + window.onclick = t.step_func((...args) => { + assert_equals(args.length, 1); + return true; + }); + + const eventWatcher = new EventWatcher(t, window, "click"); + const promise = eventWatcher.wait_for("click").then(e => { + assert_equals(e.defaultPrevented, false); + }); + + window.dispatchEvent(new ErrorEvent("click", { cancelable: true })); + + return promise; +}, "click event is normal (return true does not cancel; one arg) on Window, with a synthetic ErrorEvent"); + +promise_test(t => { + const el = document.createElement("script"); + el.onclick = t.step_func((...args) => { + assert_equals(args.length, 1); + return true; + }); + + const eventWatcher = new EventWatcher(t, el, "click"); + const promise = eventWatcher.wait_for("click").then(e => { + assert_equals(e.defaultPrevented, false); + }); + + el.dispatchEvent(new ErrorEvent("click", { cancelable: true })); + + return promise; +}, "click event is normal (return true does not cancel; one arg) on a script element, with a synthetic ErrorEvent"); + +promise_test(t => { + const worker = new Worker("resources/no-op-worker.js"); + worker.onerror = t.step_func((...args) => { + assert_equals(args.length, 1); + return true; + }); + + const eventWatcher = new EventWatcher(t, worker, "click"); + const promise = eventWatcher.wait_for("click").then(e => { + assert_equals(e.defaultPrevented, false); + }); + + worker.dispatchEvent(new ErrorEvent("click", { cancelable: true })); + + return promise; +}, "click event is normal (return true does not cancel; one arg) on Worker, with a synthetic ErrorEvent"); +</script> |