Skip to content

Commit

Permalink
Prototype of adding AbortController to addEventListener
Browse files Browse the repository at this point in the history
I2P: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/9396JedBBOM

This feature adds a new AbortSignal option, named "signal", to the
options parameter of addEventListener.
This new option can be used to remove the event listener with an
AbortController by calling abort().
More context: whatwg/dom#911

Bug: 1146467
Change-Id: I8ab1b93ec8be859c6876296fda4a9b808253c7d3
  • Loading branch information
josepharhar authored and chromium-wpt-export-bot committed Nov 11, 2020
1 parent 4cf34e3 commit b8d281f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions dom/abort/addEventListenerAbortController.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="author" title="Joey Arhar" href="mailto:jarhar@chromium.org">

<!-- This behavior has not been specified yet. See https://github.com/whatwg/dom/issues/911 -->

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>

<script>
test(t => {
const target = new EventTarget();
const controller = new AbortController();

target.addEventListener('testevent', t.step_func(() => {
assert_unreached('testevent should have been canceled by AbortController');
}), {signal: controller.signal});

controller.abort();
target.dispatchEvent(new Event('testevent'));
}, 'Tests support for EventController to cancel event listeners in addEventListener.');
</script>

0 comments on commit b8d281f

Please sign in to comment.