@@ -2775,6 +2775,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
2775
2775
2776
2776
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-arraycreate">ArrayCreate</dfn> abstract operation</li>
2777
2777
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-call">Call</dfn> abstract operation</li>
2778
+ <li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-clear-kept-objects">ClearKeptObjects</dfn> abstract operation</li>
2779
+ <li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-cleanup-finalization-registry">CleanupFinalizationRegistry</dfn> abstract operation</li>
2778
2780
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-construct">Construct</dfn> abstract operation</li>
2779
2781
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-copydatablockbytes">CopyDataBlockBytes</dfn> abstract operation</li>
2780
2782
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-createbytedatablock">CreateByteDataBlock</dfn> abstract operation</li>
@@ -2788,6 +2790,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
2788
2790
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-getfunctionrealm">GetFunctionRealm</dfn> abstract operation</li>
2789
2791
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-hasownproperty">HasOwnProperty</dfn> abstract operation</li>
2790
2792
<li>The <dfn data-x="js-HostCallJobCallback" data-x-href="https://tc39.es/ecma262/#sec-hostcalljobcallback">HostCallJobCallback</dfn> abstract operation</li>
2793
+ <li>The <dfn data-x="js-HostEnqueueFinalizationRegistryCleanupJob" data-x-href="https://tc39.es/ecma262/#sec-host-cleanup-finalization-registry">HostEnqueueFinalizationRegistryCleanupJob</dfn> abstract operation</li>
2791
2794
<li>The <dfn data-x="js-HostEnqueuePromiseJob" data-x-href="https://tc39.es/ecma262/#sec-hostenqueuepromisejob">HostEnqueuePromiseJob</dfn> abstract operation</li>
2792
2795
<li>The <dfn data-x="js-HostEnsureCanCompileStrings" data-x-href="https://tc39.es/ecma262/#sec-hostensurecancompilestrings">HostEnsureCanCompileStrings</dfn> abstract operation</li>
2793
2796
<li>The <dfn data-x="js-HostImportModuleDynamically" data-x-href="https://tc39.es/proposal-dynamic-import/#sec-hostimportmoduledynamically">HostImportModuleDynamically</dfn> abstract operation</li>
@@ -2834,11 +2837,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
2834
2837
<li>The <dfn data-x="js-strict-equality" data-x-href="https://tc39.es/ecma262/#sec-strict-equality-comparison">Strict Equality Comparison</dfn> algorithm</li>
2835
2838
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-atomics-object"><code>Atomics</code></dfn> object</li>
2836
2839
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-date-objects"><code>Date</code></dfn> class</li>
2840
+ <li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-finalization-registry-objects"><code>FinalizationRegistry</code></dfn> class</li>
2837
2841
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-regexp-regular-expression-objects"><code>RegExp</code></dfn> class</li>
2838
2842
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-sharedarraybuffer-objects"><code>SharedArrayBuffer</code></dfn> class</li>
2839
2843
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror"><code>TypeError</code></dfn> class</li>
2840
2844
<li>The <dfn data-x="js-RangeError" data-x-href="https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror"><code>RangeError</code></dfn> class</li>
2845
+ <li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-weak-ref-objects"><code>WeakRef</code></dfn> class</li>
2841
2846
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-eval-x"><code>eval()</code></dfn> function</li>
2847
+ <li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-weak-ref.prototype.deref"><code>WeakRef.prototype.deref()</code></dfn> function</li>
2842
2848
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot">[[IsHTMLDDA]]</dfn> internal slot</li>
2843
2849
<li><dfn data-x-href="https://tc39.es/ecma262/#sec-import-calls"><code>import()</code></dfn></li>
2844
2850
<li><dfn data-x-href="https://tc39.es/ecma262/#sec-meta-properties"><code>import.meta</code></dfn></li>
@@ -90002,16 +90008,20 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
90002
90008
<span data-x="JobCallback Record">JobCallback Records</span> which encapsulate JavaScript
90003
90009
functions that are called as part of jobs. The JavaScript specification contains a number of
90004
90010
<span>implementation-defined</span> abstract operations that lets the host define how jobs are
90005
- scheduled and how JobCallbacks are handled. This section defines them for user agent hosts.</p>
90011
+ scheduled and how JobCallbacks are handled. HTML uses these abstract operations to <span
90012
+ id="incumbent-settings-object-tracking-in-promises">track the <span>incumbent settings
90013
+ object</span> in promises and <code>FinalizationRegistry</code> callbacks</span> by saving and
90014
+ restoring the <span>incumbent settings object</span> and a <span>JavaScript execution
90015
+ context</span> for the <span>active script</span> in JobCallbacks. This section defines them for
90016
+ user agent hosts.</p>
90006
90017
90007
90018
<h6 id="hostcalljobcallback"><dfn>HostCallJobCallback</dfn>(<var>callback</var>, <var>V</var>,
90008
90019
<var>argumentsList</var>)</h6>
90009
90020
90010
90021
<p>JavaScript contains an <span>implementation-defined</span> <span
90011
90022
data-x="js-HostCallJobCallback">HostCallJobCallback</span>(<var>callback</var>, <var>V</var>,
90012
90023
<var>argumentsList</var>) abstract operation to let hosts restore state when invoking JavaScript
90013
- callbacks from inside tasks. HTML restores the <span>incumbent settings object</span> and the
90014
- <span>active script</span>. User agents must use the following implementation: <ref
90024
+ callbacks from inside tasks. User agents must use the following implementation: <ref
90015
90025
spec=JAVASCRIPT></p>
90016
90026
90017
90027
<ol>
@@ -90049,6 +90059,62 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
90049
90059
<li><p>Return <var>result</var>.</p></li>
90050
90060
</ol>
90051
90061
90062
+ <h6
90063
+ id="hostenqueuefinalizationregistrycleanupjob"><dfn>HostEnqueueFinalizationRegistryCleanupJob</dfn>(<var>finalizationRegistry</var>)</h6>
90064
+
90065
+ <p>JavaScript has the ability to register objects with <code>FinalizationRegistry</code> objects,
90066
+ in order to schedule a cleanup action if they are found to be garbage collected. The JavaScript
90067
+ specification contains an <span>implementation-defined</span> <span
90068
+ data-x="js-HostEnqueueFinalizationRegistryCleanupJob">HostEnqueueFinalizationRegistryCleanupJob</span>(<var>finalizationRegistry</var>)
90069
+ abstract operation to schedule the cleanup action.</p>
90070
+
90071
+ <p class="note">The timing and occurrence of cleanup work is <span>implementation-defined</span>
90072
+ in the JavaScript specification. User agents might differ in when and whether an object is garbage
90073
+ collected, affecting both whether the return value of the <code>WeakRef.prototype.deref()</code>
90074
+ method is undefined, and whether <code>FinalizationRegistry</code> cleanup callbacks occur. There
90075
+ are well-known cases in popular web browsers where objects are not accessible to JavaScript, but
90076
+ they remain retained by the garbage collector indefinitely. HTML clears kept-alive
90077
+ <code>WeakRef</code> objects in the <span>perform a microtask checkpoint</span> algorithm. Authors
90078
+ would be best off not depending on the timing details of garbage collection implementations.</p>
90079
+
90080
+ <p>Cleanup actions do not take place interspersed with synchronous JavaScript execution, but
90081
+ rather happen in queued <span data-x="concept-task">tasks</span>. User agents must use the
90082
+ following implementation: <ref spec=JAVASCRIPT></p>
90083
+
90084
+ <ol>
90085
+ <li><p>Let <var>global</var> be <var>finalizationRegistry</var>.[[Realm]]'s <span>global
90086
+ object</span>.</p></li>
90087
+
90088
+ <li>
90089
+ <p><span>Queue a global task</span> on the <dfn>JavaScript engine task source</dfn> given
90090
+ <var>global</var> to perform the following steps:</p>
90091
+
90092
+ <ol>
90093
+ <li><p>Let <var>entry</var> be
90094
+ <var>finalizationRegistry</var>.[[CleanupCallback]].[[Callback]].[[Realm]]'s <span
90095
+ data-x="concept-realm-settings-object">environment settings object</span>.</p></li>
90096
+
90097
+ <li><p><span>Check if we can run script</span> with <var>entry</var>. If this returns "do not
90098
+ run", then return.</p></li>
90099
+
90100
+ <li>
90101
+ <p><span>Prepare to run script</span> with <var>entry</var>.</p>
90102
+
90103
+ <p class="note">This affects the <span data-x="concept-entry-everything">entry</span> concept
90104
+ while the cleanup callback runs.</p>
90105
+ </li>
90106
+
90107
+ <li><p>Let <var>result</var> be the result of performing
90108
+ <span>CleanupFinalizationRegistry</span>(<var>finalizationRegistry</var>).</p></li>
90109
+
90110
+ <li><p><span>Clean up after running script</span> with <var>entry</var>.</p></li>
90111
+
90112
+ <li><p>If <var>result</var> is an <span>abrupt completion</span>, then <span>report the
90113
+ exception</span> given by <var>result</var>.[[Value]].</p></li>
90114
+ </ol>
90115
+ </li>
90116
+ </ol>
90117
+
90052
90118
<span id="integration-with-the-javascript-job-queue"></span>
90053
90119
<span id="enqueuejob(queuename,-job,-arguments)"></span>
90054
90120
<h6 id="hostenqueuepromisejob"><dfn>HostEnqueuePromiseJob</dfn>(<var>job</var>,
@@ -90123,11 +90189,8 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
90123
90189
<p>JavaScript contains an <span>implementation-defined</span> <span
90124
90190
data-x="js-HostMakeJobCallback">HostMakeJobCallback</span>(<var>callable</var>) abstract operation
90125
90191
to let hosts attach state to JavaScript callbacks that are called from inside <span
90126
- data-x="concept-task">task</span>s. HTML <span
90127
- id="incumbent-settings-object-tracking-in-promises">tracks the <span>incumbent settings
90128
- object</span> in promises</span> by saving the <span>incumbent settings object</span> and a
90129
- <span>JavaScript execution context</span> for the <span>active script</span>. User agents must use
90130
- the following implementation: <ref spec=JAVASCRIPT></p>
90192
+ data-x="concept-task">task</span>s. User agents must use the following implementation: <ref
90193
+ spec=JAVASCRIPT></p>
90131
90194
90132
90195
<ol>
90133
90196
<li><p>Let <var>incumbent settings</var> be the <span>incumbent settings object</span>.</p></li>
@@ -90187,6 +90250,7 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
90187
90250
<var>script execution context</var> } }.</p></li>
90188
90251
</ol>
90189
90252
90253
+
90190
90254
<h5 id="integration-with-the-javascript-module-system">Module-related host hooks</h5>
90191
90255
90192
90256
<p>The JavaScript specification defines a syntax for modules, as well as some host-agnostic parts
@@ -91067,6 +91131,14 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
91067
91131
91068
91132
<li><p><span>Cleanup Indexed Database transactions</span>.</p></li>
91069
91133
91134
+ <li>
91135
+ <p>Perform <span>ClearKeptObjects</span>().</p>
91136
+
91137
+ <p class="note">When <code>WeakRef.prototype.deref()</code> returns an object, that object is
91138
+ kept alive until the next invocation of <span>ClearKeptObjects</span>(), after which it is again
91139
+ subject to garbage collection.</p>
91140
+ </li>
91141
+
91070
91142
<li><p>Set the <span>event loop</span>'s <span>performing a microtask checkpoint</span> to
91071
91143
false.</p></li>
91072
91144
</ol>
0 commit comments