-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Provide a hook for "being invoked cross origin"? #2112
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
Comments
Some browsers are experimenting with a few restrictions on cross-origin script: https://github.com/WICG/interventions/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20cross-origin is a partial list. It seems like this concept is a reasonable one to define once and reuse. I'm not sure it makes sense as an IDL attribute, as it's not clear that we'd have any standardized behavior. On the one hand, you have things like WICG/interventions#16 which modify the behavior of |
Why? The worker can be instantiated from an |
I have three main comments, I think:
I agree that there's not much point to an IDL attribute here. |
|
Yes. See https://html.spec.whatwg.org/multipage/browsers.html#concept-document-salvageable In addition to that, it's not really clear what https://html.spec.whatwg.org/multipage/browsers.html#a-browsing-context-is-discarded means in practice, which means that even if a document is not salvageable it's not clear whether the browsing contexts inside it really go away when it's navigated away from, in terms of reachability from their documents. If they do then Domenic's steps have a problem, because either "Let context be settings's [responsible browsing context]" returns null or something or "If settings has no [responsible document], return false" would return false or something along those lines. As in, if things do get torn down, in whatever sense, you end up not being able to check against the top thing and have to deal with that problem. If they don't get torn down, then you can do the check, but it probably doesn't do what you want. And in addition to all that, it's not clear to me what the APIs that use this sort of check should do if they are simply in an inactive document in a toplevel browsing context. Should it matter whether that inactive document is or is not same-origin with the active document? |
I'm going to close this issue until we have some more concrete use cases, to make sure it generalizes correctly. So far we have the use case of blocking navigator.vibrate in cross origin iframes, but not much else. |
w3ctag/design-reviews#147 (comment) makes it clear that telling if you're in a method that's being invoked cross-origin is kind of complicated. This has also come up in a desire for blocking navigator.vibrate in cross-origin iframes.
I think it would be good if HTML provided an easy algorithm that could be used by spec authors to determine if they are being invoked cross-origin. That is, spec authors could write
I think this would expand to the following, which is more precise than my above-linked version:
We would preface this with a note that it's only usable inside the synchronous portion of a method or constructor.
What do people think? I'm especially curious of @bzbarsky and @mikewest's opinion. Do we have more use cases for this sort of check? Maybe it should be a Web IDL annotation, either immediately or eventually, like [SecureContext] is?
The text was updated successfully, but these errors were encountered: