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

Refactoring environment origin, top-level site, etc into policy container #8302

Open
wanderview opened this issue Sep 21, 2022 · 8 comments
Open
Labels
topic: policy container The policy container proposal

Comments

@wanderview
Copy link
Member

At TPAC there was a discussion about moving various authority information from the environment into a policy container owned by the environment. This would ensure the information is copied around correctly.

I started looking into this, but there are a couple issues I see with doing this:

  1. The policy container is currently on environment settings object and not on environment. This is a problem since we need the authority information on environments in order to construct a StorageKey during navigations in order to pick a service worker.
  2. It seems an environment settings object for a window doesn't even own the policy container. Instead it references the document's policy container.

Also, I'm wondering if policy containers are truly copied or just a reference is passed around. I haven't verified which yet. But if a reference is passed around it becomes difficult to modify values. For example, a cross-origin iframe should inherit the top-level site but will have a different origin value. But maybe the containers are copied and not referenced.

@annevk Any thoughts on these issues and what a good path forward would be?

@whatwg whatwg deleted a comment from Ashbri4 Sep 21, 2022
@annevk
Copy link
Member

annevk commented Sep 22, 2022

For cross-origin cases there is no inheritance so we'd have to copy (or set up something new) regardless. Policy container helps with certain same origin cases (such as about:blank and history).

Creating the policy container earlier on seems feasible (and having environment own it until a document comes alive), but we probably don't want to move ownership from document to environment settings object entirely as I suspect that initial about:blank and a subsequent same-origin document don't share a container.

@antosart did the policy container work and can hopefully help out here.

@annevk annevk added the topic: policy container The policy container proposal label Sep 22, 2022
@wanderview
Copy link
Member Author

I'm looking at moving origin to policy container, but I have another question. Right now the origin for a windows environment settings object delegates to the window's associated document's origin. So I presume I need to move document's origin into policy container. Correct?

Current document's policy container is defined in html spec, but document's origin is defined in DOM spec. Is there a recommendation on how to adjust things here? Can DOM spec reference the policy container defined in html? I'm not familiar with the dependencies or associated restrictions between html-vs-dom.

Thanks.

@annevk
Copy link
Member

annevk commented Oct 27, 2022

I was thinking that maybe we can move origin to HTML, but that does not immediately work as it's also cloned and such. Perhaps that is no longer necessary though if we keep track of it on the global as I don't think document's origin is directly exposed.

Interdependencies between DOM and HTML are okay though, but if we can avoid them or at least plan for a way out that's always better.

@wanderview
Copy link
Member Author

wanderview commented Oct 27, 2022

Hmm, another complication will be that adding origin, top-level site, etc to policy container will mean it is no longer able to be created with reasonable defaults. We can use an opaque origin as a default, but that would change behavior. So we will have to ensure that wherever a policy container is created these values are now available.

Edit: This is difficult because policy containers are created as defaults of other objects and so on.

@wanderview
Copy link
Member Author

Hmm, another complication may be that document.origin is altered when document.domain is set? I'm unsure of the implications of that on moving origin to policy container.

wanderview added a commit to wanderview/html that referenced this issue Oct 27, 2022
@wanderview
Copy link
Member Author

I've tried to start a PR in #8447, but I don't know where to set the policy container origin for new documents. I could just reference document.origin, but is that going away? And policy container origin would not get updated along with it for document.domain.

@annevk
Copy link
Member

annevk commented Oct 28, 2022

Unless you take steps to copy an origin, you'll reference it, so any modifications to it should be reflected. This is what happens for instance with an about:blank <iframe>. It'll have a reference to the origin of its parent document and setting document.domain in either document will affect both documents as they share an origin.

As such I think this should be doable, including incrementally where we keep document's origin around, but we definitely want to be careful.

wanderview added a commit to wanderview/html that referenced this issue Nov 2, 2022
wanderview added a commit to wanderview/html that referenced this issue Nov 4, 2022
wanderview added a commit to wanderview/html that referenced this issue Nov 4, 2022
wanderview added a commit to wanderview/html that referenced this issue Nov 4, 2022
wanderview added a commit to wanderview/html that referenced this issue Nov 4, 2022
@wanderview
Copy link
Member Author

I realized we might have a problem with document.domain changes leaking into the storage key incorrectly. See: whatwg/storage#150

wanderview added a commit to wanderview/html that referenced this issue Nov 8, 2022
wanderview added a commit to wanderview/html that referenced this issue Nov 8, 2022
wanderview added a commit to wanderview/html that referenced this issue Nov 8, 2022
wanderview added a commit to wanderview/html that referenced this issue Nov 8, 2022
wanderview added a commit to wanderview/html that referenced this issue Jan 6, 2023
wanderview added a commit to wanderview/html that referenced this issue Jan 10, 2023
wanderview added a commit to wanderview/html that referenced this issue Jan 11, 2023
wanderview added a commit to wanderview/html that referenced this issue Jan 12, 2023
wanderview added a commit to wanderview/html that referenced this issue Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: policy container The policy container proposal
Development

No branches or pull requests

2 participants