Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 484d5bdbd1e21e8a66b88477850d8d7553fb3094
https://github.com/WebKit/WebKit/commit/484d5bdbd1e21e8a66b88477850d8d7553fb3094
Author: Ahmad Saleem <[email protected]>
Date: 2026-08-04 (Tue, 04 Aug 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/preload/link-preload-as-case-insensitive-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/preload/link-preload-as-case-insensitive.html
M
LayoutTests/imported/w3c/web-platform-tests/preload/modulepreload-as-expected.txt
M Source/WebCore/loader/LinkLoader.cpp
Log Message:
-----------
`<link rel=preload as>` keywords should be matched ASCII case-insensitively
https://bugs.webkit.org/show_bug.cgi?id=320980
rdar://184013239
Reviewed by Frédéric Wang Nélar.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
`as` is an enumerated attribute [1], so determining its state is an ASCII
case-insensitive match
against its keywords [2] -- the union of the preload destinations and the
module preload
destinations.
`LinkLoader::resourceTypeFromAsAttribute()` instead passed the raw attribute
value to
`parseEnumerationFromString<FetchRequestDestination>()`, which looks the value
up in a
`SortedArrayMap` of `ComparableASCIILiteral` and so compares case-sensitively.
`<link
rel=preload as="IMAGE">` was therefore treated as having no valid `as` value:
the console got
"<link rel=preload> must have a valid `as` value" and nothing was fetched, from
either the
preload scanner or the link element. `as="FETCH"` was unaffected, because that
keyword is
checked separately with `equalLettersIgnoringASCIICase()`.
WebKit already performs the case-insensitive match one layer up:
`HTMLLinkElement::as()`, the
getter behind `link.as`, compares its keywords with
`equalLettersIgnoringASCIICase()` and returns
the canonical keyword [2] in lowercase. So `link.as` reported "image" for
`as="IMAGE"` while the
loader refused to load it.
Lowercase the value before parsing it, which is what the bindings generator
already emits when
reflecting enumerated content attributes.
[1] https://html.spec.whatwg.org/multipage/semantics.html#attr-link-as
[2]
https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute
Test:
imported/w3c/web-platform-tests/preload/link-preload-as-case-insensitive.html
*
LayoutTests/imported/w3c/web-platform-tests/preload/link-preload-as-case-insensitive-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/preload/link-preload-as-case-insensitive.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/preload/modulepreload-as-expected.txt:
Progression
* Source/WebCore/loader/LinkLoader.cpp:
(WebCore::LinkLoader::resourceTypeFromAsAttribute):
Canonical link: https://commits.webkit.org/318584@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications