diff --git a/worklets/Overview.bs b/worklets/Overview.bs index ea7de25f..5e3482d9 100644 --- a/worklets/Overview.bs +++ b/worklets/Overview.bs @@ -240,7 +240,9 @@ When a user agent is to create a WorkletGlobalScope, given |wo 6. Invoke the initialize a global object's CSP list algorithm given |workletGlobalScope|. - 7. For each |entry| in the given |moduleResponsesMap| (in insertion order), run the following + 7. Let |scripts| be «». + + 8. For each |entry| in the given |moduleResponsesMap| (in insertion order), run the following substeps: 1. Let |moduleURLRecord| be |entry|'s key. @@ -249,14 +251,19 @@ When a user agent is to create a WorkletGlobalScope, given |wo |moduleResponsesMap|, |outsideSettings|, and |insideSettings| when it asynchronously completes. - 3. Run a module script given |script|. + 3. Let |promise| be the result of running a module script + given |script|. + + 4. [=list/Append=] |promise| to |scripts|. Note: Fetch a worklet script won't actually perform a network request as it will hit the worklet's module responses map. It also won't have a parsing error as at this point it should have successfully been parsed by another worklet global scope. I.e. |script| should never be null here. - 6. Run the responsible event loop specified by |insideSettings|. + 9. [=Wait for all=] |scripts|, with success steps and failure steps both given by: + + 1. Run the responsible event loop specified by |insideSettings|. ### Script settings for worklets ### {#script-settings-for-worklets} @@ -457,18 +464,21 @@ When the user agent is to fetch and invoke a worklet script given |wo 2. Reject |promise| with error to rethrow. - 5. Run a module script given |script|. + 5. Let |promise| be the result of running a module script given + |script|. - 6. Queue a task on |outsideSettings|'s responsible event loop to run these steps: + 6. [=promise/React=] to |promise|: + * If |promise| was fulfilled or rejected, then: + 1. Queue a task on |outsideSettings|'s responsible event loop to run these steps: - 1. If |pendingTaskStruct|'s counter is not -1, then - run these steps: + 1. If |pendingTaskStruct|'s counter is not -1, then + run these steps: - 1. Decrement |pendingTaskStruct|'s counter by - 1. + 1. Decrement |pendingTaskStruct|'s counter by + 1. - 2. If |pendingTaskStruct|'s counter is 0, then - resolve |promise|. + 2. If |pendingTaskStruct|'s counter is 0, then + resolve |promise|.