-
Notifications
You must be signed in to change notification settings - Fork 305
Should event dispatch check that the event target is in a fully active realm? #1084
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Note that this appears to be enforced at the EventTarget level, not at the AbortController/AbortSignal level or at the Event level: https://jsfiddle.net/wL5evuh3/3/. Given that this is about the EventTarget itself, and thus isn't covered by the Web IDL issue you list, probably the check would have to be at https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke . You might think we could factor it out to surround all of https://dom.spec.whatwg.org/#concept-event-dispatch but that would probably not do the right thing if the first listener removed the frame. (In that case I assume subsequent listeners should not run... but someone should test.) |
Nice, right, this isn't specific to AbortSignal --- just using that as an example because that's just how I discovered this.
Re: WebIDL, I was curious what should happen if constructing an object in a realm whose global's document is detached. This happens earlier (step 2 of fire an event), but Blink doesn't create the wrapper until much later. I'll test the "detached during an event with subsequent handlers" case. I was thinking about that as well and was planning to write a WPT for that assuming we make a spec change. I agree that the check can't happen too early because if this case. |
It looks like all the engines don't run subsequent listeners after the event target's context gets detached. For Blink and WebKit, this follows from where we're checking this; for Gecko, I think the listeners get cleared on detach, so iteration over the listeners stops after detach. And yeah, there would need to be a check in https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke to account for detaching from a listener. I'll try to send a PR next week along with some tests. |
cc @smaug---- |
I can't find in the DOM or WebIDL specs where such a check exists; apologies if I missed it.
The scenario is (jsfiddle):
controller
) in its realm and hangs it off of its parentcontroller.signal
controller.abort()
is called in the parent page's contextShould the event handler run?
This is similar to whatwg/webidl#993, but it's the event target that is in a "detached realm", not the event listener or call to
controller.abort()
.All the engines are consistent though — no one runs the event listener:
I was a bit surprised by the behavior, but given that no engine is running these, would it make sense to add an explicit check (assuming I didn't miss it) so the spec is in sync, and if so, thoughts on where?
The text was updated successfully, but these errors were encountered: