Skip to content

Commit 5554fdf

Browse files
committed
Handle asynchronous modules (top-level await).
Fixes w3c#1407.
1 parent 5580c1d commit 5554fdf

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
@@ -2801,8 +2803,21 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
28012803
1. Set |workerGlobalScope|'s [=ServiceWorkerGlobalScope/force bypass cache for import scripts flag=] if |forceBypassCache| is true.
28022804
1. Create a new {{WorkerLocation}} object and associate it with |workerGlobalScope|.
28032805
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>.
2804-
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=].
2805-
1. If |evaluationStatus|.\[[Value]] is empty, this means the script was not evaluated. Set |startFailed| to true and abort these steps.
2806+
1. Let |evaluationStatus| be null.
2807+
1. If |script| is a <a>classic script</a>, then:
2808+
1. Set |evaluationStatus| to the result of <a lt="run a classic script">running the classic script</a> |script|.
2809+
1. If |evaluationStatus|.\[[Value]] is empty, this means the script was not evaluated. Set |startFailed| to true and abort these steps.
2810+
1. Otherwise, if |script| is a [=module script=], then:
2811+
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.
2812+
1. If |evaluationPromise|.\[[PromiseState]] is "fulfilled":
2813+
1. Set |evaluationStatus| to [$NormalCompletion$](|evaluationPromise|.\[[PromiseResult]]).
2814+
1. Otherwise, if |evaluationPromise|.\[[PromiseState]] is "rejected":
2815+
1. Set |startFailed| to true and abort these steps.
2816+
1. Otherwise:
2817+
1. Assert: |evaluationPromise|.\[[PromiseState]] is "pending".
2818+
1. Set |evaluationStatus| to [$NormalCompletion$](undefined).
2819+
1. [=Upon rejection=] of |evaluationPromise| with |reason|:
2820+
1. [=Report the exception=] given by |reason| for |script|.
28062821
1. If the script was aborted by the [=Terminate Service Worker=] algorithm, set |startFailed| to true and abort these steps.
28072822
1. Set |serviceWorker|'s [=start status=] to |evaluationStatus|.
28082823
1. If |script|'s <a>has ever been evaluated flag</a> is unset, then:

0 commit comments

Comments
 (0)