Skip to content

Commit d154d09

Browse files
authored
[worklets] Create WorkletOptions dictionary to pass through credentials. (w3c#382)
This changes the import() method to optionally accept a credentials argument, e.g. CSS.paintWorklet.import('paint.js', {credentials: 'include'});
1 parent eed013c commit d154d09

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

worklets/Overview.bs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,11 @@ The {{Worklet}} object provides the capability to import module scripts into its
296296

297297
<pre class='idl'>
298298
interface Worklet {
299-
[NewObject] Promise&lt;void> import(USVString moduleURL);
299+
[NewObject] Promise&lt;void> import(USVString moduleURL, optional WorkletOptions options);
300+
};
301+
302+
dictionary WorkletOptions {
303+
RequestCredentials credentials = "omit";
300304
};
301305
</pre>
302306

@@ -331,8 +335,8 @@ A <dfn>pending tasks struct</dfn> is a <a>struct</a> consiting of:
331335
This is used by the algorithms below.
332336

333337
<div algorithm>
334-
When the <dfn method for=Worklet>import(|moduleURL|)</dfn> method is called on a {{Worklet}} object,
335-
the user agent <em>must</em> run the following steps:
338+
When the <dfn method for=Worklet>import(|moduleURL|, |options|)</dfn> method is called on a
339+
{{Worklet}} object, the user agent <em>must</em> run the following steps:
336340
1. Let |promise| be <a>a new promise</a>.
337341

338342
2. Let |worklet| be the current {{Worklet}}.
@@ -345,13 +349,15 @@ the user agent <em>must</em> run the following steps:
345349

346350
5. Return |promise|, and then continue running this algorithm <a>in parallel</a>.
347351

348-
6. Let |outsideSettings| be the <a>relevant settings object</a> of <b>this</b>.
352+
6. Let |credentialOptions| be the {{WorkletOptions/credentials}} member of |options|.
353+
354+
7. Let |outsideSettings| be the <a>relevant settings object</a> of <b>this</b>.
349355

350-
7. Let |moduleResponsesMap| be |worklet|'s <a>module responses map</a>.
356+
8. Let |moduleResponsesMap| be |worklet|'s <a>module responses map</a>.
351357

352-
8. Let |workletGlobalScopeType| be |worklet|'s <a>worklet global scope type</a>.
358+
9. Let |workletGlobalScopeType| be |worklet|'s <a>worklet global scope type</a>.
353359

354-
9. If the <a>worklet's WorkletGlobalScopes</a> is empty, run the following steps:
360+
10. If the <a>worklet's WorkletGlobalScopes</a> is empty, run the following steps:
355361

356362
1. <a>Create a WorkletGlobalScope</a> given |workletGlobalScopeType|, |moduleResponsesMap|,
357363
and |outsideSettings|.
@@ -362,31 +368,32 @@ the user agent <em>must</em> run the following steps:
362368

363369
Wait for this step to complete before continuing.
364370

365-
10. Let |pendingTaskStruct| be a new <a>pending tasks struct</a> with <a
371+
11. Let |pendingTaskStruct| be a new <a>pending tasks struct</a> with <a
366372
for="pending tasks struct">counter</a> initialized to the length of <a>worklet's
367373
WorkletGlobalScopes</a>.
368374

369-
11. For each |workletGlobalScope| in the <a>worklet's WorkletGlobalScopes</a>, <a>queue a
375+
12. For each |workletGlobalScope| in the <a>worklet's WorkletGlobalScopes</a>, <a>queue a
370376
task</a> on the |workletGlobalScope| to <a>fetch and invoke a worklet script</a> given
371-
|workletGlobalScope|, |moduleURLRecord|, |moduleResponsesMap|, |outsideSettings|,
372-
|pendingTaskStruct|, and |promise|.
377+
|workletGlobalScope|, |moduleURLRecord|, |moduleResponsesMap|, |credentialOptions|,
378+
|outsideSettings|, |pendingTaskStruct|, and |promise|.
373379

374380
Note: The rejecting and resolving of the |promise| occurs within the <a>fetch and invoke a
375381
worklet script</a> algorithm.
376382
</div>
377383

378384
<div algorithm>
379385
When the user agent is to <dfn>fetch and invoke a worklet script</dfn> given |workletGlobalScope|,
380-
|moduleURLRecord|, |moduleResponsesMap|, |outsideSettings|, |pendingTaskStruct|, and |promise|, the
381-
user agent <em>must</em> run the following steps:
386+
|moduleURLRecord|, |moduleResponsesMap|, |credentialOptions|, |outsideSettings|,
387+
|pendingTaskStruct|, and |promise|, the user agent <em>must</em> run the following steps:
382388

383389
Note: This algorithm is to be run within the <a>worklet global scope execution environment</a>.
384390

385391
1. Let |insideSettings| be the |workletGlobalScope|'s associated <a>environment settings
386392
object</a>.
387393

388394
2. Let |script| by the result of <a>fetch a worklet script</a> given |moduleURLRecord|,
389-
|moduleResponsesMap|, |outsideSettings|, and |insideSettings| when it asynchronously completes.
395+
|moduleResponsesMap|, |credentialOptions|, |outsideSettings|, and |insideSettings| when it
396+
asynchronously completes.
390397

391398
3. If |script| is <em>null</em>, then <a>queue a task</a> on |outsideSettings|'s <a>responsible
392399
event loop</a> to run these steps:
@@ -414,13 +421,13 @@ user agent <em>must</em> run the following steps:
414421

415422
<div algorithm>
416423
When the user agent is to <dfn>fetch a worklet script</dfn> given |moduleURLRecord|,
417-
|moduleResponsesMap|, |outsideSettings|, and |insideSettings|, the user agent <em>must</em>
418-
run the following steps:
424+
|moduleResponsesMap|, |credentialOptions|, |outsideSettings|, and |insideSettings|, the user agent
425+
<em>must</em> run the following steps:
419426

420427
Note: This algorithm is to be run within the <a>worklet global scope execution environment</a>.
421428

422429
1. <a>Fetch a module worker script graph</a> given |moduleURLRecord|, |outsideSettings|, "script",
423-
"omit", and |insideSettings|.
430+
|credentialOptions|, and |insideSettings|.
424431

425432
To <a>perform the request</a> given |request|, perform the following steps:
426433

0 commit comments

Comments
 (0)