[CSS Modules] Bypass fetch for Blob URL's #55779
Merged
+36
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After switching to Blob URL's in CL:7075691, I noticed that the fetched
stylesheet is not always available immediately in a fully declarative
scenario (where both the style tag is a module and
shadowrootadoptedstylesheets references it), which wasn't the case for
dataURI's. Typically, the first n fetches fail to fetch, where n is
random.
I discovered that dataURI's were always synchronously returned from
ResourceFetcher via CreateResourceForStaticData.
To match this behavior with Blob URL's, this CL immediately creates a
module map entry for a style type="module" upon parsing. This entry
can then be immediately queried when referenced from the
shadowrootadoptedstylesheetsattribute, avoiding a fetch entirely.DataURI's still need a fetch to generate the underlying object.
A test was added that failed ~50% of the time without this change.
Bug: 448174611
Change-Id: If50701981f7eaa138fff7d9ca799431c3303fa72
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7093679
Commit-Queue: Kurt Catti-Schmidt <[email protected]>
Reviewed-by: Mason Freed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1541305}