Closed Bug 1877792 Opened 1 year ago Closed 1 year ago

JSON modules browser integration

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
132 Branch
Tracking Status
firefox132 --- fixed

People

(Reporter: jon4t4n, Assigned: jon4t4n)

References

(Blocks 2 open bugs)

Details

(Keywords: dev-doc-needed)

Attachments

(20 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
No description provided.
Blocks: 1670176
Type: task → enhancement
Severity: -- → N/A
Priority: -- → P3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: nobody → jonatan.r.klemets
Status: NEW → ASSIGNED

The module maps (mFetchingModules and mFetchedModules) in
ModuleLoaderBase was previously only keyed by the URL and used the
nsURIHashKey hashtable key class. This is no longer sufficient, and the key
should also contain the module type.

This patch introduces a new hashtable key class called ModuleMapKey and
changes mFetchingModules and mFetchedModules to use the new key type.

To make this a bit easier to review, this first patch only introduces the new
key type and hard-codes the type to Javascript where the key is constructed.
The hard-corded module types will be fixed in later patches.

We need to change JSONFullParseHandler::reportError (when compiling JSON
modules), so that we create syntax errors with the required metadata attached
(line, column, filename).

Depends on D160386

Attachment #9390435 - Attachment description: Bug 1877792 - Part 3: Add CompileJsonModule version for SourceText<Utf8Unit> r=mgaudet!,yulia! → Bug 1877792 - Part 4: Add CompileJsonModule version for SourceText<Utf8Unit> r=mgaudet!,yulia!
Attachment #9390436 - Attachment description: Bug 1877792 - Part 4: Use AutoReportFrontendContext in CompileJsonModule for error reporting r=dminor!,mgaudet! → Bug 1877792 - Part 5: Use AutoReportFrontendContext in CompileJsonModule for error reporting r=dminor!,mgaudet!
Attachment #9390437 - Attachment description: WIP: Bug 1877792 - Part 5: JSON modules DOM integration r=mgaudet!,yulia!,dminor! → Bug 1877792 - Part 6: JSON modules DOM integration r=#spidermonkey-reviewers

We need to encode content_type by calling encodeURIComponent. Otherwise,
the plus sign is treated as a space.

This patch is a small step towards the end goal, so we hardcoded the module
type to JS::ModuleType::JavaScript, but that will get changed in a later
patch.

This patch gets rid of most hard-coded JS::ModuleType::JavaScript in
js/loader/ModuleLoaderBase.cpp. However, the module type is still hard-coded
when constructing the ModuleLoadRequest (will be addressed in a later patch).

This patch adds the new parameter to the NewVisitedSetForTopLevelImport
method, but we hard-code the module type (which will be addressed in a later
patch)

This patch adds a module type parameter to
ModuleLoaderBase::{CreateStaticImport,CreateDynamicImport}, and gets rid of a
bunch of hard-coded JS::ModuleType::JavaScript. However, the module type is
still hard-coded when we call CreateDynamicImport and CreateStaticImport.

Synthetic modules do not have any dependencies, so calling
GetRequestedModulesCount results in cash. This patch fixes this by making
ResolveRequestedModules return early for synthetic modules.

This is something we may want to investigate and implement, but it felt out of
scope for the initial implementation.

Attachment #9390437 - Attachment description: Bug 1877792 - Part 6: JSON modules DOM integration r=#spidermonkey-reviewers → Bug 1877792 - Part 17: Extend CompileFetchedModule to handle JSON modules r=#spidermonkey-reviewers,#dom-worker-reviewers!,#dom-core!
Attachment #9417062 - Attachment description: Bug 1877792 - Part 7: Update WPT prefs to enable JSON modules r=#spidermonkey-reviewers → Bug 1877792 - Part 18: Update WPT prefs to enable JSON modules r=#spidermonkey-reviewers
Attachment #9417063 - Attachment description: Bug 1877792 - Part 8: Update WPT test expectations or JSON modules r=#spidermonkey-reviewers → Bug 1877792 - Part 19: Update WPT test expectations or JSON modules r=#spidermonkey-reviewers
Attachment #9417064 - Attachment description: Bug 1877792 - Part 9: Fix URL encoding in JSON module WPT tests r=#spidermonkey-reviewers → Bug 1877792 - Part 20: Fix URL encoding in JSON module WPT tests r=#spidermonkey-reviewers
Attachment #9417771 - Attachment description: Bug 1877792 - Part 12: Add JS::IsSyntheticModule r=#spidermonkey-reviewers → Bug 1877792 - Part 12: Add JS::IsCyclicModule r=#spidermonkey-reviewers
Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4c7182604e4f Part 1: Change HttpBaseChannel.cpp to allow application/json r=yulia,necko-reviewers,jesup,valentin https://hg.mozilla.org/integration/autoland/rev/82a58a80f58a Part 2: Change the module map key to include both URL and module type r=yulia,jonco https://hg.mozilla.org/integration/autoland/rev/d73a9f57f03c Part 3: Update module map methods to take ModuleMapKey instead of nsIURI r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/3cead4149e6b Part 4: Add CompileJsonModule version for SourceText<Utf8Unit> r=mgaudet,yulia https://hg.mozilla.org/integration/autoland/rev/5b1e29e4c597 Part 5: Use AutoReportFrontendContext in CompileJsonModule for error reporting r=bthrall https://hg.mozilla.org/integration/autoland/rev/bd23c96418b6 Part 6: Change ModuleLoaderBase::ResolveRequestedModules to handle URL and module type r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/0674cf646120 Part 7: Add ModuleLoadRequest::mModuleType r=dom-core,spidermonkey-reviewers,dom-worker-reviewers,asuth,jonco,mccr8 https://hg.mozilla.org/integration/autoland/rev/d763241fccaf Part 8: Add module type to ModuleLoadRequest::NewVisitedSetForTopLevelImport r=spidermonkey-reviewers,dom-worker-reviewers,dom-core,asuth,jonco,mccr8 https://hg.mozilla.org/integration/autoland/rev/95b20763e650 Part 9: Add module type to ModuleLoaderBase::{CreateStaticImport,CreateDynamicImport} r=spidermonkey-reviewers,dom-worker-reviewers,dom-core,asuth,jonco,mccr8 https://hg.mozilla.org/integration/autoland/rev/39a20aee3942 Part 10: Get the module type from the module request r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/fe179004423b Part 11: Only allow expected mime types r=dom-worker-reviewers,dom-core,asuth,hsivonen https://hg.mozilla.org/integration/autoland/rev/a4d7565218f3 Part 12: Add JS::IsCyclicModule r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/a1f494b9592a Part 13: Skip setting/clearing the module private for synthetic modules r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/a3b5b0cde6ce Part 14: Return early in ModuleLoaderBase::ResolveRequestedModules for synthetic modules r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/1234a31ff88f Part 15: Skip ExposeScriptToDebugger/UpdateDebugMetadata for synthetic modules r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/d98ecddf2f59 Part 16: Disable off-thread compilaton for JSON modules r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/48dc4035a14f Part 17: Extend CompileFetchedModule to handle JSON modules r=spidermonkey-reviewers,dom-core,jonco,mccr8 https://hg.mozilla.org/integration/autoland/rev/662eb52b2a6f Part 18: Update WPT prefs to enable JSON modules r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/14f104e5ce51 Part 19: Update WPT test expectations or JSON modules r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/19d78d0b6ee4 Part 20: Fix URL encoding in JSON module WPT tests r=spidermonkey-reviewers,jonco
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/47741 for changes under testing/web-platform/tests
Upstream PR was closed without merging
Flags: needinfo?(jonatan.r.klemets)

Now, when the code freeze has been lifted, we can try to re-land these patches. Jon, can you queue this for landing again?

Flags: needinfo?(jcoppeard)
Flags: needinfo?(jcoppeard)
Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1de3f8d89dec Part 1: Change HttpBaseChannel.cpp to allow application/json r=yulia,necko-reviewers,jesup,valentin https://hg.mozilla.org/integration/autoland/rev/67c5323f1554 Part 2: Change the module map key to include both URL and module type r=yulia,jonco https://hg.mozilla.org/integration/autoland/rev/0c5bcdad91ed Part 3: Update module map methods to take ModuleMapKey instead of nsIURI r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/579d484a8683 Part 4: Add CompileJsonModule version for SourceText<Utf8Unit> r=mgaudet,yulia https://hg.mozilla.org/integration/autoland/rev/0e95f906a999 Part 5: Use AutoReportFrontendContext in CompileJsonModule for error reporting r=bthrall https://hg.mozilla.org/integration/autoland/rev/67b7056ae5db Part 6: Change ModuleLoaderBase::ResolveRequestedModules to handle URL and module type r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/f0e296342474 Part 7: Add ModuleLoadRequest::mModuleType r=dom-core,spidermonkey-reviewers,dom-worker-reviewers,asuth,jonco,mccr8 https://hg.mozilla.org/integration/autoland/rev/28035acf7788 Part 8: Add module type to ModuleLoadRequest::NewVisitedSetForTopLevelImport r=spidermonkey-reviewers,dom-worker-reviewers,dom-core,asuth,jonco,mccr8 https://hg.mozilla.org/integration/autoland/rev/b83c58b4a868 Part 9: Add module type to ModuleLoaderBase::{CreateStaticImport,CreateDynamicImport} r=spidermonkey-reviewers,dom-worker-reviewers,dom-core,asuth,jonco,mccr8 https://hg.mozilla.org/integration/autoland/rev/9b247d7d4dd3 Part 10: Get the module type from the module request r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/eb947a73a97f Part 11: Only allow expected mime types r=dom-worker-reviewers,asuth https://hg.mozilla.org/integration/autoland/rev/3457e8d54eb5 Part 12: Add JS::IsCyclicModule r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/3fdcdf158eb7 Part 13: Skip setting/clearing the module private for synthetic modules r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/a0db4567cf83 Part 14: Return early in ModuleLoaderBase::ResolveRequestedModules for synthetic modules r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/66c4ccedeecb Part 15: Skip ExposeScriptToDebugger/UpdateDebugMetadata for synthetic modules r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/d99e07f9cbeb Part 16: Disable off-thread compilaton for JSON modules r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/c005e9f8e985 Part 17: Extend CompileFetchedModule to handle JSON modules r=spidermonkey-reviewers,dom-core,jonco,mccr8 https://hg.mozilla.org/integration/autoland/rev/a6641dc244fa Part 18: Update WPT prefs to enable JSON modules r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/cd4e9f2dfdae Part 19: Update WPT test expectations or JSON modules r=spidermonkey-reviewers,jonco https://hg.mozilla.org/integration/autoland/rev/b0bf3998767e Part 20: Fix URL encoding in JSON module WPT tests r=spidermonkey-reviewers,jonco
Upstream PR merged by moz-wptsync-bot

Is this something we should call out in the Fx132 relnotes?

Flags: needinfo?(jonatan.r.klemets)
Flags: in-testsuite+

I don't know anything about how and when the release notes are handled, so I will defer to Dan here. That said, this is currently nightly only, and shipping is tracked under bug 1777526, so I don't think we want to mention this in the relnotes for Fx132.

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

Yes, I think we can wait on the release notes until bug 1777526, unless we normally call out experimental features like this, which I'm not sure we do.

Flags: needinfo?(dminor)

We do have the ability to add Nightly-only release notes if you want to call it out there to encourage testing. Totally up to you, though.

Blocks: 1912112
Regressions: 1927125
Regressions: 1965620
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: