diff --git a/source b/source index 292a6968425..1ffccf86a3a 100644 --- a/source +++ b/source @@ -3112,6 +3112,15 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
Users agents that support JavaScript must also implement ECMAScript Internationalization API. JSINTL
+User agents that support JavaScript must also implement the ESM Phase Imports + proposal. The following terms are defined there, and used in this specification: + JSESMPHASEIMPORTS
+ +User agents that support JavaScript must also implement the Import Attributes proposal. The following terms are defined there, and used in this specification: JSIMPORTATTRIBUTES
@@ -9827,6 +9836,23 @@ interface DOMStringList { +Otherwise, if value has a [[SourceTextModuleRecord]] internal slot, then:
+ +If forStorage is true, then throw a
+ "DataCloneError
" DOMException
.
Let moduleScript be value.[[SourceTextModuleRecord]]. + [[HostDefined]].
Set serialized to { [[Type]]: "SourceTextModule", [[SourceText]]: value + .[[SourceTextModuleRecord]].[[SourceText]], [[BaseURL]]: moduleScript's + base URL, [[AgentCluster]]: the surrounding agent's agent + cluster }.
Otherwise, if value has an [[ErrorData]] internal slot and value is not a platform object, then:
@@ -10230,6 +10256,34 @@ o.myself = o;Set serialized to { [[Type]]: "SourceTextModule", [[SourceText]]: + value.[[SourceTextModuleRecord]].[[SourceText]], [[URL]]: moduleScript's + base URL, [[AgentCluster]]: the surrounding + agent's agent cluster }.
Otherwise, if serialized.[[Type]] is "SourceTextModule", then:
+ +If targetRealm's corresponding agent cluster is not
+ serialized.[[AgentCluster]], then throw a
+ "DataCloneError
" DOMException
.
Let settingsObject be targetRealm's environment settings + object.
Let options be a the default script fetch options.
Let moduleScript be the result of creating a JavaScript module script + using serialized.[[SourceText]], settingsObject, + serialized.[[BaseURL]], options, and false.
Let moduleRecord be moduleScript's record.
Set value to moduleRecord.GetModuleSource().
Otherwise, if serialized.[[Type]] is "Map", then:
@@ -107248,8 +107302,18 @@ document.querySelector("button").addEventListener("click", bound);A module script is another type of script. It has no additional items.
+ data-x="concept-script">script that has the following additional + item: + +A boolean which, if true, means that this script was initialized from a source text that
+ was securely obtained from a "script
" destination request for its base URL,
+ against the realm's policy container. It is true for modules loaded into the module registry, and
+ false for modules created via dynamic evaluation or compilation.
Module scripts can be classified into four types:
@@ -107811,8 +107875,8 @@ document.querySelector("button").addEventListener("click", bound);Let script be the result of creating a JavaScript module script - using sourceText, settingsObject, baseURL, and - options.
Fetch the descendants of
and link script, given settingsObject, "javascript-or-wasm
", then set moduleScript to the result of
creating a WebAssembly module script given bodyBytes,
settingsObject, response's URL, and options.
Otherwise:
@@ -108198,10 +108262,10 @@ document.querySelector("button").addEventListener("click", bound); decoding bodyBytes.If mimeType is a JavaScript MIME type and moduleType
- is "javascript-or-wasm
", then set moduleScript to the result of
- creating a JavaScript module script given sourceText,
+ is "javascript-or-wasm
", then set moduleScript to the result
+ of creating a JavaScript module script given sourceText,
settingsObject, response's URL, and options.
If the MIME type essence of mimeType is "text/css
"
and moduleType is "css
", then set moduleScript to
@@ -108331,8 +108395,8 @@ document.querySelector("button").addEventListener("click", bound);
To create a JavaScript module script, given a string source, an environment settings - object settings, a URL baseURL, and a script fetch - options options:
+ object settings, a URL baseURL, a script fetch + options options, and a boolean rootedSource:If scripting is disabled for @@ -108353,6 +108417,9 @@ document.querySelector("button").addEventListener("click", bound);
Set script's parse error and error to rethrow to null.
Set script's rooted source boolean to rootedSource.
+Let result be ParseModule(source, settings's realm, @@ -108381,8 +108448,8 @@ document.querySelector("button").addEventListener("click", bound);
To create a WebAssembly module script, given a byte sequence bodyBytes, an environment settings - object settings, a URL baseURL, and a script fetch - options options:
+ object settings, a URL baseURL, a script fetch + options options, and a boolean rootedSource:Set script's parse error and error to rethrow to null.
Set script's rooted source boolean to rootedSource.
+Let result be the result of parsing a WebAssembly module given bodyBytes, @@ -108759,7 +108829,6 @@ document.querySelector("button").addEventListener("click", bound); [[HostDefined]] field in the ScriptOrModule component of the running JavaScript execution context.
-Although the JavaScript specification does not account for this possibility, it's sometimes @@ -111058,6 +111127,75 @@ import "https://example.com/foo/../module2.mjs";
If moduleRequest is a Module Record then:
+ +Let moduleScript be moduleRequest.[[HostDefined]].
Assert: moduleScript is a JavaScript module script or a + WebAssembly module script.
Let url be moduleScript's + base URL.
Let moduleType be "javascript-or-wasm
".
Let moduleMap be settingsObject's module map.
Let completion be uninitialized.
If moduleMap[(url, moduleType)] does not exist, then:
+ +Set moduleMap[(url, moduleType)] to moduleScript + .
Set completion to Completion Record { [[Type]]: normal, + [[Value]]: moduleRequest, [[Target]]: empty }.
Otherwise: +
If moduleMap[(url, moduleType)] is "
+ fetching
", wait in parallel until that entry's value changes, then
+ queue a task on the networking task source to proceed with running
+ the following steps.
Let registryModule be moduleMap[(url, + moduleType)].
If registryModule is not null and moduleRequest.ModuleSourcesEqual( + registryModule) is true then:
+ +Set completion to Completion Record { [[Type]]: normal, + [[Value]]: registryModule, [[Target]]: empty }.
Otherwise:
+ +Set completion to Completion Record { [[Type]]: normal, + [[Value]]: moduleRequest, [[Target]]: empty }.
When a different module at the same module key already exists, we load the + module that was requested, but do not insert it into the registry, retaining the original + reference.
+Perform FinishLoadingImportedModule(referrer, + moduleRequest, payload, completion).
Let referencingScript be null.
Let originalFetchOptions be the default script fetch
@@ -120055,6 +120193,12 @@ function showLogout() {
Alternatively a module script Module Source Object
+ object can be provided directly: When a user agent is to run a worker for a script with
+ var worker = new Worker('helper.mjs', { type: "module" });
import source MyModule from './module.js';
+var worker = new Worker(MyModule);
+
Communicating with a dedicated worker
@@ -120531,12 +120675,15 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
Processing model
Worker
or
- SharedWorker
object worker, URL url,
- environment settings object outside settings, MessagePort
- outside port, and a WorkerOptions
dictionary options, it must
- run the following steps.SharedWorker
object worker, URL or module record
+ urlOrModuleRecord, environment settings object outside settings,
+ MessagePort
outside port, and a WorkerOptions
dictionary
+ options, it must run the following steps.
Assert: If urlOrModuleRecord is a URL, thenoptions's
+ type
member is not "classic
"
Let is shared be true if worker is a SharedWorker
object, and false otherwise.
Assert: urlOrModuleRecord is a URL.
Set worker global scope's constructor url to - url.
Set worker global scope's type to the value of options's
@@ -120608,10 +120757,15 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
shared is true, and "worker
" otherwise.
Obtain script by switching on the value of options's type
member:
If urlOrModuleRecord is a URL, then obtain script by
+ switching on the value of options's type
member:
auto
"classic
"In both cases, let performFetch be the following In all cases, let performFetch be the following perform the fetch hook given request, isTopLevel and processCustomFetchResponse:
@@ -120709,116 +120863,254 @@ interface SharedWorkerGlobalScope : WorkerGlobalScopeIn both cases, let onComplete given script be the following steps:
+In all cases, let onComplete given script be the following step:
If script is null or if script's error to rethrow is non-null, then:
- -Queue a global task on the DOM manipulation task source given
- worker's relevant global object to fire an event named error
- at worker.
Initialize a worker given worker, outside port, + is shared, script, inside settings, and worker global scope + .
Run the environment discarding steps - for inside settings.
Otherwise,
-Abort these steps.
Let script be urlOrModuleRecord.[[HostDefined]].
Associate worker with worker global scope.
Let baseURL be script's base URL
Let inside port be a new MessagePort
object in
- inside settings's realm.
If baseURL is null, then: +
Assert: script's rooted source property is false. +
Associate inside port with worker global scope.
Set baseURL to outside settings's API base URL
+Entangle outside port and inside port.
Set worker global scope's url + to baseURL.
Create a new WorkerLocation
object and associate it with worker global
- scope.
Set workerGlobalScope's policy container to a clone of outside settings's + policy container. + +
Let target module be undefined.
Let options be a script fetch options whose cryptographic nonce is the empty string, integrity metadata is the empty string,
+ parser metadata is "not-parser-inserted
", credentials mode is the value of the
+ credentials
member of options, referrer policy is the empty
+ string, and fetch priority is
+ "auto
".
Closing orphan workers: Start monitoring the worker such that no sooner than - it stops being a protected worker, and no later than it stops being a - permissible worker, worker global scope's closing flag is set to true.
-If urlOrModuleRecord is a Source Text Module Record then:
+Let sourceText be urlOrModuleRecord.[[SourceText]].
Set target module to the result of creating a JavaScript module script + with sourceText, inside settings, urlOrModuleRecord's + base URL, options and urlOrModuleRecord's + rooted source.
Suspending workers: Start monitoring the worker, such that whenever - worker global scope's closing - flag is false and the worker is a suspendable worker, the user agent suspends - execution of script in that worker until such time as either the closing flag switches to true or the worker stops - being a suspendable worker.
+Otherwise, urlOrModuleRecord is a WebAssembly Module Record, then: +
+ +Let wasmModule be urlOrModuleRecord.[[WebAssemblyModule]].
+Let bytes be wasmModule.[[Bytes]].
Set target module to the result of creating a JavaScript module script + with sourceText, inside settings, urlOrModuleRecord's + base URL, and urlOrModuleRecord's rooted source.
Set inside settings's execution ready flag.
TODO: CSP filter on transferred modules - eval (rooted source) / src checks?
If the Run CSP initialization for a global object algorithm returns
+ "Blocked
" when executed upon worker global scope, throw a new
+ DOMException
and run fail worker initialization with worker
+ , and inside settings and abort these steps. CSP
TODO: refactor out use of response here:
Otherwise, if the result of
+ checking a global object's embedder policy with worker global scope,
+ outsidesettings, and response is false, then throw a DOMException
+
and run fail worker initialization with worker, and inside
+ settings and abort these steps.
+
+
Set worker global scope's cross-origin isolated
+ capability to true if agent's agent cluster's cross-origin isolation mode is "concrete
".
If owner's cross-origin isolated + capability is false, then set worker global scope's cross-origin isolated + capability to false.
If modules's rooted source property is false, then set + worker global scope's cross-origin isolated + capability to false.
If script is a classic script, then run the classic script script. Otherwise, it is a module - script; run the module script - script.
- -In addition to the usual possibilities of returning a value or failing due to - an exception, this could be prematurely aborted by - the terminate a worker algorithm defined below.
+Fetch the descendants
+ of and link target module given inside settings,
+ "script
", and onComplete and with onComplete
+ given module defined as the following step:
Initialize a worker given worker, outside port, + false, module, inside settings, and worker global scope.
+Enable outside port's port message queue.
If is shared is false, enable the port message queue - of the worker's implicit port.
When a user agent is to fail worker initialization for a script with
+ Worker
or SharedWorker
object worker, and environment settings
+ object inside settings , it must run the following steps.
If is shared is true, then queue a global task on DOM
- manipulation task source given worker global scope to fire an event named connect
at worker global scope, using
- MessageEvent
, with the data
attribute
- initialized to the empty string, the ports
attribute
- initialized to a new frozen array containing inside port, and the source
attribute initialized to inside
- port.
Queue a global task on the DOM manipulation task source given
+ worker's relevant global object to fire an event named error
+ at worker.
Enable the client message queue of the
- ServiceWorkerContainer
object whose associated service worker client is
- worker global scope's relevant settings object.
Run the environment discarding steps + for inside settings.
Event loop: Run the responsible - event loop specified by inside settings until it is destroyed.
+The handling of events or the execution of callbacks by tasks run by the event loop might get prematurely aborted by the terminate a - worker algorithm defined below.
+When a user agent is to initialize a worker for a script with Worker
+
or SharedWorker
object worker, MessagePort
+ outside port, boolean is shared, module script or classic
+ script script, environment settings object inside settings
+ , and a global object worker global scope, it must run the following
+ steps.
The worker processing model remains on this step until the event loop is - destroyed, which happens after the closing - flag is set to true, as described in the event loop processing model.
-If script is null or if script's error to rethrow is non-null, then:
-Clear the worker global scope's - map of active timers.
-Fail worker initialization given worker and inside settings +
Disentangle all the ports in the list of the worker's ports.
-Abort these steps.
Empty worker global scope's owner set.
-Associate worker with worker global scope.
Let inside port be a new MessagePort
object in
+ inside settings's realm.
Associate inside port with worker global scope.
Entangle outside port and inside port.
Create a new WorkerLocation
object and associate it with worker global
+ scope.
Closing orphan workers: Start monitoring the worker such that no sooner than + it stops being a protected worker, and no later than it stops being a + permissible worker, worker global scope's closing flag is set to true.
+Suspending workers: Start monitoring the worker, such that whenever + worker global scope's closing + flag is false and the worker is a suspendable worker, the user agent suspends + execution of script in that worker until such time as either the closing flag switches to true or the worker stops + being a suspendable worker.
+Set inside settings's execution ready flag.
If script is a classic script, then run the classic script script. Otherwise, it is a module + script; run the module script + script.
+ +In addition to the usual possibilities of returning a value or failing due to + an exception, this could be prematurely aborted by + the terminate a worker algorithm defined below.
+Enable outside port's port message queue.
If is shared is false, enable the port message queue + of the worker's implicit port.
If is shared is true, then queue a global task on DOM
+ manipulation task source given worker global scope to fire an event named connect
at worker global scope, using
+ MessageEvent
, with the data
attribute
+ initialized to the empty string, the ports
attribute
+ initialized to a new frozen array containing inside port, and the source
attribute initialized to inside
+ port.
Enable the client message queue of the
+ ServiceWorkerContainer
object whose associated service worker client is
+ worker global scope's relevant settings object.
Event loop: Run the responsible + event loop specified by inside settings until it is destroyed.
+ +The handling of events or the execution of callbacks by tasks run by the event loop might get prematurely aborted by the terminate a + worker algorithm defined below.
+ +The worker processing model remains on this step until the event loop is + destroyed, which happens after the closing + flag is set to true, as described in the event loop processing model.
+Clear the worker global scope's + map of active timers.
+Disentangle all the ports in the list of the worker's ports.
+Empty worker global scope's owner set.
[Exposed=(Window,DedicatedWorker,SharedWorker)]
interface Worker : EventTarget {
- constructor((TrustedScriptURL
or USVString) scriptURL, optional WorkerOptions options = {});
+ constructor((TrustedScriptURL
or USVString or object) moduleOrURL, optional WorkerOptions options = {});
undefined terminate();
@@ -120992,25 +121284,27 @@ interface Worker : EventTarget {
};
dictionary WorkerOptions {
- WorkerType type = "classic";
+ WorkerType type = "auto";
RequestCredentials credentials = "same-origin"; // credentials is only used if type is "module"
DOMString name = "";
};
-enum WorkerType { "classic", "module" };
+enum WorkerType { "classic", "module", "auto" };
Worker includes AbstractWorker;
worker = new Worker(scriptURL [, options ])
Returns a new Returns a new Worker
object. scriptURL will be fetched and
- executed in the background, creating a new global environment for which worker
- represents the communication channel. options can be used to define the worker = new Worker(moduleOrURL [, options ])
+ Worker
object. moduleOrURL will be loaded in the
+ background, creating a new global environment for which worker represents the
+ communication channel. options can be used to define the name of that global environment via the name
option, primarily for debugging purposes. It can also ensure this new
- global environment supports JavaScript modules (specify type: "module"
),
- and if that is specified, can also be used to specify how scriptURL is fetched through
- the credentials
option.
+ type: "module"
, and if that is specified, can also be used to specify how moduleOrURL
+ and its dependencies are fetched through the credentials
option.
+ When moduleOrURL is a Module Source Object, type: "module
+
is the default and only setting supported.
worker.terminate()
When the When the Let outside settings be the current settings object. If moduleOrURL is an object, then: Let module be the result of invoking GetModuleSourceModuleRecord
+ with moduleOrURL. If module is not Assert: module is either a Source Text Module Record
+ or a WebAssembly Module Record. Let worker be a new Let outside port be a new Associate the outside port with worker. If options's Run this step in parallel: Run a worker given worker, module,
+ outside settings, outside port, and options. Return worker. Let compliantScriptURL be the result of invoking the Get Trusted Type compliant string algorithm with Let outside settings be the current settings object. Let worker URL be the result of encoding-parsing a URL given
compliantScriptURL, relative to outside settings.Worker(scriptURL,
+
Worker(moduleOrURL,
options)
constructor is invoked, the user agent must run the following
steps:
+
+
+ ~not-a-module~
, then:
+
+ Worker
object.MessagePort
in
+ outside settings's realm.type
member is "classic
+
", then throw a "TypeError
" DOMException
.
+
+ TrustedScriptURL
, this's relevant global
- object, scriptURL, "Worker constructor
", and ", scriptURLOrModule, "
Worker constructor
", and "script
".