Closed Bug 1977784 Opened 6 months ago Closed 5 months ago

Strict MIME type checks breaks dynamic import of JSON modules in workers

Categories

(Core :: DOM: Workers, defect)

defect

Tracking

()

RESOLVED FIXED
143 Branch
Tracking Status
firefox-esr115 --- unaffected
firefox-esr128 --- unaffected
firefox-esr140 --- wontfix
firefox140 --- wontfix
firefox141 --- wontfix
firefox142 --- wontfix
firefox143 --- fixed

People

(Reporter: jon4t4n, Assigned: jon4t4n)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

Since bug 1858078 JSON module (i.e. with {type: "json"}) loads have their own nsContentPolicyType(s), and bug 1966620 will start enforcing strict MIME type checking for JSON loads. In WorkerScriptLoader::GetContentPolicyType, we currently always return nsIContentPolicy::TYPE_INTERNAL_MODULE for dynamic imports, so JSON modules will fail to load. We want to change this to return nsIContentPolicy::TYPE_JSON, similar to what we do in the DOM script loader.

Set release status flags based on info from the regressing bug 1858078

Since bug 1858078, JSON modules (using {type: "json"}) have dedicated
nsIContentPolicy values, and bug 1966620 will enforce strict MIME type
checking.

Currently, WorkerScriptLoader::GetContentPolicyType always returns
nsIContentPolicy::TYPE_INTERNAL_MODULE for dynamic imports, which
causes JSON modules to fail loading when strict MIME checking is
applied.

This patch changes GetContentPolicyType to return
nsIContentPolicy::TYPE_JSON for JSON modules, matching the behavior of
the DOM script loader and fixing dynamic imports of JSON modules in
worker contexts.

Assignee: nobody → jonatan.r.klemets
Status: NEW → ASSIGNED
Severity: -- → S3

Set release status flags based on info from the regressing bug 1858078

Do you need help getting this landed?

Flags: needinfo?(jonatan.r.klemets)

(In reply to Tom Schuster (MoCo) from comment #4)

Do you need help getting this landed?

Been OOO for a week, but now when I tried to land the stack, it looks odd in lando. The repository of https://phabricator.services.mozilla.com/D257112 is beta and not autoland for some reason. Do you know if I can just edit the revision in Phabricator and select the autoland repository?

Flags: needinfo?(jonatan.r.klemets) → needinfo?(tschuster)

I am not sure, I would just try it? You should not be able to push to beta accidentally if you are worried about that.

Flags: needinfo?(tschuster)

It's bug 1963406. You can fix the target repository by going to "Edit Revision" and changing it back to autoland. Double check the diff that phabricator shows. It will have changed the diff back to the version that was commited and backed out on July 16. So if you have made changes since then, you will need to use moz-phab again to get your most recent local changes back into phabricator.

Pushed by jonatan.r.klemets@gmail.com: https://github.com/mozilla-firefox/firefox/commit/802c662da903 https://hg.mozilla.org/integration/autoland/rev/7501bab1f718 Update WorkerScriptLoader::GetContentPolicyType to return TYPE_JSON for JSON modules r=dom-worker-reviewers,edenchuang
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 143 Branch

The patch landed in nightly and beta is affected.
:jon4t4n, is this bug important enough to require an uplift?

For more information, please visit BugBot documentation.

Flags: needinfo?(jonatan.r.klemets)
Flags: needinfo?(jonatan.r.klemets)
QA Whiteboard: [qa-triage-done-c144/b143]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: