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

Error reporting in MediaQueryList tests #28108

Open
szager-chromium opened this issue Mar 16, 2021 · 5 comments
Open

Error reporting in MediaQueryList tests #28108

szager-chromium opened this issue Mar 16, 2021 · 5 comments
Assignees

Comments

@szager-chromium
Copy link
Contributor

This looks fishy to me:

const eventWatcher = new EventWatcher(t, window, "error", waitForChangesReported);

const eventWatcher = new EventWatcher(t, window, "error", waitForChangesReported);

It's watching for an error event targeting the top-level window, but the MediaQueryList object comes from the iframe's window:

const mql = iframe.contentWindow.matchMedia(...);

... so I would expect any error events to target iframe.contentWindow rather than the top-level window. Shouldn't it be:

const eventWatcher = new EventWatcher(t, getWindow(mql), "error", waitForChangesReported);

?

Also -- and maybe I'm just showing my ignorance here -- where is it specified that when listener.handleEvent is non-callable, then an error event should be fired on the window? For chromium, at least, that is non-standard behavior.

@annevk
Copy link
Member

annevk commented Mar 17, 2021

This took me a while...

The combination of step 2.10 of https://dom.spec.whatwg.org/#concept-event-listener-inner-invoke and https://heycam.github.io/webidl/#call-a-user-objects-operation should have the relevant information for handleEvent.

I think the main thing that is unclear here is what global should get the exception.

It's not clear to me what global MediaQueryList is or should be created in and it's not clear to me how report the exception deals with globals. (Firefox seems to do this in a way that leads to passing the tests, if that makes sense is another matter.)

(whatwg/dom#624 seems somewhat related.)

cc @domenic @smaug---- @emilio

@shvaikalesh
Copy link
Member

I think the main thing that is unclear here is what global should get the exception.

report an exception is a bit vague with "using the global object specified by the relevant script's settings object" prose.

This reads to me as "lexical global object", which makes sense: it attempts to reach the user, either via "error" event or the console, so to maximize the chances of being seen, the report target is global object of currently executing script.

@annevk
Copy link
Member

annevk commented Mar 17, 2021

See also whatwg/html#958.

@smaug----
Copy link
Contributor

Isn't the global of MediaQueryList clear? It is the global of the document.
But the listener is from the parent window here, so handling of the error should happen there too.

@annevk
Copy link
Member

annevk commented Mar 25, 2021

For this example Chrome does seem to agree with that (though Safari does not), i.e., it alerts "Uncaught 1", not "hmmm".

<iframe></iframe>
<script>
onerror = e => alert(e)
onload = () => {
  frames[0].document.body.addEventListener("x", () => { throw 1 });
  frames[0].onerror = e => alert("hmmm");
  frames[0].document.body.dispatchEvent(new Event("x"));
}
</script>

Not clear why Chrome does it differently for the MediaQueryList case. @szager-chromium do you know?

(https://drafts.csswg.org/cssom-view/#dom-window-matchmedia doesn't say what the global should be, but it does seem reasonable that it matches that of the document (and the object on which the factory method was invoked). Hopefully that'll get fixed one day.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants