Skip to content

Should event dispatch check that the event target is in a fully active realm? #1084

Open
@shaseley

Description

@shaseley

I can't find in the DOM or WebIDL specs where such a check exists; apologies if I missed it.

The scenario is (jsfiddle):

  • A page has an iframe
  • The iframe creates a new AbortController (controller) in its realm and hangs it off of its parent
  • The parent page adds an event listener (added and defined in its realm) to controller.signal
  • The iframe gets removed
  • controller.abort() is called in the parent page's context

Should 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:

  • Blink and WebKit both early out in ~2.10 of inner invoke.
    • For Blink specifically, we can't create the JS wrapper for the event because the context is gone.
  • Gecko skips handling the event during EventTargetChainItem::HandleEvent() because the EventListenerManager is null (IIUC it got cleared during detach). I think this is during targeting, just prior to starting inner invoke.

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions