Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'abort' event on AbortSignal should be isTrusted: true #35748

Closed
Jamesernator opened this issue Oct 22, 2020 · 2 comments
Closed

'abort' event on AbortSignal should be isTrusted: true #35748

Jamesernator opened this issue Oct 22, 2020 · 2 comments
Assignees
Labels
events Issues and PRs related to the events subsystem / EventEmitter. test Issues and PRs related to the tests.

Comments

@Jamesernator
Copy link

Jamesernator commented Oct 22, 2020

  • Version: 15.0.0
  • Platform: linux
  • Subsystem: events

This is a fairly minor thing, but might be relied upon and that's the fact that when .abort() is called on AbortController the isTrusted flag should be set.

For example this should print true:

const controller = new AbortController();
controller.signal.addEventListener('abort', event => console.log(event.isTrusted));
controller.abort();

Possible implementation:

It may be sufficient to just provide a way for the EventTarget constructor to mark events as trusted for that EventTarget e.g.:

let markAsTrusted;
const myTarget = new EventTarget(_markAsTrusted => markAsTrusted = _markAsTrusted);
const trustedEvent = markAsTrusted(new Event("my-event"));
myTarget.addEventListener("my-event", event => console.log(event.isTrusted));

myTarget.dispatchEvent(trustedEvent); // prints true

const trustedEvent2 = markAsTrusted(new Event("my-event"));
const myTarget2 = new EventTarget();
myTarget.dispatchEvent(trustedEvent); // throws Error, as this event has not been marked as trusted by this EventTarget but rather a different EventTarget
@PoojaDurgad PoojaDurgad added the events Issues and PRs related to the events subsystem / EventEmitter. label Oct 22, 2020
@benjamingr
Copy link
Member

Good catch

@benjamingr
Copy link
Member

I'll make a PR

@benjamingr benjamingr added the test Issues and PRs related to the tests. label Oct 26, 2020
@benjamingr benjamingr self-assigned this Oct 26, 2020
benjamingr added a commit to benjamingr/io.js that referenced this issue Oct 26, 2020
The AbortController abort event is trusted, currently we fire all
events with isTrusted: false. Allow dispatching events
internally with `isTrusted: true` and add a test for it.

Co-Authored-By: ExE Boss <3889017+ExE-Boss@users.noreply.github.com>
Fixes: nodejs#35748
targos pushed a commit that referenced this issue Nov 3, 2020
The AbortController abort event is trusted, currently we fire all
events with isTrusted: false. Allow dispatching events
internally with `isTrusted: true` and add a test for it.

Co-Authored-By: ExE Boss <3889017+ExE-Boss@users.noreply.github.com>
Fixes: #35748

PR-URL: #35811
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit to targos/node that referenced this issue Apr 24, 2021
The AbortController abort event is trusted, currently we fire all
events with isTrusted: false. Allow dispatching events
internally with `isTrusted: true` and add a test for it.

Co-Authored-By: ExE Boss <3889017+ExE-Boss@users.noreply.github.com>
Fixes: nodejs#35748

PR-URL: nodejs#35811
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit to targos/node that referenced this issue Apr 26, 2021
The AbortController abort event is trusted, currently we fire all
events with isTrusted: false. Allow dispatching events
internally with `isTrusted: true` and add a test for it.

Co-Authored-By: ExE Boss <3889017+ExE-Boss@users.noreply.github.com>
Fixes: nodejs#35748

PR-URL: nodejs#35811
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit to targos/node that referenced this issue Apr 30, 2021
The AbortController abort event is trusted, currently we fire all
events with isTrusted: false. Allow dispatching events
internally with `isTrusted: true` and add a test for it.

Co-Authored-By: ExE Boss <3889017+ExE-Boss@users.noreply.github.com>
Fixes: nodejs#35748

PR-URL: nodejs#35811
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue Apr 30, 2021
The AbortController abort event is trusted, currently we fire all
events with isTrusted: false. Allow dispatching events
internally with `isTrusted: true` and add a test for it.

Co-Authored-By: ExE Boss <3889017+ExE-Boss@users.noreply.github.com>
Fixes: #35748

PR-URL: #35811
Backport-PR-URL: #38386
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
events Issues and PRs related to the events subsystem / EventEmitter. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants