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 "determine navigation params policy container" and "determine the origin" #8739

Open
domenic opened this issue Jan 17, 2023 · 0 comments
Labels
clarification Standard could be clearer topic: navigation topic: policy container The policy container proposal

Comments

@domenic
Copy link
Member

domenic commented Jan 17, 2023

See #8447 (comment). This is best done after #8447 and after #8725 is fixed. Quoting from there:

Now that effectively "determine navigation params policy container" + "determine the origin" are doing one big combined thing, it's pretty bad. They have the combined inputs responseURL, sandboxFlags, sourceOrigin, containerOrigin, historyPolicyContainer, initiatorPolicyContainer, parentPolicyContainer, responsePolicyContainer. Maybe sourceOrigin / containerOrigin /initiatorPolicyContainer / parentPolicyContainer have some redundancy; maybe not.

Some ideas:

  1. Split "determine navigation params policy container" into three algorithms with three inputs, one for each of its call sites. These are much easier to read because, e.g., the srcdoc version is very short, and then there's no srcdoc stuff in the fetching version.

  2. Try to consolidate "determine the origin" and "determine navigation params policy container" as much as possible. Some of this involves ensuring sourceOrigin /containerOrigin / initiatorPolicyContainer / parentPolicyContainer line up; I think they mostly do. I'm unsure yet whether the end state here has them as separate algorithms, or one combined algorithm, or whether we ensure that "determine the origin" is always called by the now-split-up "determine navigation params policy container" instead of having the call sites call both of them in sequence. TBD.

  3. Potentially simplify the inputs to, or split up, "determine the origin" itself.

  4. Potentially consolidate "create a policy container from a fetch response" into the above stuff, since after (1) it should be pretty closely tied with the first variant of "determine navigation params policy container".

Draft of the split algorithms
  • https://html.spec.whatwg.org/#beginning-navigation:determining-navigation-params-policy-container needs "determine a navigation params policy container for a response". It takes response, sandboxFlags, sourcePolicyContainer and does the following:

    1. Let responseOrigin be determine the origin (response's URL, sandboxFlags, sourcePolicyContainer's origin, null)'s origin. (Or maybe this would be simpler inlined... but then what about the other cases??? Should it stay in the caller for now??)
    2. If sandboxFlags says so, set responseOrigin to opaque origin.
    3. If response's URL matches about:blank, then set responseOrigin to sourcePolicyContainer's origin.
    4. If responseURL is local, then return a clone of sourcePolicyContainer with origin := responseOrigin.
    5. Return a new policy container whose origin := responseOrigin. (Really not sure this step is right, but, it's what the current spec says...)
  • http://localhost:8080/#populating-a-session-history-entry:determining-navigation-params-policy-container needs "determine a navigation params policy container for a srcdoc document". It takes historyPolicyContainer, parentPolicyContainer, and responseOrigin and does the following:

    1. If historyPolicyContainer is not null, return it.
    2. Return a clone of parentPolicyContainer with origin := responseOrigin.
  • http://localhost:8080/#populating-a-session-history-entry:determining-navigation-params-policy-container-2 needs "detremine a navigations params policy container from fetching". It takes responseURL, responseOrigin, responsePolicyContainer, initiatorPolicyContainer, and historyPolicyContainer and does the following:

    1. If historyPolicyContainer is not null, return it. (This happens for local URLs, maybe can be an assert.)
    2. If responseURL is local and initiatorPolicyContainer is not null, then return initiatorPolicyContainer with origin := responseOrigin.
    3. Return responsePolicyContainer with origin := responseOrigin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer topic: navigation topic: policy container The policy container proposal
Development

No branches or pull requests

2 participants
@domenic and others