Open Bug 1888534 Opened 8 months ago

Constructor from unexpected global used for errors (failure in WPT dom/events/EventListener-handleEvent-cross-realm.html)

Categories

(Core :: DOM: Events, defect)

defect

Tracking

()

People

(Reporter: twisniewski, Unassigned)

References

(Blocks 1 open bug, )

Details

See https://wpt.fyi/results/dom/events/EventListener-handleEvent-cross-realm.html

We are currently the only browser failing the case EventListener is cross-realm callable revoked Proxy

But all of our errors here appear to be:
assert_equals: expected function "function TypeError() { [native code] }" but got function "function TypeError() { [native code] }"

Here's a reduced test-case:

<iframe name="eventListenerGlobalObject" srcdoc=""></iframe>
<script>
  window.onload = l => {
    const eventTarget = new EventTarget;
    const { proxy, revoke } = eventListenerGlobalObject.Proxy.revocable(() => {}, {});
    revoke();
    eventTarget.addEventListener("foo", proxy);

    eventListenerGlobalObject.addEventListener("error", ({ error}) => {
      console.log(error.constructor == eventListenerGlobalObject.TypeError);
    });
    eventTarget.dispatchEvent(new Event("foo"));
  };
</script>

We're failing the test-cases because while the error event is a TypeError, it's not equivalent to eventListenerGlobalObject.TypeError.

This is true even for the other test-cases in this WPT, so it's not strictly related to the proxy revocation. See for instance:

<iframe name="eventListenerGlobalObject" srcdoc=""></iframe>
<script>
  window.onload = l => {
    const eventTarget = new EventTarget;
    const eventListener = new eventListenerGlobalObject.Object;
    eventTarget.addEventListener("foo", eventListener);

    eventListenerGlobalObject.addEventListener("error", ({ error}) => {
      console.log(error.constructor == eventListenerGlobalObject.TypeError);
    });
    eventTarget.dispatchEvent(new Event("foo"));
  };
</script>
You need to log in before you can comment on or make changes to this bug.