Re: [whatwg/dom] Support `AbortSignal`s in `addEventListener`s options to unsubscribe from events? (#911)

Thanks, I now ran the actual WPTs I wrote

<details>
./wpt run --channel dev --binary ../chromium/src/out/Default/Chromium.app/Contents/MacOS/Chromium chrome dom/events/AddEventListenerOptions-signal.html
</details>

```js
test(function() {
  let count = 0;
  function handler() {
    count++;
  }
  const et = new EventTarget();
  const controller = new AbortController();
  et.addEventListener('test', handler, { signal: controller.signal });
  et.dispatchEvent(new Event('test'));
  assert_equals(count, 1, "Adding a signal still adds a listener");
  et.dispatchEvent(new Event('test'));
  assert_equals(count, 2, "The listener was not added with the once flag");
  controller.abort();
  et.dispatchEvent(new Event('test'));
  assert_equals(count, 2, "Aborting on the controller removes the listener");
  et.addEventListener('test', handler, { signal: controller.signal });
  et.dispatchEvent(new Event('test'));
  assert_equals(count, 2, "Passing an aborted signal never adds the handler");
}, "Passing an AbortSignal to addEventListener options should allow removing a listener");
```

The following test (add a listener with an already aborted controller where the same listener was already added) seems to fail (and the "capture" one but that's already handled :])



-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/911#issuecomment-727167414

Received on Saturday, 14 November 2020 08:29:09 UTC