-
Notifications
You must be signed in to change notification settings - Fork 312
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
Eliminate usage of entry and incumbent settings objects #922
Comments
I'd need to check them thoroughly but presume many of them actually implemented entry and incumbent. I changed For that change, I was referencing the example code in https://www.w3.org/TR/2016/WD-html51-20160503/webappapis.html#calling-scripts section the corresponding part of which in WHATWG version is now replaced with your recent patches that clarify those concepts. Having tried the example code with To sort them out in SW spec, I'd want to check once again if the goal is to make them all use current instead of entry and incumbent for both parsing urls and security checks? And don't we need any implementer/developer feedback on the behavior change? (I agree we should sort them out sooner than later but somewhat worry about the impact.) |
Sometimes it may be more appropriate to use relevant. Boris has argued that for URL parsing in particular that is better. (Note that inside constructors, the relevant settings object of the object being created is the current settings object, so we just use the latter.)
So far in this multi-globals work, it seems to not impact developers at all, since they mostly don't do weird multi-global things on purpose. Implementers have been largely indifferent as well, apart from the fact that only Firefox seems to have a perfectly-to-spec version of entry and incumbent. I think the way to proceed is to perform some tests and come up with a comprehensive plan for changing everything to current or relevant. Then we can see how well that matches existing service worker implementations. In the best case, it just aligns with implementations better, so the implementers don't care. In the worst case, both implementations have already done incumbent or entry, so this would be a change for them. If that's true then we should bring it up with implementers, and possibly not make the change. So I guess the first step is to write up tests for all the different uses. |
I've verified by code inspection that Chrome and Firefox seem to agree on the various places that this spec and fetch use "entry", documented in whatwg/html#1431. Most of them are around URL parsing. I think it would be ideal if implementers were willing to coordinate on a switch to the relevant settings object of the object on which the method is being called (or the current settings object in the case of constructors). This might require use counters if people think this change is risky; it seems very unlikely to be risky to me given how few developers do these sort of multi-global things, but maybe it's better to be safe than sorry. /cc @wanderview @mattto What would be a good next step here? Would writing up a spec PR with the changes I propose be a good way to concretize this? |
I'd like to get feedback from @wanderview and @matto if they're willing to change. It seems SW and window.open() are the ones that have been implemented using entry as spec'd. I'm into this change as the goal is to minimize the use of entry concept. I also believe it'd be better to make other instances (e.g. window.open()) consistent with the base rule if the change is not risky. If the implementers agree, I can update the spec. |
@wanderview, |
What does entry and incumbent mean in easy-to-understand language? |
Entry is enteredExecutionContext() in Blink. I'm not sure what the corresponding function to get the incumbent context in Blink. /cc @jeisinger Entry: https://html.spec.whatwg.org/multipage/webappapis.html#concept-entry-everything |
Thanks. Maybe the best way forward is to write the WPTs that would be affected by the change, and then see what the current implementations do and whether we expect the changes to be risky. Looking at the spec, the things that would be affected are:
|
+1 to seeing the wpt test changes. |
Awesome, thanks for being willing to work with us on this. I'll take the action item to write up some web platform tests. |
This one shouldn't really be effected since it's only callable from within a service worker, so there isn't more than one global you can reach that has that method. Also should be easy to change anyway since it hasn't shipped yet of course. Similar I don't think there are any issues around navigate(url) and openWindow(url), as both of these methods are similarly only exposed within service workers, where as far as I can tell all four settings objects would always be the same. |
Note that enteredExecutionContext returns the entry context, or the current context... so it's kinda random. In fact, we don't have an entered context during microtask execution, so if you try to invoke ServiceWorkerContainer.register in a promise handler you'll get different semantics compared to when running it in a regular task :-/ |
That's whatwg/html#1426 FYI |
This feels like v1, but feel free to change it. |
Pre F2F notes: Doesn't feel like there's much to discuss here. Just work to do. |
Is this really v1? |
It affects all impl, so yes? |
Spending a bit more time on this. EntryURL parsing would change:
No affect, since multiple globals cannot be present inside a service worker and these are only exposed there:
IncumbentNo affect, since multiple globals cannot be present inside a service worker and these are only exposed there:
postMessage (special case)
Todo:
|
This commit is part of the effort in w3c#922 to eliminate the use of entry and incumbent settings objects. It mostly just changes cases where all of relevant/current/entry/incumbent are equivalent, to use relevant. It also removes mention of "default action" for events, since that is not supposed to exist, and does some other tidying in the postMessage algorithms. There are no normative changes in this commit.
OK, here's the web platform tests for the three URL parsing cases that remain: web-platform-tests/wpt#3449 As you can see this requires some esoteric contortions to actually come up in practice. (They are written to demand relevant, which I think is more correct, so they will fail in Chrome and Firefox.) |
As noted above, I uploaded the web platform tests. Have people had a chance to review them, and hopefully agree with me that the change is doable? Is there anything else we can do to move this issue forward? |
Thanks for the tests. I agree this change is unlikely to break sites, and it makes sense. I'm willing to change Chrome implementation to conform to these tests. |
Fixes w3c#922. Web platform tests at web-platform-tests/wpt#3449. Part of the overall effort in whatwg/html#1431. In the process, fixes some ambiguity about how to parse URLs in the Link header, as previous it parsed relative to the entry settings object, which did not exist during this algorithm.
Works for me. Sorry for the delay in responding. (I really wish there was a need-info system in github.) Gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1298819 @domenic are you going to land the tests in the WPT repo? Or we can import them and uplift to WPT when we make the code changes. Not sure on time frame, though. |
@wanderview I guess I should get a reviewer to sign off on the tests? But they're ready to land if so. If people haven't seen, I also sent a spec PR: #963 |
Fixes w3c#922. Web platform tests at web-platform-tests/wpt#3449. Part of the overall effort in whatwg/html#1431. In the process, fixes some ambiguity about how to parse URLs in the Link header, as previous it parsed relative to the entry settings object, which did not exist during this algorithm.
Can someone sign-off on the corresponding tests PR at web-platform-tests/wpt#3449 ? |
Tests merged to WPT; I also filed a Blink issue at https://bugs.chromium.org/p/chromium/issues/detail?id=691008. |
Also filed an Edge issue for good measure, although I don't know if they implemented the old spec or new spec: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10902802/ |
According to the spec change, this changes to use the relevant settings object instead of the entry settings object to parse the script URL and the scope URL given to ServiceWorkerContainer.register() and ServiceWorkerContainer.getRegistration(). Before this CL, register() and getRegistration() used entered execution context to parse the URLs. After this CL, the methods use the execution context retrieved from ScriptState::getExecutionContext(). WPT: external/wpt/service-workers/service-worker/multi-globals/url-parsing.https.html Spec issue: w3c/ServiceWorker#922 Spec change: w3c/ServiceWorker@ec1aac2 BUG=691008 Review-Url: https://codereview.chromium.org/2691903005 Cr-Commit-Position: refs/heads/master@{#453033}
According to the spec change, this changes to use the relevant settings object instead of the entry settings object to parse the script URL and the scope URL given to ServiceWorkerContainer.register() and ServiceWorkerContainer.getRegistration(). Before this CL, register() and getRegistration() used entered execution context to parse the URLs. After this CL, the methods use the execution context retrieved from ScriptState::getExecutionContext(). WPT: external/wpt/service-workers/service-worker/multi-globals/url-parsing.https.html Spec issue: w3c/ServiceWorker#922 Spec change: w3c/ServiceWorker@ec1aac2 BUG=691008 Review-Url: https://codereview.chromium.org/2691903005 Cr-Commit-Position: refs/heads/master@{#453033}
See https://readable-email.org/list/public-script-coord/topic/multiple-globals-and-you. We'd like to stop using these in new specs. In addition, it seems to be the case that most places that use them, are not actually implemented that way in browsers.
It would be good to do an audit of this spec and see which globals are actually implemented in browsers, then update the spec to use those. In the rare cases where incumbent and entry are actually implemented as specced, it would be ideal to change implementations if possible.
For an example of how you can test implementations, see e.g. whatwg/html#1472 and whatwg/html#1473
The text was updated successfully, but these errors were encountered: