Skip to content

Commit ecb9304

Browse files
committed
Handle asynchronous modules (top-level await).
Fixes w3c#1407.
1 parent ffdd6c0 commit ecb9304

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

docs/index.bs

+17-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ spec: push; urlPrefix: https://w3c.github.io/push-api/
4848
text: push; url: h-the-push-event
4949

5050
spec: ecma-262; urlPrefix: http://tc39.github.io/ecma262/
51+
type: abstract-op
52+
text: NormalCompletion; url: sec-normalcompletion
5153
type: dfn
5254
text: Assert; url: sec-algorithm-conventions
5355
text: [[Call]]; url: sec-ecmascript-function-objects-call-thisargument-argumentslist
@@ -2873,8 +2875,21 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
28732875
1. Set |workerGlobalScope|'s [=ServiceWorkerGlobalScope/force bypass cache for import scripts flag=] if |forceBypassCache| is true.
28742876
1. Create a new {{WorkerLocation}} object and associate it with |workerGlobalScope|.
28752877
1. If |serviceWorker| is an <a>active worker</a>, and there are any <a>tasks</a> queued in |serviceWorker|'s <a>containing service worker registration</a>'s [=service worker registration/task queues=], <a lt="queue a task">queue</a> them to |serviceWorker|'s <a>event loop</a>'s [=/task queues=] in the same order using their original <a>task sources</a>.
2876-
1. Let |evaluationStatus| be the result of <a lt="run a classic script">running the classic script</a> |script| if |script| is a <a>classic script</a>, otherwise, the result of <a lt="run a module script">running the module script</a> |script| if |script| is a [=module script=].
2877-
1. If |evaluationStatus|.\[[Value]] is empty, this means the script was not evaluated. Set |startFailed| to true and abort these steps.
2878+
1. Let |evaluationStatus| be null.
2879+
1. If |script| is a <a>classic script</a>, then:
2880+
1. Set |evaluationStatus| to the result of <a lt="run a classic script">running the classic script</a> |script|.
2881+
1. If |evaluationStatus|.\[[Value]] is empty, this means the script was not evaluated. Set |startFailed| to true and abort these steps.
2882+
1. Otherwise, if |script| is a [=module script=], then:
2883+
1. Let |evaluationPromise| be the result of <a lt="run a module script">running the module script</a> |script|, with report errors set to false.
2884+
1. If |evaluationPromise|.\[[PromiseState]] is "fulfilled":
2885+
1. Set |evaluationStatus| to [$NormalCompletion$](|evaluationPromise|.\[[PromiseResult]]).
2886+
1. Otherwise, if |evaluationPromise|.\[[PromiseState]] is "rejected":
2887+
1. Set |startFailed| to true and abort these steps.
2888+
1. Otherwise:
2889+
1. Assert: |evaluationPromise|.\[[PromiseState]] is "pending".
2890+
1. Set |evaluationStatus| to [$NormalCompletion$](undefined).
2891+
1. [=Upon rejection=] of |evaluationPromise| with |reason|:
2892+
1. [=Report the exception=] given by |reason| for |script|.
28782893
1. If the script was aborted by the [=Terminate Service Worker=] algorithm, set |startFailed| to true and abort these steps.
28792894
1. Set |serviceWorker|'s [=start status=] to |evaluationStatus|.
28802895
1. If |script|'s <a>has ever been evaluated flag</a> is unset, then:

0 commit comments

Comments
 (0)