Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: f3abbc493107b5e67649d1dd1fc310e1c422c144
https://github.com/WebKit/WebKit/commit/f3abbc493107b5e67649d1dd1fc310e1c422c144
Author: Ahmad Saleem <[email protected]>
Date: 2026-07-11 (Sat, 11 Jul 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/scroll-to-text-fragment/non-html-documents-json-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/scroll-to-text-fragment/resources/text-html-with-charset.html
A
LayoutTests/imported/w3c/web-platform-tests/scroll-to-text-fragment/resources/text-html-with-charset.html.headers
A
LayoutTests/imported/w3c/web-platform-tests/scroll-to-text-fragment/text-directive-mime-type-parameter-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/scroll-to-text-fragment/text-directive-mime-type-parameter.html
M Source/WebCore/page/LocalFrameView.cpp
Log Message:
-----------
Scroll To Text Fragment: text directives should only run in text/html and
text/plain documents
https://bugs.webkit.org/show_bug.cgi?id=318931
rdar://181763736
Reviewed by Abrar Rahman Protyasha.
Per spec [1], a text directive is only processed when the document's MIME type
is a
"text directive allowing MIME type" (essence "text/html" or "text/plain").
WebKit ran text directives regardless of content type, so `#:~:text=` scrolled
in application/json (and XML/CSS/JS) documents, diverging from other browsers.
Gate scrollToTextFragment() on the document's MIME type being text/html or
text/plain. The check must use the MIME string, not the document class, since
text/plain and JSON are both TextDocument.
[1]
https://wicg.github.io/scroll-to-text-fragment/#text-directive-allowing-mime-type
*
LayoutTests/imported/w3c/web-platform-tests/scroll-to-text-fragment/non-html-documents-json-expected.txt:
Progression.
*
LayoutTests/imported/w3c/web-platform-tests/scroll-to-text-fragment/text-directive-mime-type-parameter.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/scroll-to-text-fragment/text-directive-mime-type-parameter-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/scroll-to-text-fragment/resources/text-html-with-charset.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/scroll-to-text-fragment/resources/text-html-with-charset.html.headers:
Added.
* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::scrollToTextFragment):
Canonical link: https://commits.webkit.org/316976@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications