You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -121,9 +110,9 @@ on a class should produce the same output given a particular input.
121
110
The following techniques should be used in order to encourage authors to write code in an idempotent
122
111
way:
123
112
- No reference to the global object, e.g. <a>self</a> on a {{DedicatedWorkerGlobalScope}}.
124
-
- Code is loaded similar to how ES6 Modules are loaded, in <a>strict mode code</a> inside an
125
-
anonymous function. This prevents two different scripts sharing state by referencing shared
126
-
objects on the global scope.
113
+
- Code is loaded as a <a>module script</a> which resulting in the code being executed in <a>strict
114
+
mode code</a> without a shared this. This prevents two different module scripts sharing
115
+
state be referencing shared objects on the global scope.
127
116
- User agents may choose to always have at least two {{WorkletGlobalScope}}s per {{Worklet}} and
128
117
randomly assign a method or set of methods on a class to a particular global scope.
129
118
- User agents may create and destroy {{WorkletGlobalScope}}s at any time.
@@ -179,8 +168,15 @@ and |worklet|, it <em>must</em> run the following steps:
179
168
180
169
2. Associate the |settingsObject| with |workletGlobalScope|.
181
170
182
-
3. For each |script| in the given |worklet|'s <b>worklet's loaded scripts</b> run the |script|
183
-
in the |workletGlobalScope|.
171
+
3. For each |resolvedModuleURL| in the given |worklet|'s <b>worklet's resolved module URLs</b>,
172
+
run the following substeps:
173
+
1. Let |script| be the result of <a>fetch a module script tree</a> given
174
+
|resolvedModuleURL|, "anonymous" for the <a>CORS setting attribute</a>, and
175
+
|settingsObject|.
176
+
177
+
Issue: Decide if "use-credientials" should be valid for worklets.
178
+
179
+
2. <a>Run a module script</a> given |script|.
184
180
185
181
### Script settings for worklets ### {#script-settings-for-worklets}
186
182
@@ -238,60 +234,56 @@ Issue: Merge this with https://html.spec.whatwg.org/multipage/workers.html#set-u
238
234
Worklet {#worklet-section}
239
235
--------------------------
240
236
241
-
The {{Worklet}} object provides the capability to import scripts into its associated {{WorkletGlobalScope}}s. The user agent can then create classes registered
242
-
on the {{WorkletGlobalScope}}s and invoke their methods.
237
+
The {{Worklet}} object provides the capability to import module scripts into its associated
238
+
{{WorkletGlobalScope}}s. The user agent can then create classes registered on the
A {{Worklet}} has a list of the <b>worklet's {{WorkletGlobalScope}}s</b>. Initially this list is empty; it is populated when the user agent chooses to create its {{WorkletGlobalScope}}.
247
+
A {{Worklet}} has a list of the <b>worklet's WorkletGlobalScopes</b>. Initially this list is empty;
248
+
it is populated when the user agent chooses to create its {{WorkletGlobalScope}}.
251
249
252
-
A {{Worklet}} has a list of the <b>worklet's loaded scripts</b>. Initially this list is empty; it is populated when scripts are fetched and parsed.
250
+
A {{Worklet}} has a list of the <b>worklet's resolved module URLs</b>. Initially this list is empty; it is
251
+
populated when module scripts resolved.
253
252
254
-
When the <dfn method for=Worklet>importScripts(urls)</dfn> method is called on a {{Worklet}} object, the user agent <em>must</em> run the following steps:
253
+
When the <dfn method for=Worklet>import(moduleURL)</dfn> method is called on a {{Worklet}} object,
254
+
the user agent <em>must</em> run the following steps:
255
255
1. Let |promise| be <a>a new promise</a>.
256
+
256
257
2. Run the following steps <a>in parallel</a>:
257
-
1. Let |settingsObject| be the <a>incumbent settings object</a>.
258
-
2. If there are no arguments, return without doing anything. Abort these steps.
259
-
3. <a>Resolve</a> each argument relative to settings object's <a>API base URL</a>.
260
-
4. If any fail, throw a SyntaxError</a> exception and abort these steps.
261
-
5. For each URL in the resulting absolute URLs, run these substeps:
262
-
1. Let response be the result of <a>get a fetch result</a>, given |url| and |settingsObject|.
263
-
2. Let |source| be the result of running the <a>UTF-8 decode</a> algorithm on response's <a>unsafe response</a>'s <a>body</a>.
264
-
3. Let |script| be the result of running <a>create an isolated script</a> using |source| as the script source, the <a>URL</a> from which source was obtained, and |settingsObject| as the environment settings object.
265
-
266
-
Parse the newly created |script|. If it failed to parse, then reject the |promise| and abort all these steps.
267
-
268
-
4. Add |script| to the list of the <b>worklet's loaded scripts</b>.
269
-
6. For each {{WorkletGlobalScope}} in the <b>worklet's {{WorkletGlobalScope}}s</b>, run these substeps.
270
-
1. For each newly created |script| in <b>worklet's loaded scripts</b> run the script in the {{WorkletGlobalScope}}.
271
-
7. If <em>all</em> the steps above succeeded (in particular, if all of the scripts parsed and loaded into the global scopes), resolve |promise|
272
-
<br>Otherwise, reject |promise|.
273
-
3. Return |promise|.
258
+
1. If there are no arguments, return without doing anything. Abort these steps.
274
259
275
-
Issue(w3c/css-houdini-drafts#51): What should happen when a script throws an exception while executing for the first time?
260
+
2. Let |resolvedModuleURL| be the result of <a>resolving</a> the |moduleURL| relative to the
261
+
<a>API base URL</a> specified by the <a>entry settings object</a> when the method was
262
+
invoked.
263
+
264
+
3. If this fails, reject |promise| with a <a>SyntaxError</a> exception and abort these steps.
276
265
277
-
Issue(w3c/css-houdini-drafts#52): Is importScripts the right API call? Should it be singular instead?
266
+
4. Add |resolvedModuleURL| to the list of <b>worklet's resolved module URLs</b>.
278
267
279
-
When a user agent is to <dfn>create an isolated script</dfn> given some |scriptSource|, an <a>environment settings object</a>,
280
-
it must run the following steps:
281
-
1. Let |script| be a new script that this algorithm will subsequently initialise.
282
-
2. Obtain the appropriate <a>script execution environment</a> for the given scripting language from the <a>environment settings object</a> provided.
283
-
3. Let |kind| be Normal.
268
+
5. For each {{WorkletGlobalScope}} in the <b>worklet's WorkletGlobalScopes</b>, run these
269
+
substeps:
270
+
1. Let |settings| be the {{WorkletGlobalScope}}'s associated
271
+
<a>environment settings object</a>.
284
272
285
-
Let |parameterList| be an empty list.
273
+
2. Let |script| be the result of <a>fetch a module script tree</a> given
274
+
|resolvedModuleURL|, "anonymous" for the <a>CORS setting attribute</a>, and |settings|.
286
275
287
-
Let |parsedBodySource| be the result of parsing |scriptSource| as a <a>FunctionBody</a> using the <a>script execution environment</a>.
276
+
Issue: Decide if "use-credientials" should be valid for worklets.
288
277
289
-
Let |strict| be true.
278
+
3. <a>Run a module script</a> given |script|.
290
279
291
-
Let |scope| be the result of <a>NewObjectEnvironment</a>(O=<em>null</em>, E=<em>the global environment</em>).
292
-
4. Let |function| be the result of <a>FunctionCreate</a>(kind=|kind|, ParameterList=|parameterList|, Body=|parsedBodySource|, Scope=|scope|, Strict=|strict|).
293
-
5. Let |script|'s <a>code entry-point</a> be |function|.
294
-
6. Return |script|.
280
+
6. If <em>all</em> the steps above succeeded (in particular, if all of the scripts parsed and
281
+
loaded into the global scopes), resolve |promise|
282
+
<br>Otherwise, reject |promise|.
283
+
284
+
3. Return |promise|.
285
+
286
+
Issue(w3c/css-houdini-drafts#51): What should happen when a script throws an exception while executing for the first time?
295
287
296
288
Issue(w3c/css-houdini-drafts#47): Need ability to load code into {{WorkletGlobalScope}} declaratively.
297
289
@@ -302,16 +294,20 @@ Lifetime of the Worklet {#lifetime-of-the-worklet}
302
294
303
295
The lifetime of a {{Worklet}} is tied to the object it belongs to, for example the {{Window}}.
304
296
305
-
The lifetime of a {{WorkletGlobalScope}} is tied to the execution lifetime of a method or set of methods on a class, not to the lifetime of the {{Worklet}} object.
297
+
The lifetime of a {{WorkletGlobalScope}} is tied to the execution lifetime of a method or set of
298
+
methods on a class, not to the lifetime of the {{Worklet}} object.
306
299
307
-
The user agent <em>may</em> terminate a {{WorkletGlobalScope}} at any time it has no callbacks to handle or detects abnormal operation such as infinite loops and
308
-
callbacks exceeding imposed time limits.
300
+
The user agent <em>may</em> terminate a {{WorkletGlobalScope}} at any time it has no callbacks to
301
+
handle or detects abnormal operation such as infinite loops and callbacks exceeding imposed time
302
+
limits.
309
303
310
304
Issue(w3c/css-houdini-drafts#53): Worth adding dispose to classes to allow clean-up?
311
305
312
306
Processing Model {#processing-model}
313
307
------------------------------------
314
308
309
+
Issue: Split this up.
310
+
315
311
The <a>invoke a method on a class inside a Worklet</a> has two hooks for algorithm steps that may be customized by any callers:
316
312
- <dfn export>lookup a class instance on a worklet global scope</dfn>
317
313
@@ -381,21 +377,21 @@ Loading scripts into a worklet. {#example-single}
0 commit comments