Skip to content

Commit c2326d4

Browse files
committed
[worklets] Fix module loading when creating a new worklet global scope.
1 parent ef2cc61 commit c2326d4

File tree

1 file changed

+43
-33
lines changed

1 file changed

+43
-33
lines changed

worklets/Overview.bs

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,13 @@ When a user agent is to <dfn>create a WorkletGlobalScope</dfn>, for a given |wor
185185

186186
1. Let |resolvedModuleURL| be |entry|'s key.
187187

188-
2. Let |script| be the result of <a>fetch a module script tree</a> given
189-
|resolvedModuleURL|, "anonymous" for the <a>CORS setting attribute</a>, and
190-
|settingsObject|.
188+
2. <a>Fetch a module worklet script tree</a> given |resolvedModuleURL|, |outsideSettings|,
189+
and |settingsObject|.
191190

192-
Note: Worklets follow <a>web workers</a> here in not allowing "use-credientials" for
193-
fetching resources.
191+
3. Let |script| be the result of <a>fetch a module worklet script tree</a> when it
192+
asynchronously completes.
194193

195-
3. <a>Run a module script</a> given |script|.
194+
4. <a>Run a module script</a> given |script|.
196195

197196
### Script settings for worklets ### {#script-settings-for-worklets}
198197

@@ -247,6 +246,41 @@ When a user agent is to <dfn>set up a worklet environment settings object</dfn>,
247246

248247
Issue: Merge this with https://html.spec.whatwg.org/multipage/workers.html#set-up-a-worker-environment-settings-object
249248

249+
### Fetching a module worklet script tree ### {#fetching-a-module-worklet-script-tree}
250+
251+
When a user agent is to <dfn>fetch a module worklet script tree</dfn>, given |resolvedModuleURL|,
252+
|outsideSettings|, and |insideSettings| it must run the following steps:
253+
254+
1. <a>Fetch a module script tree</a> given |resolvedModuleURL|, |outsideSettings|, "script" the
255+
empty string (as no cryptographic nonce is present for worklets), "not parser-inserted", "omit",
256+
and |insideSettings|.
257+
258+
To <a>perform the fetch</a> given |request|, perform the following steps:
259+
260+
1. Let |cache| be the current {{Worklet}}'s <a>module responses map</a>.
261+
262+
2. Let |url| be |request|'s <a >url</a>.
263+
264+
3. If |cache| contains an entry with key |url| whose value is "fetching", wait
265+
(<a>in parallel</a>) until that entry's value changes, then proceed to the
266+
next step.
267+
268+
4. If |cache| contains an entry with key |url|, asynchronously complete this
269+
algorithm with that entry's value, and abort these steps.
270+
271+
5. Create an entry in |cache| with key |url| and value "fetching".
272+
273+
6. <a>Fetch</a> |request|.
274+
275+
7. Let |response| be the result of <a>fetch</a> when it asynchronously
276+
completes.
277+
278+
8. Set the value of the entry in |cache| whose key is |url| to |response|, and
279+
asynchronously complete this algorithm with |response|.
280+
281+
2. Asynchronously complete this algorithm with the result of <a>fetch a module script tree</a>
282+
when it completes.
283+
250284
Worklet {#worklet-section}
251285
--------------------------
252286

@@ -302,34 +336,10 @@ the user agent <em>must</em> run the following steps:
302336
1. Let |insideSettings| be the {{WorkletGlobalScope}}'s associated <a>environment
303337
settings object</a>.
304338

305-
2. <a>Fetch a module script tree</a> given |resolvedModuleURL|, "omit", the empty string
306-
(as no cryptographic nonce is present for worklets), "not parser-inserted",
307-
"script", |outsideSettings|, and |insideSettings|.
308-
309-
To <a>perform the request</a> given |request|, perform the following steps:
310-
311-
1. Let |cache| be the current {{Worklet}}'s <a>module responses map</a>.
312-
313-
2. Let |url| be |request|'s <a >url</a>.
314-
315-
3. If |cache| contains an entry with key |url| whose value is "fetching", wait
316-
(<a>in parallel</a>) until that entry's value changes, then proceed to the
317-
next step.
318-
319-
4. If |cache| contains an entry with key |url|, asynchronously complete this
320-
algorithm with that entry's value, and abort these steps.
321-
322-
5. Create an entry in |cache| with key |url| and value "fetching".
323-
324-
6. <a>Fetch</a> |request|.
325-
326-
7. Let |response| be the result of <a>fetch</a> when it asynchronously
327-
completes.
328-
329-
8. Set the value of the entry in |cache| whose key is |url| to |response|, and
330-
asynchronously complete this algorithm with |response|.
339+
2. <a>Fetch a module worklet script tree</a> given |resolvedModuleURL|,
340+
|outsideSettings|, and |settingsObject|.
331341

332-
3. Let |script| be the result of <a>fetch a module script tree</a> when it
342+
3. Let |script| be the result of <a>fetch a module worklet script tree</a> when it
333343
asynchronously completes.
334344

335345
4. <a>Run a module script</a> given |script|.

0 commit comments

Comments
 (0)