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

Add opt-in/opt-out mechanism #80

Closed
bokand opened this issue Jan 20, 2020 · 22 comments · Fixed by #131
Closed

Add opt-in/opt-out mechanism #80

bokand opened this issue Jan 20, 2020 · 22 comments · Fixed by #131
Assignees

Comments

@bokand
Copy link
Collaborator

bokand commented Jan 20, 2020

As shown in #76 and #79, there are ways to leak information across origins due to the initial scroll. They rely on specific circumstances on a page so they aren't general but they are possible so we should consider ways to mitigate them.

I think it'd be useful to add a mechanism for a page to opt out of fragment navigation. i.e. Guarantee it'll load at the initial scroll offset. This can opt-out of element-id and name based fragments as well, which are susceptible to the same issues.

IMHO, it'd also be reasonable for UAs to weigh the trade-offs differently so I'd like to explore adding an auto|on|off switch. By default (auto), the UA can decide whether or not to scroll into view. "On" would be a signal that the page has explicitly deemed it ok to scroll on load and allow all UAs to scroll to a fragment whereas "off" would block all UAs from scrolling into view.

The highlights themselves, if implemented according to spec, aren't detectable by pages so I think this opt-in/out need only apply to the scrolling aspect.

A meta tag seems like a good start to me but I'm open to alternatives. e.g.

<meta name="allow-navigation-scroll" content="auto|block|allow">
@bokand
Copy link
Collaborator Author

bokand commented Jan 31, 2020

An alternative (syntax-wise) we're looking into is using feature-policy. However, I think the semantics would be the same as described above.

@tcr
Copy link

tcr commented Feb 21, 2020

Is this implemented in M80?

@heavyoak
Copy link

Im thinking that just adding a redirect in a page header that triggers on :~: might work, but really a whole domain needs to be able to block this.

regardless, adding this to a browser just violated the security of millions of web pages, mostly medical.

@bokand
Copy link
Collaborator Author

bokand commented Feb 24, 2020

Is this implemented in M80?

No, an author-usable opt-out will be in available M82.

Users who want can disable this for now using chrome://flags/#enable-text-fragment-anchor

blueboxd pushed a commit to blueboxd/chromium-legacy that referenced this issue Mar 10, 2020
Add a document policy that lets pages opt out of scrolling that
automatically happens on page load. This provides an opt-out to the
Scroll To Text feature (see bug and [1]), but also applies to fragment
scrolls and scroll restoration.

With the DocumentPolicy feature[2] enabled, pages can opt out of these
types of scrolling by adding the HTTP header:
Document-Policy: force-load-at-top

[1] WICG/scroll-to-text-fragment#80
[2] https://github.com/w3c/webappsec-feature-policy/blob/master/document-policy-explainer.md

Bug: 1047900
Change-Id: Iebba7fd24fa2e362bfa4a8f77903763b5d95b787
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2073138
Commit-Queue: Nick Burris <nburris@chromium.org>
Reviewed-by: Ian Clelland <iclelland@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748465}
@Malvoz
Copy link

Malvoz commented Apr 22, 2020

In the case of a meta tag, whatwg/html#2335 suggests it should rather be:
<meta allow-navigation-scroll="auto|block|allow">.

@nickburris
Copy link
Collaborator

We've implemented the opt-out as a force-load-at-top document policy (described in the explainer), and created an origin trial to bridge the gap until document policies ship.

I wanted to add some spec text describing the document policy, but I'm not sure where it would live. AFAICT the document policy spec doesn't define a set of policies. @clelland do we have a way of standardizing available policies that I should add force-load-at-top to?

@tomayac
Copy link
Contributor

tomayac commented May 8, 2020

FYI: I have added the OT info to the article.

@GlenAllsopp
Copy link

Hi @nickburris

On the page you linked to, it states " To allow websites to opt out of text fragments, we propose adding"

Emphasis my own.

Then you state,

"We've implemented the opt-out "

Can you let me know if this actually works right now, or it will be available in M82?

Thanks a lot!

@tomayac
Copy link
Contributor

tomayac commented Jun 4, 2020

This works from Chrome 83–84. The origin trial link to opt-in is https://developers.chrome.com/origintrials/#/view_trial/3253850730775183361.

@GlenAllsopp
Copy link

@tomayac

Thank you for the reply.

Sorry if this sounds rude, but it looks really unattractive on some websites I manage. Is there any way to change the highlight colour that you know of?

@tomayac
Copy link
Contributor

tomayac commented Jun 4, 2020

While at the first sight it looks like <mark>, it's not. Here's a quick demo where you can see the difference:

  • The first line is user-agent text fragment styling (note how the visited link is black, not purple).
  • The second is user-agent mark styling (note how the visited link is purple).
  • The third line is custom mark styling.

Screen Shot 2020-06-04 at 12 24 42

@nickburris I believe this is unstylable on purpose. Can you confirm?

@dfsa3ws
Copy link

dfsa3ws commented Jun 4, 2020

I opted in to the origin trial and it had the effect of disabling element fragment identifier based navigation at all times, not just on load. Is this intentional?

Thanks

@tomayac
Copy link
Contributor

tomayac commented Jun 4, 2020

This is indeed intentional. From the origin trial's description:

"The ForceLoadAtTop feature allows sites to indicate that they should be loaded at the top of the page, and not perform any scroll on load, including element fragment identifiers, scroll restoration, and Scroll To Text."

@dfsa3ws
Copy link

dfsa3ws commented Jun 4, 2020

Thanks for the quick reply.

My reading of that passage is that scrolling is only restricted on load.

@tomayac
Copy link
Contributor

tomayac commented Jun 4, 2020

@nickburris to clarify if it's intended for first load only, or throughout the session.

@bokand
Copy link
Collaborator Author

bokand commented Jun 4, 2020

Sorry, that's a bug in the implementation. I've filed https://crbug.com/1091247

The highlight used is the same one as from find-in-page. AFAICT that cannot be changed.

I'd support adding styling options - it's something we considered early on and agreed would be useful but didn't make the cut for the initial set of features. That said, there's no immediate plans to add it at this time.

@tomayac
Copy link
Contributor

tomayac commented Jun 4, 2020

The highlight used is the same one as from find-in-page.

I guess it's using the mark default color internally. Note that this color was just promoted to an own CSS named system color called Mark alongside MarkText.

@Malvoz
Copy link

Malvoz commented Jun 16, 2020

@nickburris

AFAICT the document policy spec doesn't define a set of policies. @clelland do we have a way of standardizing available policies that I should add force-load-at-top to?

There's an unofficial registry at https://github.com/w3c/webappsec-feature-policy/blob/master/features.md (to be official per w3c/webappsec-permissions-policy#366).

@bokand
Copy link
Collaborator Author

bokand commented Aug 7, 2020

There's an unofficial registry at https://github.com/w3c/webappsec-feature-policy/blob/master/features.md (to be official per w3c/webappsec-permissions-policy#366).

Thanks for the link! That looks specific to Feature Policy (now Permissions Policy). The Document Policy spec mentions it has an attached registry but I couldn't find it.

I've added related spec text text-fragments in #131 - @clelland can verify if there's a registry we should also add the new document policy to.

@bokand
Copy link
Collaborator Author

bokand commented Aug 7, 2020

Sorry if this sounds rude, but it looks really unattractive on some websites I manage. Is there any way to change the highlight colour that you know of?

FYI: There's discussions afoot on how to do this in w3c/csswg-drafts#5233

@dfsa3ws
Copy link

dfsa3ws commented Oct 1, 2020

The ForceLoadAtTop origin trial ended on the 30th Sept and the "Document-Policy: force-load-at-top" method doesn't appear to have shipped yet.

Is anyone able to extend the origin trail end date?
https://developers.chrome.com/origintrials/#/view_trial/3253850730775183361

@bokand
Copy link
Collaborator Author

bokand commented Oct 1, 2020

The DocumentPolicy is shipping in M86 which is being pushed out in the next few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants