diff --git a/source b/source index 83c2f45d482..3b9d4e5c192 100644 --- a/source +++ b/source @@ -2755,6 +2755,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
JavaScript contains an implementation-defined HostEnsureCanCompileStrings(callerRealm,
+ calleeRealm) abstract operation. User agents must use the following implementation:
+
+
+
+
+ JavaScript contains an implementation-defined HostPromiseRejectionTracker(promise,
+ operation) abstract operation. User agents must use the following implementation:
+ Let script be the running script. If script's muted errors is true, terminate these steps. Let settings object be script's settings object. If operation is Add promise to settings object's about-to-be-notified
+ rejected promises list. If operation is If settings object's about-to-be-notified rejected promises
+ list contains promise, then remove promise from that list and
+ return. If settings object's outstanding rejected promises weak set
+ does not contain promise, then return. Remove promise from settings object's outstanding rejected
+ promises weak set. Let global be settings object's global object. Queue a global task on the DOM manipulation task source given
+ global to fire an event named The JavaScript specification defines Jobs to be scheduled and run later by the host, as well as
+ JobCallback Records which encapsulate JavaScript
+ functions that are called as part of jobs. The JavaScript specification contains a number of
+ implementation-defined abstract operations that lets the host define how jobs are
+ scheduled and how JobCallbacks are handled. This section defines them for user agent hosts. JavaScript contains an implementation-defined HostCallJobCallback(callback, V,
+ argumentsList) abstract operation to let hosts restore state when invoking JavaScript
+ callbacks from inside tasks. HTML restores the incumbent settings object and the
+ active script. User agents must use the following implementation: Let incumbent settings be
+ callback.[[HostDefined]].[[IncumbentSettings]]. Let script execution context be
+ callback.[[HostDefined]].[[ActiveScriptContext]]. Prepare to run a callback with incumbent settings. This affects the incumbent
+ concept while the callback runs. If script execution context is not null, then push script execution context onto the JavaScript execution
+ context stack. This affects the active script while the callback runs. Let result be Call(callback.[[Callback]], V,
+ argumentsList). If script execution context is not null, then pop script execution context from the JavaScript execution context
+ stack. Clean up after running a callback with incumbent
+ settings. Return result. JavaScript contains an implementation-defined HostEnqueuePromiseJob(job, realm)
@@ -89687,58 +89810,6 @@ dictionary PromiseRejectionEventInit : EventInit {
- Let incumbent settings be the incumbent settings object. Let active script be the active script. Let script execution context be null. If active script is not null, set script execution context to a new
- JavaScript execution context, with its Function field set to null, its Realm field
- set to active script's settings object's Realm, and its ScriptOrModule set to active script's
- record. As seen below, this is used in order to propagate the current active
- script forward to the time when the job is executed. A case where active script is non-null, and saving it in this way is useful, is
- the following: Without this step (and the steps below that use it), there would be no active
- script when the With this step in place, the active script is propagated from the above code into the job,
- allowing active script can be null if the user clicks on the following button: In this case, the JavaScript function for the event
- handler will be created by the get the current value of the event handler algorithm, which creates a function
- with null [[ScriptOrModule]] value. Thus, when the promise machinery calls
- HostEnqueuePromiseJob, there will be no active script to pass
- along. As a consequence, this means that when the Queue a microtask on the surrounding agent's event loop to perform the following steps:HostPromiseRejectionTracker(promise, operation)
+
+
+
+
+
+
+ "reject"
,
+
+
+
+ "handle"
,
+
+
+
+ rejectionhandled
at global, using
+ PromiseRejectionEvent
, with the promise
attribute initialized to
+ promise, and the reason
+ attribute initialized to the value of promise's [[PromiseResult]] internal slot.Job-related host hooks
+
+ HostCallJobCallback(callback, V,
+ argumentsList)
+
+
+
+
- HostEnqueuePromiseJob(job,
- realm)
+ HostEnqueuePromiseJob(job,
+ realm)
-
- Promise.resolve('import(`./example.mjs`)').then(eval);
import()
expression is evaluated, since eval()
- is a built-in function that does not originate from any particular script.import()
to use the original script's base URL appropriately.
-
- <button onclick="Promise.resolve('import(`./example.mjs`)').then(eval)">Click me</button>
import()
expression is evaluated,
- there will still be no active script. Fortunately that is handled by our
- implementations of HostResolveImportedModule and
- HostImportModuleDynamically, by falling back to using the current settings
- object's API base URL.
Prepare to run a callback with incumbent settings.
- -This affects the incumbent - concept while the job runs.
-If script execution context is not null, then push script execution context onto the JavaScript execution - context stack.
- -As explained above, this affects the active script while the job - runs.
-Let result be job().
job is an abstract closure returned by - NewPromiseReactionJob or NewPromiseResolveThenableJob.
-If script execution context is not null, then pop script execution context from the JavaScript execution context - stack.
Clean up after running a callback with incumbent - settings.
then
function when job is returned by
+ NewPromiseResolveThenableJob, are wrapped in JobCallback Records. HTML saves the incumbent settings object and
+ a JavaScript execution context for to the active script in
+ HostMakeJobCallback and restores them in HostCallJobCallback.
+
If job settings is not null, then clean up after running script with job settings.
JavaScript contains an implementation-defined HostEnsureCanCompileStrings(callerRealm, - calleeRealm) abstract operation. User agents must use the following implementation: - + data-x="js-HostMakeJobCallback">HostMakeJobCallback(callable) abstract operation + to let hosts attach state to JavaScript callbacks that are called from inside tasks. HTML tracks the incumbent settings + object in promises by saving the incumbent settings object and a + JavaScript execution context for the active script. User agents must use + the following implementation:
- -Let incumbent settings be the incumbent settings object.
JavaScript contains an implementation-defined HostPromiseRejectionTracker(promise, - operation) abstract operation. User agents must use the following implementation: -
+Let active script be the active script.
Let script be the running script.
Let script execution context be null.
If script's muted errors is true, terminate these steps.
If active script is not null, set script execution context to a new + JavaScript execution context, with its Function field set to null, its Realm field + set to active script's settings object's Realm, and its ScriptOrModule set to active script's + record.
-Let settings object be script's settings object.
-As seen below, this is used in order to propagate the current active + script forward to the time when the job callback is invoked.
-If operation is "reject"
,
+
A case where active script is non-null, and saving it in this way is useful, is + the following:
-Add promise to settings object's about-to-be-notified - rejected promises list.
Promise.resolve('import(`./example.mjs`)').then(eval);
- If operation is "handle"
,
+
Without this step (and the steps that use it in HostCallJobCallback), there
+ would be no active script when the import()
expression is evaluated,
+ since eval()
is a built-in function that does not originate from any particular
+ script.
If settings object's about-to-be-notified rejected promises - list contains promise, then remove promise from that list and - return.
With this step in place, the active script is propagated from the above code into the job,
+ allowing import()
to use the original script's base URL appropriately.
If settings object's outstanding rejected promises weak set - does not contain promise, then return.
active script can be null if the user clicks on the following button:
-Remove promise from settings object's outstanding rejected - promises weak set.
<button onclick="Promise.resolve('import(`./example.mjs`)').then(eval)">Click me</button>
- Let global be settings object's global object.
In this case, the JavaScript function for the event + handler will be created by the get the current value of the event handler algorithm, which creates a function + with null [[ScriptOrModule]] value. Thus, when the promise machinery calls + HostMakeJobCallback, there will be no active script to pass + along.
-Queue a global task on the DOM manipulation task source given
- global to fire an event named rejectionhandled
at global, using
- PromiseRejectionEvent
, with the promise
attribute initialized to
- promise, and the reason
- attribute initialized to the value of promise's [[PromiseResult]] internal slot.
As a consequence, this means that when the import()
expression is evaluated,
+ there will still be no active script. Fortunately that is handled by our
+ implementations of HostResolveImportedModule and
+ HostImportModuleDynamically, by falling back to using the current settings
+ object's API base URL.
Return the JobCallback Record { [[Callback]]: callable, + [[HostDefined]]: { [[IncumbentSettings]]: incumbent settings, [[ActiveScriptContext]]: + script execution context } }.