Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: fe24f90cc7e7901576f3561ff7b2dee255063cee
https://github.com/WebKit/WebKit/commit/fe24f90cc7e7901576f3561ff7b2dee255063cee
Author: Ahmad Saleem <[email protected]>
Date: 2026-07-13 (Mon, 13 Jul 2026)
Changed paths:
A
LayoutTests/inspector/css/clear-stylesheets-for-resource-invalidates-cache-expected.txt
A
LayoutTests/inspector/css/clear-stylesheets-for-resource-invalidates-cache.html
M Source/WebInspectorUI/UserInterface/Controllers/CSSManager.js
Log Message:
-----------
Web Inspector: stylesheet resource cache is never invalidated when a resource
is added or changes type
https://bugs.webkit.org/show_bug.cgi?id=319270
rdar://182113358
Reviewed by Devin Rousso.
CSSManager keeps two maps: `_styleSheetIdentifierMap`, keyed by stylesheet id
(`target:styleSheetId`), and `_styleSheetFrameURLMap`, keyed by frame+URL
(`frame.id + ":" + url`). `_clearStyleSheetsForResource` is meant to evict the
frame+URL entry so the next `_lookupStyleSheet` misses and re-fetches via
`_fetchInfoForAllStyleSheets`, but it called `delete` on
`_styleSheetIdentifierMap` with a frame+URL key. That key can never exist in the
id-keyed map, so the delete was a permanent no-op and a stale stylesheet could
be
returned after a stylesheet resource was added (`_resourceAdded`) or its type
changed to StyleSheet (`_resourceTypeDidChange`).
This was introduced in 166259@main when the plain-object maps were converted to
`Map`; the two `delete` lines in this method were retargeted to the wrong map
while every other reference correctly stayed on `_styleSheetFrameURLMap`.
Delete from `_styleSheetFrameURLMap` instead, matching the key that
`_frameURLMapKey` produces and the map that `_lookupStyleSheet` reads.
Test: inspector/css/clear-stylesheets-for-resource-invalidates-cache.html
* Source/WebInspectorUI/UserInterface/Controllers/CSSManager.js:
(WI.CSSManager.prototype._clearStyleSheetsForResource): Evict from the frame+URL
map so the next lookup re-fetches.
*
LayoutTests/inspector/css/clear-stylesheets-for-resource-invalidates-cache.html:
Added.
*
LayoutTests/inspector/css/clear-stylesheets-for-resource-invalidates-cache-expected.txt:
Added.
Primes the frame+URL cache, confirms a repeat lookup is served from the cache,
then confirms a lookup after Resource.Event.TypeDidChange re-fetches. The last
case fails without the fix.
Canonical link: https://commits.webkit.org/317084@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications