WICG / scroll-to-text-fragment

Proposal to allow specifying a text snippet in a URL fragment
Other
586 stars 43 forks source link

Websites where text fragment link does not work despite text being there and link syntax well formed #255

Closed porg closed 5 months ago

porg commented 6 months ago

Operating System in all tests:

https://eshop.macsales.com/guides/Mac_OS_X_Compatibility#:~:text=MacBook%20Pro

https://eshop.macsales.com/guides/Mac_OS_X_Compatibility#:~:text=MacBook

https://dortania.github.io/OpenCore-Legacy-Patcher/MODELS.html#:~:text=MacBookPro13

https://dortania.github.io/OpenCore-Legacy-Patcher/MODELS.html#:~:text=below%20tables

https://dortania.github.io/OpenCore-Legacy-Patcher/MODELS.html#:~:text=verified%20your%20hardware

https://dortania.github.io/OpenCore-Legacy-Patcher/MODELS.html#macbook-pro:~:text=MacBookPro9

https://support.apple.com/en-us/108052#:~:text=2016

https://support.apple.com/108052#:~:text=2016

https://support.apple.com/en-us/108052#:~:text=MacBookPro13

porg commented 5 months ago

Added 3 new use cases above:

I'd appreciate a reaction to my report! Thanks!

porg commented 5 months ago

No reaction? Please!

bokand commented 5 months ago

Sorry! Thanks for the ping - this has been sitting in my TODO list, I'll take a look today.

bokand commented 5 months ago

Thank you for the details!

https://dortania.github.io/OpenCore-Legacy-Patcher/MODELS.html#:~:text=MacBookPro13

This is due to the word bounding restriction, we treat "MacBookPro13,1" as the full word. To select this you'd need: :~:text=MacBooPro%2C1

❌ Safari 16.6.1 — Redirects to URL with hash still there, and everything behind cut off.

Yeah, looks like the page resets fragments from JS - guessing the timing of when that's read differs between Safari and Chrome. I think this is specified to happen before the page should have a chance to run JS so I suspect Safari's implementation does it elsewhere.

https://dortania.github.io/OpenCore-Legacy-Patcher/MODELS.html#macbook-pro:~:text=MacBookPro9

This is the same issue as the one on the top - we can't find the "MacBookPro9" instance since we'd need to look for "MacBookPro9,1". However, the fragment is found so is scrolled to as expected (i.e. equivalent to navigating to #macbook-pro).

https://support.apple.com/en-us/108052#:~:text=MacBookPro13

Similarly, to select MacBookPro13,3 use: text=MacBookPro13%2C3.

porg commented 5 months ago
bokand commented 5 months ago

JS intervention different in Safari - Shall/is this filed at Apple / WebKit?

I'm not sure - feel free to file a bug with WebKit: https://webkit.org/reporting-bugs/

Please also address the other reported phenomena.

Sorry, I thought my explanation applies to all the failing cases mentioned (i.e. all cases where the highlight fails, the whole word requirement is the root cause). Was there a specific case that's not answered by the above?

porg commented 5 months ago

Yet unaddressed phenomenon

https://eshop.macsales.com/guides/Mac_OS_X_Compatibility#:~:text=MacBook https://eshop.macsales.com/guides/Mac_OS_X_Compatibility#:~:text=MacBook%20Pro

Praise — Fragment link survives server side HTTP 3xx redirection just fine

https://support.apple.com/108052#:~:text=2016

bokand commented 5 months ago

❌ Both fail in Safari.

I don't see any obvious reason why it shouldn't work, per spec. The fact it works in Chrome makes me think this is likely a bug in WebKit and I'm not able to root cause that. Your best bet is probably to file a bug with WebKit.

But that should not be left up to luck, but should be specced explicitly IMHO.

It's definitely not luck :) This took quite a bit of effort (it even works across client-side redirects, at least in Chrome) and is specified by virtue of the user activation being part of the navigation request which is preserved (along with the fragment in the URL) across navigation redirects.

porg commented 5 months ago

Ad 1) Am on Safari 16.x. Will re-check this on v17.x when getting a newer Mac and then file if needed.

Ad 2) Glad that this is specced explicitly. As a less technical reader I could not grasp what it deals with on first sight. I had searched for "HTTP redirect", "HTTP 3" as in "3xx", then "redirect" and finally found that section. On first glance of that section I was not sure that it indeed deals with the interplay of server side and local redirects. But I assume a real technical reader realizes that quicker hopefully.

porg commented 5 months ago

So from my side we can close this issue, the spec seems to cover all phenomena, and I just found browser mis-implementations.

bokand commented 5 months ago

Thanks for the detailed investigation!