From 50f3a5421c8c1d728b86151c956d40dc4da829c9 Mon Sep 17 00:00:00 2001 From: Matt Falkenhagen Date: Fri, 7 Jun 2019 14:53:16 +0900 Subject: [PATCH] fixes --- docs/index.bs | 58 +++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/docs/index.bs b/docs/index.bs index 4d77ecc2..a2e7cd39 100644 --- a/docs/index.bs +++ b/docs/index.bs @@ -175,7 +175,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe A [=/service worker=] has an associated set of extended events (a [=ordered set|set=]) whose [=list/item=] is an {{ExtendableEvent}}. It is initially a new [=ordered set|set=]. - A [=/service worker=] is said to be running if its [=event loop=] is running and its [=service worker/global object=]'s [=WorkerGlobalScope/closing=] flag is false. + A [=/service worker=] has an associated start status which can be null or a [=Completion=]. It is initially null. + + A [=/service worker=] is said to be running if its [=event loop=] is running.

Lifetime

@@ -390,7 +392,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe The postMessage(|message|, |options|) method *must* run these steps: - 1. If the {{ServiceWorker/state}} attribute value of the context object is {{"redundant"}}, [=throw=] an "{{InvalidStateError}}" {{DOMException}}. 1. Let |serviceWorker| be the [=/service worker=] represented by the context object. 1. If the result of running the [=Should Skip Event=] algorithm with "message" and |serviceWorker|, is true, then return. 1. Let |incumbentSettings| be the [=incumbent settings object=]. @@ -2585,8 +2586,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Append |url| to |worker|'s [=set of used scripts=]. 1. Set |worker|'s script resource's HTTPS state to |httpsState|. 1. Set |worker|'s script resource's [=script resource/referrer policy=] to |referrerPolicy|. - 1. Set |evaluationStatus| to the result of running the [=Run Service Worker=] algorithm with |worker| and the *force bypass cache for importscripts flag* set if |job|'s [=job/force bypass cache flag=] is set. - 1. If |evaluationStatus| is an [=abrupt completion=] or |evaluationStatus|.\[[Value]] is empty, then: + 1. Run the [=Run Service Worker=] algorithm with |worker| and the *force bypass cache for importscripts flag* set if |job|'s [=job/force bypass cache flag=] is set. + 1. If |worker| is not [=running=] or its [=start status=] is an [=abrupt completion=], then: 1. Invoke [=Reject Job Promise=] with |job| and `TypeError`. 1. If |newestWorker| is null, invoke [=Clear Registration=] algorithm passing |registration| as its argument. 1. Invoke [=Finish Job=] with |job|. @@ -2649,7 +2650,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Wait until |e| is not [=ExtendableEvent/active=]. 1. If |e|'s [=ExtendableEvent/timed out flag=] is set, or the result of [=waiting for all=] of |e|'s [=extend lifetime promises=] rejected, set |installFailed| to true. - If |task| is discarded or the script has been aborted by the termination of |installingWorker|, set |installFailed| to true. + If |task| is discarded, set |installFailed| to true. 1. Wait for |task| to have executed or been discarded. 1. Wait for the step labeled *WaitForAsynchronousExtensions* to complete. @@ -2715,7 +2716,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Initialize |e|’s {{Event/type}} attribute to {{activate!!event}}. 1. Dispatch |e| at |activeWorker|'s [=service worker/global object=]. 1. *WaitForAsynchronousExtensions*: Wait, [=in parallel=], until |e| is not [=ExtendableEvent/active=]. - 1. Wait for |task| to have executed or been discarded, or the script to have been aborted by the termination of |activeWorker|. + 1. Wait for |task| to have executed or been discarded. 1. Wait for the step labeled *WaitForAsynchronousExtensions* to complete. 1. Run the Update Worker State algorithm passing |registration|'s active worker and *activated* as the arguments.
@@ -2744,24 +2745,19 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe : Input :: |serviceWorker|, a [=/service worker=] :: *force bypass cache for importscripts flag*, an optional flag unset by default - : Output - :: a [=Completion=]
- Note: This algorithm typically blocks until initial script evaluation of the service worker finishes, and returns when the service worker starts its event loop. The return value may be: - * an evaluation status whose \[[Value]] is empty if the worker was not attempted to start at all because the worker was redundant or the [=run a classic script=] or [=run a module script=] algorithm determined not to start the worker. - * an evaluation status whose \[[Value]] is a "QuotaExceededError" DOMException if the script was [=abort a running script|aborted prematurely=] during evaluation. In this case, the worker's [=global object=]'s [=WorkerGlobalScope/closing=] flag is true. - * some other [=abrupt completion=] if, e.g., a uncaught exception occurred during evalution. - * a normal completion. + Note: This algorithm typically blocks until the service worker is [=running=]. Most callsites can check for success or failure by checking if the service worker is [=running=] after this algorithm returns. - This specification generally treats an [=abrupt completion=] due to an uncaught exception the same as a normal completion. That is, if the worker throws an exception during initial script evaluation, it is still considering running and can receive events. However, some callsites distinguish between them using the return value. Other callsites simply check if the service worker is [=running=] after this algorithm returns. + This specification generally treats an [=abrupt completion=] due to an uncaught exception the same as a normal completion. That is, if the worker throws an exception during initial script evaluation, it is still considering running and can receive events. Some callsites distinguish between these scenarios by examining the [=start status=] of the [=running=] worker.
+ 1. If |serviceWorker| is [=running=], then return. + 1. If |serviceWorker|'s [=state=] is *redundant*, then return. + 1. Assert: |serviceWorker|'s [=start status=] is null. 1. Let |script| be |serviceWorker|'s [=service worker/script resource=]. 1. Assert: |script| is not null. - 1. If |serviceWorker| is already running, this algorithm must have been invoked previously. Return the same value as the previous time. - 1. If |serviceWorker|'s [=state=] is *redundant*, then return NormalCompletion(empty). - 1. Let |evaluationStatus| be null. + 1. Let |startFailed| be false. 1. Create a separate parallel execution environment (i.e. a separate thread or process or equivalent construct), and run the following substeps in that context [=in parallel=]: 1. Call the JavaScript [=InitializeHostDefinedRealm|InitializeHostDefinedRealm()=] abstract operation with the following customizations: * For the global object, create a new {{ServiceWorkerGlobalScope}} object. Let |workerGlobalScope| be the created object. @@ -2797,6 +2793,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Create a new {{WorkerLocation}} object and associate it with |workerGlobalScope|. 1. If |serviceWorker| is an active worker, and there are any tasks queued in |serviceWorker|'s containing service worker registration's [=service worker registration/task queues=], queue them to |serviceWorker|'s event loop's [=/task queues=] in the same order using their original task sources. 1. Let |evaluationStatus| be the result of running the classic script |script| if |script| is a classic script, otherwise, the result of running the module script |script| if |script| is a [=module script=]. + 1. If |evaluationStatus|.\[[Value]] is empty, this means the script was not evaluated. Set |startFailed| to true and abort the rest of these steps. + 1. If the script was aborted by the [=Terminate Service Worker=] algorithm, set |startFailed| to true and abort the rest of these steps. + 1. Set |serviceWorker|'s [=start status=] to |evaluationStatus|. 1. If |script|'s has ever been evaluated flag is unset, then: 1. For each |eventType| of |settingsObject|'s [=environment settings object/global object=]'s associated list of event listeners' event types: 1. [=set/Append=] |eventType| to |workerGlobalScope|'s associated [=ServiceWorkerGlobalScope/service worker=]'s set of event types to handle. @@ -2806,8 +2805,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Set |script|'s has ever been evaluated flag. 1. Run the responsible event loop specified by |settingsObject| until it is destroyed. 1. Empty |workerGlobalScope|'s list of active timers. - 1. Wait for |serviceWorker|'s [=event loop=] to start running, or to be destroyed, whichever comes first. - 1. Return |evaluationStatus|. + 1. Wait for |serviceWorker| to be [=running=], or for |startFailed| to be true.
@@ -2819,14 +2817,16 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe :: None 1. If |serviceWorker| is not running, abort these steps. - 1. Let |serviceWorkerGlobalScope| be |serviceWorker|'s [=service worker/global object=]. - 1. Set |serviceWorkerGlobalScope|'s [=WorkerGlobalScope/closing=] flag to true. - 1. [=set/Remove=] all the [=list/items=] from |serviceWorker|'s [=set of extended events=]. - 1. If there are any tasks, whose task source is either the handle fetch task source or the handle functional event task source, queued in |serviceWorkerGlobalScope|'s event loop's [=/task queues=], queue them to |serviceWorker|'s containing service worker registration's corresponding [=service worker registration/task queues=] in the same order using their original task sources, and discard all the tasks (including tasks whose task source is neither the handle fetch task source nor the handle functional event task source) from |serviceWorkerGlobalScope|'s event loop's [=/task queues=] without processing them. + 1. Run the following steps [=in parallel=] with |serviceWorker|'s main loop: + 1. Let |serviceWorkerGlobalScope| be |serviceWorker|'s [=service worker/global object=]. + 1. Set |serviceWorkerGlobalScope|'s [=WorkerGlobalScope/closing=] flag to true. + 1. [=set/Remove=] all the [=list/items=] from |serviceWorker|'s [=set of extended events=]. + 1. If there are any tasks, whose task source is either the handle fetch task source or the handle functional event task source, queued in |serviceWorkerGlobalScope|'s event loop's [=/task queues=], queue them to |serviceWorker|'s containing service worker registration's corresponding [=service worker registration/task queues=] in the same order using their original task sources, and discard all the tasks (including tasks whose task source is neither the handle fetch task source nor the handle functional event task source) from |serviceWorkerGlobalScope|'s event loop's [=/task queues=] without processing them. - Note: This effectively means that the fetch events and the other functional events such as push events are backed up by the registration's task queues while the other tasks including message events are discarded. + Note: This effectively means that the fetch events and the other functional events such as push events are backed up by the registration's task queues while the other tasks including message events are discarded. - 1. Abort the script currently running in |serviceWorker|. + 1. [=Abort a running script|Abort the script=] currently running in |serviceWorker|. + 1. Set |serviceWorker|'s [=start status=] to null.
@@ -2897,8 +2897,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. Return null. 1. If |activeWorker|'s state is *activating*, wait for |activeWorker|'s state to become *activated*. 1. Run the [=Run Service Worker=] algorithm with |activeWorker|. - 1. If |activeWorker| is not [=running=], then return null. - 1. Queue a task |task| to run the following substeps: + 1. If |activeWorker| is not [=running=], then set |handleFetchFailed| to true. + 1. Else queue a task |task| to run the following substeps: 1. Let |e| be the result of creating an event with {{FetchEvent}}. 1. Let |requestObject| be a new {{Request}} object associated with |request| and a new associated {{Headers}} object whose [=guard=] is "`immutable`". 1. Initialize |e|’s {{Event/type}} attribute to {{fetch!!event}}. @@ -2918,11 +2918,11 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe 1. If |e|'s canceled flag is set, set |eventCanceled| to true. 1. If |fetchInstance| is [=fetch/terminated=], then [=queue a task=] to [=AbortSignal/signal abort=] on |requestObject|'s {{Request/signal}}. - If |task| is discarded or the script has been aborted by the termination of |activeWorker|, set |handleFetchFailed| to true. + If |task| is discarded, set |handleFetchFailed| to true. The |task| *must* use |activeWorker|'s event loop and the handle fetch task source. - 1. Wait for |task| to have executed or been discarded. + 1. Wait for |task| to have executed or for |handleFetchFailed| to be true. 1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|. 1. If |respondWithEntered| is false, then return a [=network error=] if |eventCanceled| is true and null otherwise. 1. If |handleFetchFailed| is true, then return a [=network error=].