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

Refactor browsing context creation #4284

Merged
merged 13 commits into from
Jan 29, 2019
Merged

Refactor browsing context creation #4284

merged 13 commits into from
Jan 29, 2019

Conversation

annevk
Copy link
Member

@annevk annevk commented Jan 11, 2019

Some initial work to make introducing browsing context groups easier.

In particular:

  • Gives creation of top-level and auxiliary browsing contexts their own algorithm.
  • Makes the creator browsing context variables set explicitly during creation. (The current definition didn't really make sense, as the created browsing context had no parent, yet we were asking for information from the parent...)
  • Makes setting the opener browsing context explicit.

@mikewest currently "choosing a browsing context" has some sandboxing integration. It seems this can move to "creating a new auxiliary browsing context"? I haven't made that change yet, but it seems like that's what should happen as presumably it doesn't apply when we create a new non-auxiliary top-level browsing context.

cc @mystor @farre


/browsers.html ( diff )
/iframe-embed-object.html ( diff )
/index.html ( diff )
/links.html ( diff )
/obsolete.html ( diff )
/urls-and-fetching.html ( diff )
/webappapis.html ( diff )
/webstorage.html ( diff )
/window-object.html ( diff )

Some initial work to make introducing browsing context groups easier.
Copy link
Contributor

@mystor mystor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a pretty good improvement to me :-) - I don't have as much context as some other contributors to the spec as to other places which might need to be updated, but the parts I see here look pretty good.

I added some comments which are somewhat style-focused - feel free to disregard them.

source Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
@mystor
Copy link
Contributor

mystor commented Jan 11, 2019

@mikewest currently "choosing a browsing context" has some sandboxing integration. It seems this can move to "creating a new auxiliary browsing context"? I haven't made that change yet, but it seems like that's what should happen as presumably it doesn't apply when we create a new non-auxiliary top-level browsing context.

We might want to propagate some sandboxing information into noopener-created toplevel browsing contexts, so I am not sure if we'd want to make that change. That being said, we probably should consider them.

IIRC we do / want to do some propagation of e.g. popup blocking flags into noopener-created toplevel browsing contexts.

@annevk
Copy link
Member Author

annevk commented Jan 22, 2019

Edit: so per some local testing sandboxing as well as name setting goes for both auxiliary and non-auxiliary top-level browsing contexts. The difference between auxiliary and non-auxiliary top-level browsing contexts is only whether you get a reference (opener/openee) and session storage, as far as I can tell. It'd be great if someone could confirm. (E.g., @mikewest.)

I'll make the patch reflect that, even if it seems less than ideal.

@annevk annevk requested a review from domenic January 22, 2019 16:55
@annevk
Copy link
Member Author

annevk commented Jan 23, 2019

Note: this fixes #2645.

@annevk
Copy link
Member Author

annevk commented Jan 24, 2019

The annoying thing with refactoring is that you always run into new things:

I'll try to sort that out and also a restructuring of the sections that it requires as well as writing some tests I suppose. It'd be good to get this done though as this blocks making target=_blank behave like noopener, adding Cross-Origin-Opener-Policy, browsing context groups, etc.

@annevk
Copy link
Member Author

annevk commented Jan 24, 2019

Tests to write (though perhaps noopener bits should be lightly tested given #1826 will likely change things a bit):

  • <a> / <area> / <form> only set opener when creating a popup.
  • window.open() always sets opener, unless noopener is specified.
    • Also test that then setting opener to null works and if you then set opener to something meaningless (e.g., a string, undefined, or self) and use the original getter you get null.

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some editorial suggestions. But my biggest concern is changing the definition of "top-level browsing context" to exclude auxiliary BCs. There seem to be ~50 uses of "top-level browsing context" in this spec alone. How many of those change their meaning substantially now?

Spot-checking, many of them now seem broken, e.g.

source Show resolved Hide resolved
source Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated
@@ -31164,7 +31184,8 @@ interface <dfn>HTMLObjectElement</dfn> : <span>HTMLElement</span> {

<p>If the <code>object</code> element's <span>nested browsing context</span> is null, set
the element's <span>nested browsing context</span> to a <span data-x="creating a new
browsing context">newly-created browsing context</span>.</p>
browsing context">newly-created browsing context</span> with the element's <span>node
document</span>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same two-steps comment as above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is much harder as it's knee-deep in an existing algorithm. So you cannot really abstract object element out without rewriting the entire thing.

source Outdated Show resolved Hide resolved
@@ -77343,6 +77363,46 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
<span>top-level browsing context</span>'s <code>WindowProxy</code> object.</p></li>
</ol>

<p>The <dfn><code data-x="dom-opener">opener</code></dfn> attribute's getter must run these
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put this last, if you want to keep it in the same section. top/parent are both about navigating the tree, whereas this is about crossing to a new tree, kinda. Feels different.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it in IDL order.

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
@annevk
Copy link
Member Author

annevk commented Jan 25, 2019

web-platform-tests/wpt#15078 has tests.

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Do you think maybe "create a new top-level browsing context" should get a new name, since it's immediately followed by "create a new auxiliary browsing context"? Or maybe just a clarifying note that "create a new auxiliary browsing context" is a more specialized way of creating a certain type of top-level BC.

I think in the future we could also have a "create a nested BC" algorithm which takes an element; that would be a nice cleanup.

browsing context</span>. <span w-nodev>When the browsing context is created, if the attribute
is present, the <span>browsing context name</span> must be set to the value of this attribute;
otherwise, the <span>browsing context name</span> must be set to the empty string.</span></p>
browsing context</span>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice to move this.

@@ -76949,7 +76960,8 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
<p>A <span>browsing context</span> has an <dfn data-export="">opener browsing context</dfn>, which
is null or a <span>browsing context</span>. It is initially null.</p>

<p>A <span>browsing context</span> can be <dfn id="disowned-its-opener">disowned</dfn>.</p>
<p>A <span>browsing context</span> can be <dfn id="disowned-its-opener">disowned</dfn>, which is a
boolean. It is initially false.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ehh, "can be disowned, which is a boolean" is not really grammatical. "Has a disowned boolean" would be better.

@annevk annevk merged commit a48895e into master Jan 29, 2019
@annevk annevk deleted the annevk/bc-creation-refactor branch January 29, 2019 13:52
annevk added a commit to web-platform-tests/wpt that referenced this pull request Jan 31, 2019
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Feb 14, 2019
…nested browsing context, a=testonly

Automatic update from web-platform-tests
HTML: window.open() can set opener of a nested browsing context

Needed for whatwg/html#4284.

--

wpt-commits: 5cf7f41336801449ce7499a5f41ccf6848650e9c
wpt-pr: 15078
xeonchen pushed a commit to xeonchen/gecko that referenced this pull request Feb 14, 2019
…nested browsing context, a=testonly

Automatic update from web-platform-tests
HTML: window.open() can set opener of a nested browsing context

Needed for whatwg/html#4284.

--

wpt-commits: 5cf7f41336801449ce7499a5f41ccf6848650e9c
wpt-pr: 15078
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…nested browsing context, a=testonly

Automatic update from web-platform-tests
HTML: window.open() can set opener of a nested browsing context

Needed for whatwg/html#4284.

--

wpt-commits: 5cf7f41336801449ce7499a5f41ccf6848650e9c
wpt-pr: 15078

UltraBlame original commit: 5eb72f3fdd6a5d8a9f9eb3015af3522b7196fcb2
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 4, 2019
…nested browsing context, a=testonly

Automatic update from web-platform-tests
HTML: window.open() can set opener of a nested browsing context

Needed for whatwg/html#4284.

--

wpt-commits: 5cf7f41336801449ce7499a5f41ccf6848650e9c
wpt-pr: 15078

UltraBlame original commit: 5eb72f3fdd6a5d8a9f9eb3015af3522b7196fcb2
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 4, 2019
…nested browsing context, a=testonly

Automatic update from web-platform-tests
HTML: window.open() can set opener of a nested browsing context

Needed for whatwg/html#4284.

--

wpt-commits: 5cf7f41336801449ce7499a5f41ccf6848650e9c
wpt-pr: 15078

UltraBlame original commit: 5eb72f3fdd6a5d8a9f9eb3015af3522b7196fcb2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants