Skip to content

Add tests for text modules#56812

Open
eemeli wants to merge 4 commits intoweb-platform-tests:masterfrom
eemeli:import-text
Open

Add tests for text modules#56812
eemeli wants to merge 4 commits intoweb-platform-tests:masterfrom
eemeli:import-text

Conversation

@eemeli
Copy link

@eemeli eemeli commented Dec 17, 2025

This is to support the spec changes in:

I've effectively tried to duplicate and appropriately modify all the tests for JSON modules that I was able to find.

@bakkot
Copy link
Contributor

bakkot commented Dec 17, 2025

Might consider adding a test that the request has a Sec-Fetch-Dest: text header. I think this is lacking for JSON as well, and have it on my backlog to write such a test, but as long as you're here...

Also, you could add a test that importing a module as JS, from a server which responds with valid JS file with a content type of text/javascript (and so loading succeeds), and then fetching it again with type: "text" causes two network requests (because the type is part of the module map). This is similar to repeated-imports.any.js but the other way around.

@eemeli
Copy link
Author

eemeli commented Dec 20, 2025

Might consider adding a test that the request has a Sec-Fetch-Dest: text header. I think this is lacking for JSON as well, and have it on my backlog to write such a test, but as long as you're here...

Done. There are some test for the JSON module fetch headers already at fetch/metadata/tools/templates/script-json-module-import-static.sub.html; I added corresponding ones for text modules, as well as a non-generated test modeled after the audioworklet test.

Also, you could add a test that importing a module as JS, from a server which responds with valid JS file with a content type of text/javascript (and so loading succeeds), and then fetching it again with type: "text" causes two network requests (because the type is part of the module map). This is similar to repeated-imports.any.js but the other way around.

Done; added those to repeated-imports.any.js.

@eemeli eemeli requested a review from bakkot December 20, 2025 10:01
@bakkot
Copy link
Contributor

bakkot commented Dec 20, 2025

New tests look great, thanks.

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

Comments