Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4952aceefed640808291ab3768c7a960fd3224c2
      
https://github.com/WebKit/WebKit/commit/4952aceefed640808291ab3768c7a960fd3224c2
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-06-17 (Wed, 17 Jun 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/preload/preload-type-match-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/preload/supported-as-values_as=json&expected=0-expected.txt
    M Source/WebCore/loader/LinkLoader.cpp
    M Source/WebCore/loader/LinkLoader.h

  Log Message:
  -----------
  <link rel=preload as=json> should not trigger a preload
https://bugs.webkit.org/show_bug.cgi?id=317223
rdar://179843455

Reviewed by Chris Dumez.

`json` is a module preload destination [1], not a valid destination for
<link rel=preload>; so reject it. WebKit was nonetheless issuing the fetch.

LinkLoader::resourceTypeFromAsAttribute() unconditionally mapped
FetchRequestDestination::Json to CachedResource::Type::JSON. That mapping
was added for <link rel=modulepreload>, but the function is shared by the
plain preload path, the Link HTTP header path, and the speculative
HTMLPreloadScanner, so all of them inherited the json destination.

Thread an IsModulePreload flag through resourceTypeFromAsAttribute() and
only honor `as=json` when the link is a module preload; otherwise log a
console error and return nullopt so no resource is fetched. The
rel=modulepreload caller opts in with IsModulePreload::Yes; all other
callers keep the default.

[1] https://html.spec.whatwg.org/multipage/links.html#link-type-modulepreload
A module preload destination is "json", "style", "text", or a
script-like destination.

* 
LayoutTests/imported/w3c/web-platform-tests/preload/preload-type-match-expected.txt:
 Progressions
* 
LayoutTests/imported/w3c/web-platform-tests/preload/supported-as-values_as=json&expected=0-expected.txt:
 Ditto
* Source/WebCore/loader/LinkLoader.cpp:
(WebCore::LinkLoader::resourceTypeFromAsAttribute):
(WebCore::LinkLoader::preloadIfNeeded):
* Source/WebCore/loader/LinkLoader.h:

Canonical link: https://commits.webkit.org/315422@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to