Require a user gesture for a cross-origin frame to navigate the top-level page
We are seeing a lot of ads that navigate the top-level page outside of a user gesture. We think this is user hostile and that we don't lose any important use cases by requiring a user gesture. Chrome has added formal measurement for this. Once we get the numbers back, we plan to make this change.
There is also the allow-top-navigation flag for iframe sandbox attribute. Once we make this change the plan is that sandbox disallows top navigation and allow-top-navigation allows the behavior described above (i.e. even with allow-top-navigation, you'd still need a user gesture to navigate the top-level page).
Any consideration of doing this for modal dialogs as well? When I saw the email about not opening "popups" except in response to a user gesture, was excited about this because I thought it included blocking that particular behavior as well. A lot of abusive pages use OnBeforeUnload dialogs, which are just annoying.
blink-dev thread: https://groups.google.com/a/chromium.org/d/msg/blink-dev/Xi8-y4ySjA4/dc4BFfqyBQAJ
/cc @annevk @rlbmoz @johnwilander @travisleithead
:( This breaks a thing I'm working on. I'm trying to expose a cross-origin API in an iframe via postMessage. The parent frame uses postMessage to request a service from the iframe. If the request can be fulfilled without user confirmation, the iframe navigates the parent to a "success" page specified by the caller. Otherwise it makes a POST that navigates the parent frame to a confirmation page, which takes the user back to the specified "success" page after the user gesture.
I like the iframe top navigation pattern for a couple of reasons.
Compare it to the traditional workflow for doing this (as with OAuth) which requires POSTing directly to the cross-origin resource or opening a popup:
- If user consent isn't required the user is taken directly to the "success" page without incurring a synchronous additional round-trip and redirect in the top frame, giving better perceived performance, responsiveness and less drop-off.
- Popups suck and are frequently blocked.
The parent could implement another listener for a postMessage reply and do the navigation itself, but that makes using this kind of API more complicated, and it is nice to be able to do the POST from the iframe and include, e.g. a CSRF token and trustworthy indication of the parent origin that triggered the request.
A click to the iframe doesn't make sense; it takes away control over the UX that the parent wants.
Since a page that doesn't want this behavior from an iframe already has the ability to block top-navigation with the sandbox attribute, I'm not sure why we need to break this behavior by default?
Could we count receiving a postMessage from the parent as enabling navigation? (in addition to a user gesture)
For payments security, we collect sensitive card information within an embedded iFrame. A lot of our clients depend on our iFrame for this. Once the card information is collected in the iFrame, the user is then navigated (by changing window.top) to a page in our domain for authentication of the card information. This proposed change will break our flow permanently.
If allow-top-navigation is mentioned in the
This is breaking sign-in flow for CapitalOne (https://servicing.capitalone.com/c1/Login.aspx). I see the following message in console:
Unsafe JavaScript attempt to initiate navigation for frame with URL 'https://servicing.capitalone.com/c1/Login.aspx' from frame with URL 'https://login2.capitalone.com/loginweb/login/postLogin.do'. The frame attempting navigation is targeting its top-level window, but is neither same-origin with its target nor is it processing a user gesture. See https://www.chromestatus.com/features/5851021045661696.
I presume Capital One will have to fix their site, and Chrome is working as intended?
We received user reports that this is breaking users of the Facebook SDK. https://developers.facebook.com/docs/games/gamesonfacebook/login explicitly encourages use of top level navigation.
@reginaldos thanks for the report. Can you point us to an example page? We considering changing behavior here and being able to verify the new idea works would be helpful. It's hard for me to follow in that SDK documentation where top-level navigation is used.
@ojanvafai this also seems to break typeform redirection
This broke eBay checkout flow for me. It hung after adding a credit card in PayPal, and an error in the console pointed me to this new Chrome feature.
In the console:
main.js:21966 Unsafe JavaScript attempt to initiate navigation for frame with URL 'https://mbuy.ebay.com/xo?action=view&sessionid=(redacted)&redirect=mobile' from frame with URL 'https://www.paypal.com/webapps/helios?action=addCard&payer_id=(redacted)…hod%3DPAYPAL%26redirect%3Dmobile#/checkout/pageAddCard/addCardFlow/addCard'. The frame attempting navigation is targeting its top-level window, but is neither same-origin with its target nor is it processing a user gesture. See https://www.chromestatus.com/features/5851021045661696.
findWindowAndRedirect @ main.js:21966
This seems to break the ability to log in on My3 (https://www.three.co.uk/My3Account/Login) in Chrome 56.0.2885.0 canary.
Error:
- Unsafe JavaScript attempt to initiate navigation for frame with URL 'https://www.three.co.uk/My3Account/Login' from frame with URL 'https://sso.three.co.uk/mylogin/?service=https%3A%2F%2Fwww.three.co.uk%2FTh…&resource=portlet'. The frame attempting navigation is targeting its top-level window, but is neither same-origin with its target nor is it processing a user gesture. See https://www.chromestatus.com/features/5851021045661696.
- Uncaught DOMException: Failed to set the 'href' property on 'Location': The current window does not have permission to navigate the target frame to 'https://www.three.co.uk/ThreePortal/appmanager/Three/SelfcareUk?…'.
After submitting log-in credentials, the user stays on a (now partially blank) login page instead proceeding to the My3 home page.
It still works in Chrome 53.0.2785.143 stable.
I just reenabled this experiment in Chrome 56+ builds (should be on the chrome canary in a day or two) with a few changes to try to make it less breaking:
- Instead of requiring a current user gesture, a cross-origin iframe can navigation top if it has ever received a user gesture.
- When setting the bit that indicates whether a given browsing context has received a user gesture, it is also set on all of that browsing context's ancestors.
I still think that the parent frame sending a postMessage should also "activate" the iframe, or there needs to be a way to explicitly allow a child frame to top-nav so without a user gesture. This is an important cross-origin API surface. Iframes are not just ads.
On Wed, Oct 26, 2016 at 12:25 PM natechapin notifications@github.com wrote:
I just reenabled this experiment in Chrome 56+ builds (should be on the chrome canary in a day or two) with a few changes to try to make it less breaking:
- Instead of requiring a current user gesture, a cross-origin iframe can navigation top if it has ever received a user gesture.
- When setting the bit that indicates whether a given browsing context has received a user gesture, it is also set on all of that browsing context's ancestors.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/WICG/interventions/issues/16#issuecomment-256451362, or mute the thread https://github.com/notifications/unsubscribe-auth/ACFbcAuXVIvL28tXEv6TmKkWFK9WGncOks5q36kXgaJpZM4IN2IH .
@hillbrad is it possible for your case to postMessage back to the parent page to do the navigation?
Having postMessage auto-grant this ability would take all the value out of this proposal since postMessage is so widely used.
Maybe we should consider adding a permission that we can delegate down via feature policy (e.g. via an enable attribute on the iframe) to allow the top-level page to say the iframe can navigate it without a user gesture. @hillbrad would that work for your use case?
@ojanvafai an explicit opt-in or callback could work, but there are 7 independent bug reports here, which seems to indicate reasonably wide legitimate use.
What does the data look like on the prevalence of legitimate vs. user-hostile occurrences?
@hillbrad these bug reports were on the less permissive version that required a user gesture for the navigation instead of any user gesture during the life of the frame. It's hard to test all of these because most of them don't link to pages, but I confirmed that the capitalone case does get a user gesture today.
It's very hard to get data on prevalence of legitimate vs. user-hostile at scale. If we could distinguish the two reliably, we'd do a different intervention. :)
If we get reports of real content that breaks with this more permissive solution, we'll need to reconsider.
It seems that any use of hidden frames as an API surface that includes automatic navigation will still break under the new approach because they have no way to collect a user gesture? So I think there should be a way to designate a frame at creation as capable of top navigating, or to decorate a postMessage so it delegates a capability equivalent to a user gesture, before intervening and requiring a larger redesign of these existing uses. Setting up an event listener, parsing and navigating in response to a reply message is not terribly difficult, but it is much more complicated than a simple fire-and-forget postMessage.
On Tue, Nov 1, 2016 at 8:07 AM ojan notifications@github.com wrote:
@hillbrad https://github.com/hillbrad these bug reports were on the less permissive version that required a user gesture for the navigation instead of any user gesture during the life of the frame. It's hard to test all of these because most of them don't link to pages, but I confirmed that the capitalone case does get a user gesture today.
It's very hard to get data on prevalence of legitimate vs. user-hostile at scale. If we could distinguish the two reliably, we'd do a different intervention. :)
If we get reports of real content that breaks with this more permissive solution, we'll need to reconsider.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/WICG/interventions/issues/16#issuecomment-257591242, or mute the thread https://github.com/notifications/unsubscribe-auth/ACFbcErrIcZj7CJk4PmxONoJp3niR9dyks5q51W9gaJpZM4IN2IH .
I think a way to delegate top navigation to subframes is reasonable. It would probably build on top of feature policy: https://wicg.github.io/feature-policy/. When we ship feature policy, I don't see any downside to adding the ability to delegate down the ability to do top-navigation without a gesture. But, I'm hesitant to block shipping this until then due to:
- The large user benefit this has.
- (so far) no complaints of real-world web sites breaking.
- The restriction can be worked around via a postMessage to the parent.
I do think we might want to explore having a postMessage that happens during a user-gesture grant the messaged-frame the ability to top-navigate since we pass the user gesture bit with the postMessage already (e.g. the inner frame's message handler can open popups, etc). That'd probably be good for keeping the platform simple and consistent. But, I think that doesn't actually address your need @hillbrad, right?
If you can track a user gesture in a parent frame leading to an postMessage to the child frame and carry the user intent flags through, that should work for my specific use cases. But it would definitely be nice to have something deterministic to set so every postMessage API documentation doesn't need an extra page of explanation about this behavior.
On Tue, Nov 1, 2016 at 11:33 AM ojan notifications@github.com wrote:
I think a way to delegate top navigation to subframes is reasonable. It would probably build on top of feature policy: https://wicg.github.io/feature-policy/. When we ship feature policy, I don't see any downside to adding the ability to delegate down the ability to do top-navigation without a gesture. But, I'm hesitant to block shipping this until then due to:
- The large user benefit this has.
- (so far) no complaints of real-world web sites breaking.
- The restriction can be worked around via a postMessage to the parent.
I do think we might want to explore having a postMessage that happens during a user-gesture grant the messaged-frame the ability to top-navigate since we pass the user gesture bit with the postMessage already (e.g. the inner frame's message handler can open popups, etc). That'd probably be good for keeping the platform simple and consistent. But, I think that doesn't actually address your need @hillbrad https://github.com/hillbrad, right?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/WICG/interventions/issues/16#issuecomment-257653733, or mute the thread https://github.com/notifications/unsubscribe-auth/ACFbcA9bW9ghj0R0rZqmkdkr06UgsBH3ks5q54YRgaJpZM4IN2IH .
I'm seeing this in Chrome 56 (dev release), but not for post message. Does anyone know if this will definitely ship on January 31st? I am not familiar with the Chromium release cycle, and whether dates are strictly followed.
@limpygnome the dates aren't strictly followed, but it should ship on January 31st give or take a week. Is this breaking a page for you?