Commit Graph

39 Commits

Author SHA1 Message Date
Brian Smith 993476283d Issue #1691 - Part 7e: Dependencies for required to finish part 7d. https://bugzilla.mozilla.org/show_bug.cgi?id=1331662 Reimplement EvaluateString using the ExecutionContext class. https://bugzilla.mozilla.org/show_bug.cgi?id=1316078 Extract redudant code into StartOffThreadParseTask. Use an ExclusiveContext instead of a JSContext in XDR functions. Add a script decoder as a valid off-main-thread parse-task. https://bugzilla.mozilla.org/show_bug.cgi?id=900784 Add nsJSUtils functions for encoding and decoding the bytecode. https://bugzilla.mozilla.org/show_bug.cgi?id=1316081 Add XDRIncrementalEncoder to replace delazified LazyScript in the encoded XDR buffer. Add an XDRIncrementalEncoder instance on the ScriptSource. Expose a new JSAPI to incrementally encode bytecode when it is generated. https://bugzilla.mozilla.org/show_bug.cgi?id=1334091 XDR function use the sourceObject instead of the enclosingScript as argument.
(cherry picked from commit d6de9a669f4b2f5115670bd771cd53d7cfb3956a)
2023-04-30 21:20:33 +08:00
Brian Smith d5d7bb5e47 Issue #1691 - Part 7d: Allow dynamic import in cases where there's no referencing script or module. Support dynamic import from classic scripts by creating ClassicScript objects and associating them with the compiled. https://bugzilla.mozilla.org/show_bug.cgi?id=1342012 This patch is incomplete, some code in ScriptLoader::EvaluateScript() could not be applied for missing dependencies. Part 7e will apply the missing dependencies and finish the patch.
(cherry picked from commit ce31a906e801b72f06385b0755710317ccf3658b)
2023-04-30 21:20:19 +08:00
Brian Smith ba01d99e31 Issue #1691 - Part 7b: Make load request element optional. https://bugzilla.mozilla.org/show_bug.cgi?id=1342012
(cherry picked from commit 169bb5d2ada59026fb6407716a7b3862810c9b97)
2023-04-30 21:19:50 +08:00
Brian Smith 9a19e9d165 Issue #1691 - Part 6c: Fix a few issues with the earlier commits. Need PNK_CALL_IMPORT and PNK_IMPORT_META in the node children list or it will abort. When porting ScriptFetchOptions support, I had 2 constructors, I picked the wrong one. Missed adding the preference javascript.options.dynamicImport to all.js.
(cherry picked from commit b95ccb711dc41b343d02ae69b3dc4747bbbe86fb)
2023-04-30 21:18:24 +08:00
Brian Smith 86e0057ea7 Issue #1691 - Part 6b: Initial browser support for dynamic import from module scripts. https://bugzilla.mozilla.org/show_bug.cgi?id=1342012 Factor out script fetch options from script load request classes. https://bugzilla.mozilla.org/show_bug.cgi?id=1480720 Remove support for version parameter from script loader. https://bugzilla.mozilla.org/show_bug.cgi?id=1428745
(cherry picked from commit 3ec2529aa6303f6950622e3cb91a23580649c73b)
2023-04-30 21:18:11 +08:00
Brian Smith 3f4985ce6c Issue #1691 - Part 3: Finish implementing import meta. https://bugzilla.mozilla.org/show_bug.cgi?id=1427610
(cherry picked from commit a8625238ac846fb7eb103646ddb8634a5860f067)
2023-04-30 21:17:00 +08:00
Brian Smith 1a6b3a822c Issue #1691 - Part 1: Provide a way of associating a private value with a script or module.
This is a prerequisite for dynamic import

(cherry picked from commit 2e2972647ee29340df51a804f05e40fc1da2c89b)
2023-04-30 21:16:28 +08:00
Moonchild 19e2f0fbf9 Issue #3058 - Try to deal with bad website scripting loading/unloading modules.
Apparently Bing does rapid-fire loading/unloading of module scripts that causes
our attempts at resolving and initializing them to end up with null fetched
modules. Returning null is probably a better way to handle this than crashing
on ms->ModuleRecord().
2022-03-22 23:07:42 +08:00
Moonchild 8c395520d9 Issue #1656 - Part 1: Nuke most vim config lines in the tree.
Since these are just interpreted comments, there's 0 impact on actual code.
This removes all lines that match /* vim: set(.*)tw=80: */ with S&R -- there are
a few others scattered around which will be removed manually in a second part.
2020-09-25 22:04:12 +08:00
Moonchild ef11a4d7e8 Issue #618 - Clear the module map when changing a Document's global and add
release build assertions for mismatching compartments.
2020-09-10 21:07:51 +08:00
Moonchild 7316d91ba2 Issue #618 - Make ES6 modules work for resource: URIs 2020-09-10 21:07:51 +08:00
Moonchild 1e87731ce1 Issue #618 - Implement preloading of module scripts.
This hooks up module scripts to the existing preload mechanism.
2020-09-10 21:07:50 +08:00
Gaming4JC 6c8f24a735 Issue #618 - Don't preload nomodule scripts when modules are enabled
Ref: BZ 1382020
2020-08-29 08:10:45 +08:00
Moonchild 3781c4a6dd Issue #618 - (async) Implement async attribute for inline module scripts.
This commit does several things:
- Moves the pref check from ScriptLoader to ns[I]Document so it can be called on
the document.
- Changes the atrribute freezing function to a better name that takes the
document as a parameter.
- Sets the proper async/defer attributes on HTML script elements based on
keywords and whether they are module scripts or not.
2020-08-29 08:10:42 +08:00
Moonchild 294721687c Issue #618 - (async) Keep track of script modes in a single mode state.
This simplifies handling of combinations of async/defer by assigning one and
only one state to scripts.
If async then always async > if defer or module then defer > otherwise blocking.
2020-08-29 08:10:40 +08:00
Moonchild 3fa4aabfad Issue #618 - (async, preload) Correctly pass info about async/defer to parser.
This makes sure we don't block body-referred sub-resources by head-referenced
defer and async scripts. This is important for all script loads, not just
modules, but is added here because it was run into while implementing modules.
2020-08-29 08:10:37 +08:00
Moonchild d8c2bc2976 Issue #618 - (async) Split out function to add async request. 2020-08-29 08:10:35 +08:00
Moonchild ecf9c7cf08 Issue #618 - Rename some script load request flags to be more descriptive. 2020-08-29 08:10:33 +08:00
Moonchild b7dbc3e795 Issue #618 - Make document.currentScript null in modules.
Because the spec says so.
2020-08-29 08:10:31 +08:00
Jon Coppeard d7889e2d2a Issue #618 - Fix processing of non-parser-generated module scripts. 2020-08-29 08:10:28 +08:00
Jon Coppeard 93d4766c01 Issue #618 - Handle errors for inline module scripts and ensure we update the
module map after fetch errors.
2020-08-29 08:10:26 +08:00
Moonchild 6c7ac2b844 Issue #618 - Split SRI verification out from OnStreamComplete. 2020-08-29 08:10:24 +08:00
Moonchild 7e6cd5def1 Issue #618 - Split handling of load errors out from OnStreamComplete. 2020-08-29 08:10:22 +08:00
Jon Coppeard 75f3f09fc6 Issue #618 - Don't mute errors for module scripts because they always use CORS 2020-08-29 08:10:17 +08:00
Moonchild 684f4824da Issue #618: Pass down referrer and referrer policy when fetching modules.
Because the spec says so.
2020-08-29 08:09:41 +08:00
Moonchild 97617a3ab1 Issue #618: Ignore 'event' and 'for' attributes for module scripts.
Because the spec says so.
2020-08-29 08:09:38 +08:00
Moonchild 34db761758 Issue #618 - Simplify module resolve hook to be a function pointer
This is an ahead-of time port to try and address #1624.
This is based on BZ 1461751 and Jon Coppeard's work in it.
2020-08-29 08:08:41 +08:00
Gaming4JC 6639e9cdac Issue #618 - Keep track of which modules in a graph have been fetched using a visited set
Ref: BZ 1365187
2020-08-29 08:08:23 +08:00
Gaming4JC f0d6e293a3 Issue #618 - Simplify module map interface
Ref: BZ 1365187
2020-08-29 08:08:19 +08:00
Jon Coppeard 40017437ab Issue #618 - Record module dependency before starting fetch so that error
handling works correctly

Ref BZ 1395896
2020-08-29 08:07:10 +08:00
Moonchild 0d874713ef Issue #618 - Align error handling for module scripts with the spec (again)
This updates module implementation to match spec regarding handling of
instantiation errors, after it was changed yet again, this time to not remember
instantiation errors, but instead immediately rethrow applicable ones.

Ref: BZ 1420420
2020-08-29 08:07:00 +08:00
Moonchild 933fb54415 Issue #618 - Fix error events fired when loading JS module dependencies fail
When module dependencies fail, don't spam with errors for each import; only fire
the error event once.

Ref: BZ 1421259
2020-08-29 08:06:57 +08:00
Moonchild 743bdc04fb Issue #618 - Further align error handling for module scripts with the spec
Ref: BZ 1388728
2020-07-10 22:18:04 +08:00
Moonchild a754a7be26 Issue #618 - Remove eager instantiation
This backs out the stuff added in Bug 1295978.
Ref: BZ 1295978, 1388728
2020-07-10 22:17:58 +08:00
Moonchild 91a79c0ddc Issue #618 - Match JSAPI names with the changes in 9ca74147225eed305e28c7887f9b2251aeeb0f36
Ref: BZ 1388728
2020-07-10 22:17:52 +08:00
Moonchild 336347212b Issue #618 - Add clarifying code comments. 2020-07-10 22:17:38 +08:00
Moonchild 27f4d0b5a5 Issue #618 - Check for failed instantiation when starting to fetch dependencies
If instantiation has failed, then also fail the load and don't fetch imports.
Ref BZ: 1358882
2020-07-10 22:17:34 +08:00
Moonchild c04b682a88 Issue #1603 - Part 2: Split some classes out of ScriptLoader.cpp
This splits ScriptLoader up the same way Mozilla did with the exception of
ScriptRequest due to the fact that ScriptLoader and ScriptRequest are
interdependent and would create a circular dependency if split apart when not
using unified building.
2020-07-04 07:01:03 +08:00
Moonchild f85b274e94 Issue #1603 - Part 1: Reorganize ScriptLoader/ScriptElement
- Moves scripting parts of DOM into 'dom/script'
- Renames nsScript{Loader/Element} to Script{Loader/Element}
- Adjusts all callers
2020-07-04 07:01:00 +08:00