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
Add tests for the realms involved in compiling event handlers #4988
Conversation
Firefox (nightly channel)Testing web-platform-tests at revision 4046209 All results1 test ran/html/webappapis/scripting/events/compile-event-handler-settings-objects.html
|
Chrome (unstable channel)Testing web-platform-tests at revision 7b7b8a0 All results1 test ran/html/webappapis/scripting/events/compile-event-handler-settings-objects.html
|
OK, these are ready to go. Encouragingly, they pass in Firefox, and the incumbent one fails in Chrome (which is encouraging because Chrome is known to "give up" on determining the incumbent in sufficiently-esoteric situations, of which this is probably one). |
I don't follow the entry settings test. What's foo.html? Why would that onload ever fire? I'm pretty sure error loads don't necessarily trigger onload... It might be better to use a URL that actually resolves to something there. Actually, I'm not sure I follow the incumbent settings test either. How does that test the incumbent global of a compiled event handler? Or is that not what it's trying to test? |
foo.html resolves to a 404 page, which fires the onload just fine... we can create a foo.html if you want though. I'm not sure about the incumbent global test. I just kind of tried to follow your instructions, but I admit not understanding them super-well. Why did you think return value conversion was relevant to the incumbent global? |
I guess I'm not sure why both Chrome and Firefox time out on that test, then, per test results above.
Because when the return value conversion is happening the incumbent global is whatever was pushed for the callback. So this test is testing the incumbent global that gets stored when window.onbeforeunload is assigned, but that has nothing to do with event handler compilation. You may want to leave that test and add one which does:
to test the incumbent set up with event handler compilation. |
And also possibly of interest is a |
They don't if you actually run it in a browser instead of in CI; very interesting. I'll try to see if I can get a good incumbent test working... |
…IDL attributes, for the incumbent case
OK, I worked on that, but now the test is failing in Firefox (the "source" ends up being the parent frame, not the iframe), which is unexpected given your comments in whatwg/html#2248 (comment)... |
That's odd. I just tried this locally
where
and I get |
Ah, I see. The problem is that a slight modification of that, where instead of clicking the button the outer frame does Can you think of a reason that would be? |
So first of all, that test is not navigating the subframe, just assigning a .src property on its window (as opposed to the iframe element). The beforeunload only fires when the whole page is unloaded. But that shouldn't affect the behavior. What does affect it is that gecko does NOT in fact set up an incumbent global on event handlers compiled from strings. Which means the incumbent global ends up being "yeah, whatever is on the stack" if there's script on the stack (and the entry global if there's nothing on the stack). But then if that incumbent global is not same origin-domain with the current global, we reset it to the current global. In the "unload the page via browser UI" case, there's actually privileged script that's part of the browser UI on the stack. So we get that as the incumbent, then it fails the same origin-domain check and we reset the incumbent to current. And our current at that point is the global of the postMessage function, which is the parent. Anyway, this is a bug in Gecko. Filed https://bugzilla.mozilla.org/show_bug.cgi?id=1342513 |
Ah, oops. But in the end, the upside of this that the tests and spec patch are good to merge? :) The test in this PR does not appear to have the iframe vs. contentWindow confusion. |
Yes, the test in the PR looks good to me! |
This fixes #2248 by ensuring that we convert the created JavaScript Function object to a Web IDL callback, with the appropriate callback context. While in the area, it also straightens out and clarifies some confusion around what exactly the event listener's "callback" is; it is now always a Web IDL callback, instead of sometimes being just an algorithm. It also adds a clarifying note as to why we go through the JavaScript stack-pushing steps. Tests: web-platform-tests/wpt#4988
This fixes whatwg#2248 by ensuring that we convert the created JavaScript Function object to a Web IDL callback, with the appropriate callback context. While in the area, it also straightens out and clarifies some confusion around what exactly the event listener's "callback" is; it is now always a Web IDL callback, instead of sometimes being just an algorithm. It also adds a clarifying note as to why we go through the JavaScript stack-pushing steps. Tests: web-platform-tests/wpt#4988
Follows whatwg/html#2286 and whatwg/html#2248.
This is WIP; ideally I'd like to also test incumbent settings object. Also the spec PR needs updates based on the results of my testing.
/cc @bzbarsky @Ms2ger