Skip to content

Add tests for modulepreload links with JSON and CSS, remove json with non-module preload#56617

Merged
yoavweiss merged 15 commits intoweb-platform-tests:masterfrom
KurtCattiSchmidt:modulepreload-json-style
Jan 30, 2026
Merged

Add tests for modulepreload links with JSON and CSS, remove json with non-module preload#56617
yoavweiss merged 15 commits intoweb-platform-tests:masterfrom
KurtCattiSchmidt:modulepreload-json-style

Conversation

@KurtCattiSchmidt
Copy link
Copy Markdown
Contributor

@KurtCattiSchmidt KurtCattiSchmidt commented Dec 9, 2025

Per whatwg/html#10233, "json" and "style" should be supported for modulepreload. This PR adds tests for this.

In the PR to update the HTML5 spec for these changes, it was also recommended that support for non-module JSON preloads be removed, as it only makes sense in a module context. This change also updates tests for that scenario.

The existing tests had a flakiness problem that this change addressed in order to satisfy the "unstable results" bots. Specifically, modulepreload-as.html was modified fairly substantially. It no longer checks performance.getEntriesByName, as the preload scanner was fetching the files and firing events, but the performance entries were not always getting updated in time for the test. Now, the test only checks for events fired, as that is all we can determine consistently at test time. The event handlers were also moved to markup, which avoids a race between the preload scanner fetching the files and the event handlers being added.

@KurtCattiSchmidt
Copy link
Copy Markdown
Contributor Author

@annevk FYI

Comment thread preload/modulepreload.html Outdated
});
}, 'link rel=modulepreload');

promise_test(function(t) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a utility function that accepts the different URLs and as values?

Copy link
Copy Markdown
Contributor Author

@KurtCattiSchmidt KurtCattiSchmidt Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest commit revamps this to take an array of module types for shared tests. That way we can have unique tests for each module type. This reduced a lot of duplication. It's not used everywhere because a lot of these tests are unique for script, but it'll make it much easier to expand for future module types like "text".

Comment thread preload/modulepreload.html Outdated
Copy link
Copy Markdown
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me but it seems like it needs rebasing to get CI to be green.

Comment thread preload/modulepreload.html Outdated
Comment thread preload/modulepreload.html Outdated
Copy link
Copy Markdown
Contributor

@yoavweiss yoavweiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % helper

Comment thread preload/modulepreload-as.html Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants