-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle module scripts that include top-level await. #984
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,7 +240,9 @@ When a user agent is to <dfn export>create a WorkletGlobalScope</dfn>, given |wo | |
|
||
6. Invoke the <a>initialize a global object's CSP list</a> 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 <dfn export>create a WorkletGlobalScope</dfn>, given |wo | |
|moduleResponsesMap|, |outsideSettings|, and |insideSettings| when | ||
it asynchronously completes. | ||
|
||
3. <a>Run a module script</a> given |script|. | ||
3. Let |promise| be the result of <a lt="run a module script">running a module script</a> | ||
given |script|. | ||
|
||
4. [=list/Append=] |promise| to |scripts|. | ||
|
||
Note: <a>Fetch a worklet script</a> won't actually perform a network request as it will hit | ||
the worklet's <a>module responses map</a>. 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 <a>responsible event loop</a> specified by |insideSettings|. | ||
9. [=Wait for all=] |scripts|, with success steps and failure steps both given by: | ||
|
||
1. Run the <a>responsible event loop</a> specified by |insideSettings|. | ||
</div> | ||
|
||
### Script settings for worklets ### {#script-settings-for-worklets} | ||
|
@@ -457,18 +464,21 @@ When the user agent is to <dfn>fetch and invoke a worklet script</dfn> given |wo | |
|
||
2. Reject |promise| with <a>error to rethrow</a>. | ||
|
||
5. <a>Run a module script</a> given |script|. | ||
5. Let |promise| be the result of <a lt="run a module script">running a module script</a> given | ||
|script|. | ||
|
||
6. <a>Queue a task</a> on |outsideSettings|'s <a>responsible event loop</a> to run these steps: | ||
6. [=promise/React=] to |promise|: | ||
* If |promise| was fulfilled or rejected, then: | ||
1. <a>Queue a task</a> on |outsideSettings|'s <a>responsible event loop</a> to run these steps: | ||
|
||
1. If |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> is not <b>-1</b>, then | ||
run these steps: | ||
1. If |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> is not <b>-1</b>, then | ||
run these steps: | ||
|
||
1. Decrement |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> by | ||
<b>1</b>. | ||
1. Decrement |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> by | ||
<b>1</b>. | ||
|
||
2. If |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> is <b>0</b>, then | ||
resolve |promise|. | ||
2. If |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> is <b>0</b>, then | ||
resolve |promise|. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like you shadowed an existing |promise| variable. |
||
</div> | ||
|
||
<div algorithm> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this isn't right. Without an inner event loop, the microtask queue (and thus any awaits) cannot run.
I see two possible semantics here:
I think the first of these is probably more correct, since (IIRC) it aligns with what happens if you have multiple TLA-using
<script type=module>
s.