-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
How should noopener/noreferrer affect link targeting? #1826
Comments
I like the Chrome behavior... The less we share those names the better. (To define that better we still need a lot of refactoring I'm afraid.) |
I'm surprised that Chrome opens two windows for I think we should change step 4 of https://html.spec.whatwg.org/#dom-open to check the I wouldn't be sad if we did the same for |
I think we should keep |
Nope. It's apparently less work for me to do things that way, in fact. |
WIP: All of this would benefit from more substantial refactoring, but let's decide that this is the right way to approach things first. #1826
WIP: All of this would benefit from more substantial refactoring, but let's decide that this is the right way to approach things first. #1826
I landed the Gecko changes based on what we are planning to do here, plus web platform tests. It sure would be nice to update the spec to match the tests. ;) |
I can't realistically commit to a timeframe for that. As far as I can tell the way navigation/history/loading/etc. works is rather broken and refactoring it to match implementations (or at least what they should aspire too) is a hard problem for me. I tried a few times and got stuck on edge cases each time. I want to try again, but there's a lot of other things to work on too, so... |
I mean, I can write the spec update I want. The real questions are:
Because if the answer to either one is "no", then I should just back out the changes to noreferrer behavior I made, and try to figure out whether noreferrer and noopener should actually behave the same wrt link targeting or not, with some lovely reverse-engineering. // cc @domenic |
cc @RByers for the interop question. We'd take a PR that clarifies this if there's agreement (and tests). |
This is basically a duplicate of #313, no? I still can't commit to a timeframe, but I do have a much better handle on this now and am making some modest progress towards fixing this situation. Help with tests and such appreciated. |
After some thought, and given total lack of response from @mikewest or @RByers, I am just going to undo the main incompatible change to noreferrer behavior we made in Gecko. In terms of spec text, the Gecko behavior after my change will basically be:
So if you do |
@bzbarsky why, compat? Making noreferrer/noopener the same seems much better. |
Sorry I haven't been paying attention to window targeting. I'll try to be more responsive on the bugs Anne's been pinging today. :) I think I would be happier if |
Sorry I missed this also. I don't have context in this space to speak to the details, but unsurprisingly I support any effort that'll increase interop - even if it means taking a little compat risk in chromium. I'll chat with Mike offline a bit. |
Yes. See https://bugzilla.mozilla.org/show_bug.cgi?id=1358469 |
Specifically, everyone has for years been shipping behavior for noreferrer that is interoperable when the named target already exists. When it doesn't exist, interop is horrible, of course. But the "target already exists" case is interoperable inasmuch as any named targeting is interoperable, and is the only way to do no-referrer loads until everyone implements referrer policy. And people are using it. |
@bzbarsky: Skimming through this again, I think |
Yes.
Could you please summarize what behavior is actually being implemented there, for both noopener and noreferrer? The tests here are very much not exhaustive (e.g. doesn't test noreferrer), so agreement on them clearly doesn't mean very much in practice. Again, I am backing out some of the changes I made to Gecko's noreferrer behavior to allow it to target an existing named thing (but the thing it creates will still not be targetable). See https://bugzilla.mozilla.org/show_bug.cgi?id=1358469 and the change I just landed there, which includes wpt changes. |
Currently in Chrome/Safari TP these links <a href=https://example.com/ target=hi>start</a>
<a href=https://example.com/ target=hi rel=noreferrer>noreferrer</a>
<a href=https://example.com/ target=hi rel=noopener>noopener</a> all end up in a new browsing context, until "start" is clicked at which point they all reuse the same. In Firefox "noopener" is always new. "noreferrer" opens a new one that cannot be reused, unless "start" was clicked first in which case "noreferrer" behaves the same as "start". In Edge if you start with "noreferrer" everything will then open a new browsing context. If you start with "start" or "noopener" the browsing context will always be reused. (Bonus points for doing something unexpected I suppose.) |
Does Edge even support noopener? Because I thought part of the point of noopener was to explicitly create a new unit of related browsing contexts... |
https://caniuse.com/#search=noopener says Edge in fact does not support it. |
Sure, but that's not what's unexpected. What's unexpected is, e.g., clicking "noreferrer" and then clicking "start" twice gives you three new browsing contexts. |
Oh. Yeah, that's odd. ;) |
This feature has some outstanding issues and feature requests; see whatwg#323 and whatwg#1826. But this editorial cleanup creates a more solid foundation for future work.
Given the compatibility issue in #1826 (comment) I guess we should go with the Chrome/Safari status quo. Reuse existing window if it exists, create a new one (that cannot be targeted if noopener/noreferrer is set) otherwise. However, note that for |
I would really prefer we did the more-secure thing for noopener, especially since it seems to be web-compatible enough (Firefox is shipping it, after all). That would also avoid the problem of diverging codepaths, for links and window.open, I would hope. But that would obviously need buy-in from Chrome and Safari. |
Btw, I believe I made changes in this area so it’d be good to confirm Safari behavior using a recent STP. I believe link targeting no longer works when noopener/noreferer is specified. |
@cdumez in release 73 name targeting happens first: https://morning-tarp-1.glitch.me/. |
If Blink people are on board with trying this, I'd be willing to give it a try in WebKit too. I personally like Firefox's behavior better here but there are some risks associated with changing our behavior (https://bugzilla.mozilla.org/show_bug.cgi?id=1358469#c0). |
Wait, I take back what I said. I just tried Firefox and link targeting fails with noopener but works with noreferrer. The inconsistency is definitely not nice here, especially considering that noreferer is supposed to be a superset of noopener. I am guessing Firefox did this for compat reasons? |
I think I agree with this now. At least the behavior is consistent between noopener and noreferer. The inconsistency in Firefox and Chrome bothers me.
That's the part I thought I fixed recently in STP. |
Yes.
Is that more important than sane behavior for noopener? With this behavior, if you do a noopener link maybe you'll actually get the severing you want, and maybe you won't, depending. |
@bzbarsky we could advice folks to also use |
It depends. You might control it on the other side. That is, you may be opening a page you control with noopener (and its subframes might target it by name, etc) so that if the user later navigates to another tab there the new thing won't be able to reach back to you. I mean, the way I see it we end up with a suboptimal inconsistency somewhere here. We just have to pick where... |
That case seems more unlikely. Since if the user navigated there directly (or from search results or some such) it wouldn't have a name and things would fall apart. I agree that none of this is ideal though. |
The way I think we should resolve this given all the information given thus far:
|
I've lost track of what the "what the current specification accepts" behavior is. Is there a summary somewhere? |
If the |
I've been trying clean up chromium's browsing context selection in the last month or so and stumbled across this issue. Is the current spec text sufficiently agreed upon that I should standardize chromium's behavior on it (i.e., noopener/noreferrer shouldn't ever affect browsing context selection by name)? |
I think so, especially given that we cannot change it for noreferrer it makes sense to not do it for noopener either, to keep noreferrer as a superset. |
I don't think "shouldn't ever affect" is quite correct, because the things actually opened via noopener/noreferrer, when it opens new things, can't be targeted later. Anyway, I still think basically ignoring noopener on the load that we want to target for targeting purposes is very sad, but if that's what everyone else wants to implement... |
…s for choosing a browsing con…, a=testonly Automatic update from web-platform-tests HTML: correct noopener tests In particular, if a name is given use that first and potentially reuse a window. Closes whatwg/html#1826. -- wpt-commits: 0c79d0d99c720f679fa089374971778e461e6662 wpt-pr: 16451
…s for choosing a browsing con…, a=testonly Automatic update from web-platform-tests HTML: correct noopener tests In particular, if a name is given use that first and potentially reuse a window. Closes whatwg/html#1826. -- wpt-commits: 0c79d0d99c720f679fa089374971778e461e6662 wpt-pr: 16451
In particular, if a name is given use that first and potentially reuse a window. Closes whatwg/html#1826.
…s for choosing a browsing con…, a=testonly Automatic update from web-platform-tests HTML: correct noopener tests In particular, if a name is given use that first and potentially reuse a window. Closes whatwg/html#1826. -- wpt-commits: 0c79d0d99c720f679fa089374971778e461e6662 wpt-pr: 16451 UltraBlame original commit: f2b4dc0d863dcdd1768145f1fa83462cf9a9271c
…s for choosing a browsing con…, a=testonly Automatic update from web-platform-tests HTML: correct noopener tests In particular, if a name is given use that first and potentially reuse a window. Closes whatwg/html#1826. -- wpt-commits: 0c79d0d99c720f679fa089374971778e461e6662 wpt-pr: 16451 UltraBlame original commit: f2b4dc0d863dcdd1768145f1fa83462cf9a9271c
…s for choosing a browsing con…, a=testonly Automatic update from web-platform-tests HTML: correct noopener tests In particular, if a name is given use that first and potentially reuse a window. Closes whatwg/html#1826. -- wpt-commits: 0c79d0d99c720f679fa089374971778e461e6662 wpt-pr: 16451 UltraBlame original commit: f2b4dc0d863dcdd1768145f1fa83462cf9a9271c
Consider this testcase:
Should clicking the link twice lead to one new window being opened or two? In Safari and Firefox and Edge it's one. In Chrome it's two.
What about the noopener case? The theory is it's just like the noreferrer case but sends a referrer.... But note that there is desire to be able to open noopener things in a totally new process, which does not play very nicely with being able to then target them by name. Presumably this is the root of the Chrome behavior here?
/cc @domenic @mikewest @annevk
The text was updated successfully, but these errors were encountered: