Skip to content

Commit

Permalink
Remove abort from steps that throw
Browse files Browse the repository at this point in the history
Infra spec clarifies "throw" terminates the algorithm the statement was
in. This change removes unnecessary abort statements that follow the
throw statements.
  • Loading branch information
jungkees committed Aug 1, 2017
1 parent c54fb37 commit 65cf285
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 112 deletions.
48 changes: 19 additions & 29 deletions docs/index.bs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe


A [=/service worker=] has an associated <dfn export id="dfn-imported-scripts-updated-flag">imported scripts updated flag</dfn>. It is initially unset. A [=/service worker=] has an associated <dfn export id="dfn-imported-scripts-updated-flag">imported scripts updated flag</dfn>. It is initially unset.


A [=/service worker=] has an associated <dfn export id="dfn-set-of-event-types-to-handle">set of event types to handle</dfn> (a [=ordered set|set=]) whose [=item=] is an <a>event listener</a>'s event type. It is initially an empty set. A [=/service worker=] has an associated <dfn export id="dfn-set-of-event-types-to-handle">set of event types to handle</dfn> (a [=ordered set|set=]) whose [=list/item=] is an <a>event listener</a>'s event type. It is initially an empty set.


A [=/service worker=] has an associated <dfn export id="dfn-set-of-extended-events">set of extended events</dfn> (a [=ordered set|set=]) whose [=item=] is an {{ExtendableEvent}}. It is initially an empty set. A [=/service worker=] has an associated <dfn export id="dfn-set-of-extended-events">set of extended events</dfn> (a [=ordered set|set=]) whose [=list/item=] is an {{ExtendableEvent}}. It is initially an empty set.


A [=/service worker=] has an associated <dfn export id="dfn-foreign-fetch-scopes">list of foreign fetch scopes</dfn> whose element type is a [=/URL=]. It is initially empty. A [=/service worker=] has an associated <dfn export id="dfn-foreign-fetch-scopes">list of foreign fetch scopes</dfn> whose element type is a [=/URL=]. It is initially empty.


Expand Down Expand Up @@ -350,7 +350,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe


The <dfn method for="ServiceWorker"><code>postMessage(|message|, |transfer|)</code></dfn> method *must* run these steps: The <dfn method for="ServiceWorker"><code>postMessage(|message|, |transfer|)</code></dfn> method *must* run these steps:


1. If the {{ServiceWorker/state}} attribute value of the <a>context object</a> is {{"redundant"}}, <a>throw</a> an "{{InvalidStateError}}" {{DOMException}} and abort these steps. 1. If the {{ServiceWorker/state}} attribute value of the <a>context object</a> is {{"redundant"}}, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
1. Let |serviceWorker| be the [=/service worker=] represented by the <a>context object</a>. 1. Let |serviceWorker| be the [=/service worker=] represented by the <a>context object</a>.
1. Invoke <a>Run Service Worker</a> algorithm with |serviceWorker| as the argument. 1. Invoke <a>Run Service Worker</a> algorithm with |serviceWorker| as the argument.
1. Let |incumbentSettings| be the <a>incumbent settings object</a>, and |incumbentGlobal| its [=environment settings object/global object=]. 1. Let |incumbentSettings| be the <a>incumbent settings object</a>, and |incumbentGlobal| its [=environment settings object/global object=].
Expand All @@ -371,7 +371,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Let |destination| be the {{ServiceWorkerGlobalScope}} object associated with |serviceWorker|. 1. Let |destination| be the {{ServiceWorkerGlobalScope}} object associated with |serviceWorker|.
1. Let |deserializeRecord| be <a abstract-op>StructuredDeserializeWithTransfer</a>(|serializeWithTransferResult|, |destination|'s [=global object/Realm=]). 1. Let |deserializeRecord| be <a abstract-op>StructuredDeserializeWithTransfer</a>(|serializeWithTransferResult|, |destination|'s [=global object/Realm=]).


If this throws an exception, [=fire an event=] named {{messageerror!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin| and the {{MessageEvent/source}} attribute initialized to |source|, and then abort these steps. If this throws an exception, catch it, [=fire an event=] named {{messageerror!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin| and the {{MessageEvent/source}} attribute initialized to |source|, and then abort these steps.
1. Let |messageClone| be |deserializeRecord|.\[[Deserialized]]. 1. Let |messageClone| be |deserializeRecord|.\[[Deserialized]].
1. Let |newPorts| be a new [=frozen array type|frozen array=] consisting of all {{MessagePort}} objects in |deserializeRecord|.\[[TransferredValues]], if any, maintaining their relative order. 1. Let |newPorts| be a new [=frozen array type|frozen array=] consisting of all {{MessagePort}} objects in |deserializeRecord|.\[[TransferredValues]], if any, maintaining their relative order.
1. Let |e| be the result of [=creating an event=] named {{message!!event}}, using {{ExtendableMessageEvent}}, with the {{ExtendableMessageEvent/origin}} attribute initialized to |origin|, the {{ExtendableMessageEvent/source}} attribute initialized to |source|, the {{ExtendableMessageEvent/data}} attribute initialized to |messageClone|, and the {{ExtendableMessageEvent/ports}} attribute initialized to |newPorts|. 1. Let |e| be the result of [=creating an event=] named {{message!!event}}, using {{ExtendableMessageEvent}}, with the {{ExtendableMessageEvent/origin}} attribute initialized to |origin|, the {{ExtendableMessageEvent/source}} attribute initialized to |source|, the {{ExtendableMessageEvent/data}} attribute initialized to |messageClone|, and the {{ExtendableMessageEvent/ports}} attribute initialized to |newPorts|.
Expand Down Expand Up @@ -1049,7 +1049,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Let |source| be a {{ServiceWorker}} object, which represents the [=ServiceWorkerGlobalScope/service worker=] associated with |sourceSettings|'s [=environment settings object/global object=]. 1. Let |source| be a {{ServiceWorker}} object, which represents the [=ServiceWorkerGlobalScope/service worker=] associated with |sourceSettings|'s [=environment settings object/global object=].
1. Let |deserializeRecord| be <a abstract-op>StructuredDeserializeWithTransfer</a>(|serializeWithTransferResult|, |destination|'s [=relevant Realm=]). 1. Let |deserializeRecord| be <a abstract-op>StructuredDeserializeWithTransfer</a>(|serializeWithTransferResult|, |destination|'s [=relevant Realm=]).


If this throws an exception, [=fire an event=] named {{messageerror!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin| and the {{MessageEvent/source}} attribute initialized to |source|, and then abort these steps. If this throws an exception, catch it, [=fire an event=] named {{messageerror!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin| and the {{MessageEvent/source}} attribute initialized to |source|, and then abort these steps.
1. Let |messageClone| be |deserializeRecord|.\[[Deserialized]]. 1. Let |messageClone| be |deserializeRecord|.\[[Deserialized]].
1. Let |newPorts| be a new [=frozen array type|frozen array=] consisting of all {{MessagePort}} objects in |deserializeRecord|.\[[TransferredValues]], if any, 1. Let |newPorts| be a new [=frozen array type|frozen array=] consisting of all {{MessagePort}} objects in |deserializeRecord|.\[[TransferredValues]], if any,
1. [=Dispatch|Dispatch an event=] named {{Window/message!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin|, the {{MessageEvent/source}} attribute initialized to |source|, the {{MessageEvent/data}} attribute initialized to |messageClone|, and the {{MessageEvent/ports}} attribute initialized to |newPorts|. 1. [=Dispatch|Dispatch an event=] named {{Window/message!!event}} at |destination|, using {{MessageEvent}}, with the {{MessageEvent/origin}} attribute initialized to |origin|, the {{MessageEvent/source}} attribute initialized to |source|, the {{MessageEvent/data}} attribute initialized to |messageClone|, and the {{MessageEvent/ports}} attribute initialized to |newPorts|.
Expand Down Expand Up @@ -1333,9 +1333,9 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe


<dfn method for="ExtendableEvent"><code>waitUntil(|f|)</code></dfn> method *must* run these steps: <dfn method for="ExtendableEvent"><code>waitUntil(|f|)</code></dfn> method *must* run these steps:


1. If the {{Event/isTrusted}} attribute is false, [=throw=] an "{{InvalidStateError}}" {{DOMException}} and abort these steps. 1. If the {{Event/isTrusted}} attribute is false, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.


1. If the [=ExtendableEvent/pending promises count=] is zero and the [=dispatch flag=] is unset, [=throw=] an "{{InvalidStateError}}" {{DOMException}} and abort these steps. 1. If the [=ExtendableEvent/pending promises count=] is zero and the [=dispatch flag=] is unset, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.


Note: If no lifetime extension promise has been added in the task that called the event handlers, calling {{ExtendableEvent/waitUntil()}} in subsequent asynchronous tasks will throw. Note: If no lifetime extension promise has been added in the task that called the event handlers, calling {{ExtendableEvent/waitUntil()}} in subsequent asynchronous tasks will throw.


Expand Down Expand Up @@ -1383,23 +1383,21 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe


<dfn method for="InstallEvent"><code>registerForeignFetch(|options|)</code></dfn> method *must* run these steps: <dfn method for="InstallEvent"><code>registerForeignFetch(|options|)</code></dfn> method *must* run these steps:


1. If the <a>dispatch flag</a> is unset, then: 1. If the <a>dispatch flag</a> is unset, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
1. <a>Throw</a> an "{{InvalidStateError}}" {{DOMException}}. 1. If |options|.{{ForeignFetchOptions/origins}} is empty, [=throw=] a <code>TypeError</code>.
1. Abort these steps.
1. If |options|.{{ForeignFetchOptions/origins}} is empty <a>throw</a> a <code>TypeError</code> and abort these steps.
1. Let |originURLs| be an empty list of [=/URLs=]. 1. Let |originURLs| be an empty list of [=/URLs=].
1. If the value of |options|.{{ForeignFetchOptions/origins}} is not a single string equal to a single U+002A ASTERISK character (*): 1. If the value of |options|.{{ForeignFetchOptions/origins}} is not a single string equal to a single U+002A ASTERISK character (*):
1. For each |origin| in |options|.origins: 1. For each |origin| in |options|.origins:
1. If the value of |origin| is not an <a>absolute-URL string</a>, <a>throw</a> a <code>TypeError</code> and abort these steps. 1. If the value of |origin| is not an <a>absolute-URL string</a>, [=throw=] a <code>TypeError</code>.
1. Add the result of <a lt="URL parser">parsing</a> |origin| to |originURLs|. 1. Add the result of <a lt="URL parser">parsing</a> |origin| to |originURLs|.
1. If |options|.{{ForeignFetchOptions/scopes}} is empty <a>throw</a> a <code>TypeError</code> and abort these steps. 1. If |options|.{{ForeignFetchOptions/scopes}} is empty, [=throw=] a <code>TypeError</code>.
1. Let |scopeString| be the <a>context object</a>'s <a>relevant global object</a>'s [=ServiceWorkerGlobalScope/service worker=]'s <a>containing service worker registration</a>'s [=service worker registration/scope url=], <a lt="URL serializer">serialized</a>. 1. Let |scopeString| be the <a>context object</a>'s <a>relevant global object</a>'s [=ServiceWorkerGlobalScope/service worker=]'s <a>containing service worker registration</a>'s [=service worker registration/scope url=], <a lt="URL serializer">serialized</a>.
1. Let |subScopeURLs| be an empty list of [=/URLs=]. 1. Let |subScopeURLs| be an empty list of [=/URLs=].
1. For each |subScope| in |options|.{{ForeignFetchOptions/scopes}}: 1. For each |subScope| in |options|.{{ForeignFetchOptions/scopes}}:
1. Let |subScopeURL| be the result of <a lt="URL parser">parsing</a> |subScope| with <a>context object</a>'s <a>relevant settings object</a>'s <a>API base URL</a>. 1. Let |subScopeURL| be the result of <a lt="URL parser">parsing</a> |subScope| with <a>context object</a>'s <a>relevant settings object</a>'s <a>API base URL</a>.
1. If |subScopeURL| is failure, <a>throw</a> a <code>TypeError</code> and abort these steps. 1. If |subScopeURL| is failure, [=throw=] a <code>TypeError</code>.
1. Let |subScopeString| be the <a lt="URL serializer">serialized</a> |subScopeURL|. 1. Let |subScopeString| be the <a lt="URL serializer">serialized</a> |subScopeURL|.
1. If |subScopeString| does not start with |scopeString|, <a>throw</a> a <code>TypeError</code> and abort these steps. 1. If |subScopeString| does not start with |scopeString|, [=throw=] a <code>TypeError</code>.
1. Add |subScopeURL| to |subScopeURLs|. 1. Add |subScopeURL| to |subScopeURLs|.
1. Set this [=/service worker=]'s <a>list of foreign fetch scopes</a> to |subScopeURLs|. 1. Set this [=/service worker=]'s <a>list of foreign fetch scopes</a> to |subScopeURLs|.
1. Set this [=/service worker=]'s <a>list of foreign fetch origins</a> to |originURLs|. 1. Set this [=/service worker=]'s <a>list of foreign fetch origins</a> to |originURLs|.
Expand Down Expand Up @@ -1476,12 +1474,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe


<dfn method for="FetchEvent"><code>respondWith(|r|)</code></dfn> method *must* run these steps: <dfn method for="FetchEvent"><code>respondWith(|r|)</code></dfn> method *must* run these steps:


1. If the <a>dispatch flag</a> is unset, then: 1. If the <a>dispatch flag</a> is unset, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
1. <a>Throw</a> an "{{InvalidStateError}}" {{DOMException}}. 1. If the [=FetchEvent/respond-with entered flag=] is set, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
1. Abort these steps.
1. If the [=FetchEvent/respond-with entered flag=] is set, then:
1. <a>Throw</a> an "{{InvalidStateError}}" {{DOMException}}.
1. Abort these steps.
1. Add |r| to the <a>extend lifetime promises</a>. 1. Add |r| to the <a>extend lifetime promises</a>.
1. Increment the [=ExtendableEvent/pending promises count=] by one. 1. Increment the [=ExtendableEvent/pending promises count=] by one.


Expand Down Expand Up @@ -1596,12 +1590,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
<dfn method for="ForeignFetchEvent"><code>respondWith(|r|)</code></dfn> method *must* run these steps: <dfn method for="ForeignFetchEvent"><code>respondWith(|r|)</code></dfn> method *must* run these steps:


<div link-for-hint="ForeignFetchEvent"> <div link-for-hint="ForeignFetchEvent">
1. If the <a>dispatch flag</a> is unset, then: 1. If the <a>dispatch flag</a> is unset, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
1. <a>Throw</a> an "{{InvalidStateError}}" {{DOMException}}. 1. If the [=ForeignFetchEvent/respond-with entered flag=] is set, [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
1. Abort these steps.
1. If the [=ForeignFetchEvent/respond-with entered flag=] is set, then:
1. <a>Throw</a> an "{{InvalidStateError}}" {{DOMException}}.
1. Abort these steps.
1. Add |r| to the <a>extend lifetime promises</a>. 1. Add |r| to the <a>extend lifetime promises</a>.
1. Increment the [=ExtendableEvent/pending promises count=] by one. 1. Increment the [=ExtendableEvent/pending promises count=] by one.


Expand Down Expand Up @@ -2914,7 +2904,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. If |serviceWorker| is not running, abort these steps. 1. If |serviceWorker| is not running, abort these steps.
1. Let |serviceWorkerGlobalScope| be |serviceWorker|'s [=service worker/global object=]. 1. Let |serviceWorkerGlobalScope| be |serviceWorker|'s [=service worker/global object=].
1. Set |serviceWorkerGlobalScope|'s [=WorkerGlobalScope/closing=] flag to true. 1. Set |serviceWorkerGlobalScope|'s [=WorkerGlobalScope/closing=] flag to true.
1. [=set/Remove=] all the [=items=] from |serviceWorker|'s [=set of extended events=]. 1. [=set/Remove=] all the [=list/items=] from |serviceWorker|'s [=set of extended events=].
1. If there are any <a>tasks</a>, whose <a>task source</a> is either the <a>handle fetch task source</a> or the <a>handle functional event task source</a>, queued in |serviceWorkerGlobalScope|'s <a>event loop</a>'s [=/task queues=], <a lt="queue a task">queue</a> them to |serviceWorker|'s <a>containing service worker registration</a>'s corresponding [=service worker registration/task queues=] in the same order using their original <a>task sources</a>, and discard all the <a>tasks</a> (including <a>tasks</a> whose <a>task source</a> is neither the <a>handle fetch task source</a> nor the <a>handle functional event task source</a>) from |serviceWorkerGlobalScope|'s <a>event loop</a>'s [=/task queues=] without processing them. 1. If there are any <a>tasks</a>, whose <a>task source</a> is either the <a>handle fetch task source</a> or the <a>handle functional event task source</a>, queued in |serviceWorkerGlobalScope|'s <a>event loop</a>'s [=/task queues=], <a lt="queue a task">queue</a> them to |serviceWorker|'s <a>containing service worker registration</a>'s corresponding [=service worker registration/task queues=] in the same order using their original <a>task sources</a>, and discard all the <a>tasks</a> (including <a>tasks</a> whose <a>task source</a> is neither the <a>handle fetch task source</a> nor the <a>handle functional event task source</a>) from |serviceWorkerGlobalScope|'s <a>event loop</a>'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.
Expand Down Expand Up @@ -3568,7 +3558,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
1. Return |resultArray|. 1. Return |resultArray|.
1. And then, if an exception was <a lt="throw">thrown</a>, then: 1. And then, if an exception was <a lt="throw">thrown</a>, then:
1. Set the <a>context object</a>'s <a>request to response map</a> to |itemsCopy|. 1. Set the <a>context object</a>'s <a>request to response map</a> to |itemsCopy|.
1. <a>Throw</a> the exception 1. <a>Throw</a> the exception.
</section> </section>
</section> </section>


Expand Down

0 comments on commit 65cf285

Please sign in to comment.