Skip to content

Commit

Permalink
Tidy up global object usage
Browse files Browse the repository at this point in the history
This commit is part of the effort in w3c#922 to eliminate the use of entry and incumbent settings objects. It mostly just changes cases where all of relevant/current/entry/incumbent are equivalent, to use relevant. It also removes mention of "default action" for events, since that is not supposed to exist, and does some other tidying in the postMessage algorithms.

There are no normative changes in this commit.
  • Loading branch information
domenic committed Aug 10, 2016
1 parent cb05733 commit b546c24
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 36 deletions.
39 changes: 21 additions & 18 deletions spec/service_worker/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ spec: html; type: dfn
text: parent browsing context
text: queue a task
text: relevant settings object
text: the environment settings object's global object
text: replacement enabled
text: responsible browsing context
text: responsible document
Expand Down Expand Up @@ -518,17 +519,18 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<li>Invoke <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>serviceWorker</var> as the argument.</li>
<li>Let <var>destination</var> be the {{ServiceWorkerGlobalScope}} object associated with <var>serviceWorker</var>.</li>
<li>Let <var>targetRealm</var> be <var>destination</var>'s <a lt="the global object's Realm">Realm</a>.</li>
<li>Let <var>incumbentSettings</var> be the <a>incumbent settings object</a>, and <var>incumbentGlobal</var> its <a lt="the environment settings object's global object">global object</a>.</li>
<li>Let <var>cloneRecord</var> be <a>StructuredCloneWithTransfer</a>(<var>message</var>, <var>transfer</var>, <var>targetRealm</var>). If this <a>throws</a> an exception, <a lt="throw">rethrow</a> that exception and abort these steps.</li>
<li>Let <var>clonedMessage</var> be <var>cloneRecord</var>.\[[Clone]].</li>
<li>Let <var>newPorts</var> be a new <a lt="frozen array type">frozen array</a> consisting of all {{MessagePort}} objects in <var>cloneRecord</var>.\[[TransferList]], if any, maintaining their relative order.</li>
<li><a>Queue a task</a> that runs the following steps:
<ol>
<li>Create an event <var>e</var> that uses the {{ExtendableMessageEvent}} interface, with the event type <a href="#service-worker-global-scope-message-event">message</a>, which does not bubble, is not cancelable, and has no default action.</li>
<li>Create an event <var>e</var> that uses the {{ExtendableMessageEvent}} interface, with the event type <a href="#service-worker-global-scope-message-event">message</a>, which does not bubble and is not cancelable.</li>
<li>Let the {{ExtendableMessageEvent/data}} attribute of <var>e</var> be initialized to <var>clonedMessage</var>.</li>
<li>Let the {{ExtendableMessageEvent/origin}} attribute of <var>e</var> be initialized to the <a lt="unicode serialisation of an origin">Unicode serialisation</a> of the <a for="resource">origin</a> specified by the <a>incumbent settings object</a>.</li>
<li>If the <a>global object</a> <var>globalObject</var> specified by the <a>incumbent settings object</a> is a {{ServiceWorkerGlobalScope}} object, let the {{ExtendableMessageEvent/source}} attribute of <var>e</var> be initialized to a new {{ServiceWorker}} object that represents <var>globalObject</var>'s <a href="#dfn-service-worker-global-scope-service-worker">service worker</a>.</li>
<li>Else if <var>globalObject</var> is a {{Window}} object, let the {{ExtendableMessageEvent/source}} attribute of <var>e</var> be initialized to a new {{WindowClient}} object that represents <var>globalObject</var>'s <a>browsing context</a>.</li>
<li>Else, let it be initialized to a new {{Client}} object that represents the worker associated with <var>globalObject</var>.</li>
<li>Let the {{ExtendableMessageEvent/origin}} attribute of <var>e</var> be initialized to the <a lt="unicode serialisation of an origin">Unicode serialisation</a> of <var>incumbentSettings</var>'s <a for="resource">origin</a>.</li>
<li>If <var>incumbentGlobal</var> is a {{ServiceWorkerGlobalScope}} object, let the {{ExtendableMessageEvent/source}} attribute of <var>e</var> be initialized to a new {{ServiceWorker}} object that represents <var>incumbentGlobal</var>'s <a href="#dfn-service-worker-global-scope-service-worker">service worker</a>.</li>
<li>Else if <var>incumbentGlobal</var> is a {{Window}} object, let the {{ExtendableMessageEvent/source}} attribute of <var>e</var> be initialized to a new {{WindowClient}} object that represents <var>incumbentGlobal</var>'s <a>browsing context</a>.</li>
<li>Else, let it be initialized to a new {{Client}} object that represents the worker associated with <var>incumbentGlobal</var>.</li>
<li>Let the {{ExtendableMessageEvent/ports}} attribute of <var>e</var> be initialized to <var>newPorts</var>.</li>
<li><a>Dispatch</a> <var>e</var> at <var>destination</var>.</li>
</ol>
Expand Down Expand Up @@ -1218,18 +1220,19 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<p>The <dfn method for="Client" id="client-postmessage-method"><code>postMessage(<var>message</var>, <var>transfer</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps or their <a href="#dfn-processing-equivalence">equivalent</a>:</p>

<ol>
<li>Let <var>sourceSettings</var> be the <a>context object</a>'s <a>relevant settings object</a>.</li>
<li>Let <var>destination</var> be the {{ServiceWorkerContainer}} object whose <a href="#dfn-service-worker-container-interface-client">service worker client</a> is the <a>context object</a>'s <a href="#dfn-service-worker-client-client">service worker client</a>.</li>
<li>If <var>destination</var> is null, <a>throw</a> an "{{InvalidStateError}}" exception.</li>
<li>Let <var>targetRealm</var> be <var>destination</var>'s <a lt="the global object's Realm">Realm</a>.</li>
<li>Let <var>targetRealm</var> be <var>destination</var>'s <a>relevant Realm</a>.</li>
<li>Let <var>cloneRecord</var> be <a>StructuredCloneWithTransfer</a>(<var>message</var>, <var>transfer</var>, <var>targetRealm</var>). If this <a>throws</a> an exception, <a lt="throw">rethrow</a> that exception and abort these steps.</li>
<li>Let <var>clonedMessage</var> be <var>cloneRecord</var>.\[[Clone]].</li>
<li>Let <var>newPorts</var> be a new <a lt="frozen array type">frozen array</a> consisting of all {{MessagePort}} objects in <var>cloneRecord</var>.\[[TransferList]], if any, maintaining their relative order.</li>
<li>Add a <a>task</a> that runs the following steps to <var>destination</var>'s <a>client message queue</a>:
<ol>
<li>Create an event <var>e</var> that uses the {{ServiceWorkerMessageEvent}} interface, with the event type <a href="#service-worker-container-message-event">message</a>, which does not bubble, is not cancelable, and has no default action.</li>
<li>Create an event <var>e</var> that uses the {{ServiceWorkerMessageEvent}} interface, with the event type <a href="#service-worker-container-message-event">message</a>, which does not bubble and is not cancelable.</li>
<li>Let the {{ServiceWorkerMessageEvent/data}} attribute of <var>e</var> be initialized to <var>clonedMessage</var>.</li>
<li>Let the {{ServiceWorkerMessageEvent/origin}} attribute of <var>e</var> be initialized to the <a lt="unicode serialisation of an origin">Unicode serialisation</a> of the <a for="resource">origin</a> specified by the <a>incumbent settings object</a>.</li>
<li>Let the {{ServiceWorkerMessageEvent/source}} attribute of <var>e</var> be initialized to a {{ServiceWorker}} object, which represents the <a href="#dfn-service-worker-global-scope-service-worker">service worker</a> associated with the <a>global object</a> specified by the <a>incumbent settings object</a>.</li>
<li>Let the {{ServiceWorkerMessageEvent/origin}} attribute of <var>e</var> be initialized to the <a lt="unicode serialisation of an origin">Unicode serialisation</a> of <var>sourceSettings</var>'s <a for="resource">origin</a>.</li>
<li>Let the {{ServiceWorkerMessageEvent/source}} attribute of <var>e</var> be initialized to a {{ServiceWorker}} object, which represents the <a href="#dfn-service-worker-global-scope-service-worker">service worker</a> associated with <var>sourceSettings</var>'s <a lt="the environment settings object's global object">global object</a>.</li>
<li>Let the {{ServiceWorkerMessageEvent/ports}} attribute of <var>e</var> be initialized to <var>newPorts</var>.</li>
<li><a>Dispatch</a> <var>e</var> at <var>destination</var>.</li>
</ol>
Expand Down Expand Up @@ -1285,10 +1288,10 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<p>The <dfn method for="WindowClient" id="client-navigate-method"><code>navigate()</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps or their <a href="#dfn-processing-equivalence">equivalent</a>:</p>

<ol>
<li>Let <var>url</var> be the result of <a for="url">parsing</a> <var>url</var> with <a>entry settings object</a>'s <a>API base URL</a>.</li>
<li>Let <var>url</var> be the result of <a for="url">parsing</a> <var>url</var> with the <a>context object</a>'s <a>relevant settings object</a>'s <a>API base URL</a>.</li>
<li>If <var>url</var> is failure, return a <a>promise</a> rejected with a <code>TypeError</code>.</li>
<li>If <var>url</var> is <code><a>about:blank</a></code>, return a <a>promise</a> rejected with a <code>TypeError</code>.</li>
<li>If the <a>context object</a>'s associated <a href="#dfn-service-worker-client-client">service worker client</a>'s <a href="#dfn-service-worker-client-active-worker">active worker</a> is not the <a>incumbent settings object</a>'s <a>global object</a>'s <a href="#dfn-service-worker-global-scope-service-worker">service worker</a>, return a <a>promise</a> rejected with a <code>TypeError</code>.</li>
<li>If the <a>context object</a>'s associated <a href="#dfn-service-worker-client-client">service worker client</a>'s <a href="#dfn-service-worker-client-active-worker">active worker</a> is not the <a>context object</a>'s <a>relevant global object</a>'s <a href="#dfn-service-worker-global-scope-service-worker">service worker</a>, return a <a>promise</a> rejected with a <code>TypeError</code>.</li>
<li>Let <var>promise</var> be a new <a>promise</a>.</li>
<li>Run these substeps <a>in parallel</a>:
<ol>
Expand Down Expand Up @@ -1513,7 +1516,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<p>The <dfn method id="clients-openwindow-method"><code>openWindow(<var>url</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps or their <a href="#dfn-processing-equivalence">equivalent</a>:</p>

<ol>
<li>Let <var>url</var> be the result of <a for="url">parsing</a> <var>url</var> with <a>entry settings object</a>'s <a>API base URL</a>.</li>
<li>Let <var>url</var> be the result of <a for="url">parsing</a> <var>url</var> with the <a>context object</a>'s <a>relevant settings object</a>'s <a>API base URL</a>.</li>
<li>If <var>url</var> is failure, return a <a>promise</a> rejected with a <code>TypeError</code>.</li>
<li>If <var>url</var> is <code><a>about:blank</a></code>, return a <a>promise</a> rejected with a <code>TypeError</code>.</li>
<li>If this algorithm is not <a>triggered by user activation</a>, return a <a>promise</a> rejected with an "{{InvalidAccessError}}" exception.</li>
Expand Down Expand Up @@ -1689,11 +1692,11 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
</ol>
</li>
<li>If <var>options</var>.{{ForeignFetchOptions/scopes}} is empty <a>throw</a> a <code>TypeError</code> and abort these steps.</li>
<li>Let <var>scopeString</var> be the <a>incumbent settings object</a>'s <a>global object</a>'s <a for="ServiceWorkerGlobalScope">service worker</a>'s <a>containing service worker registration</a>'s <a for="service worker registration">scope url</a>, <a for="url">serialized</a>.</li>
<li>Let <var>scopeString</var> be the <a>context object</a>'s <a>relevant global object</a>'s <a for="ServiceWorkerGlobalScope">service worker</a>'s <a>containing service worker registration</a>'s <a for="service worker registration">scope url</a>, <a for="url">serialized</a>.</li>
<li>Let <var>subScopeURLs</var> be an empty list of <a for="url">URLs</a>.</li>
<li>For each <var>subScope</var> in <var>options</var>.{{ForeignFetchOptions/scopes}}:
<ol>
<li>Let <var>subScopeURL</var> be the result of <a for="url">parsing</a> <var>subScope</var> with <a>entry settings object</a>'s <a>API base URL</a>.</li>
<li>Let <var>subScopeURL</var> be the result of <a for="url">parsing</a> <var>subScope</var> with <a>context object</a>'s <a>relevant settings object</a>'s <a>API base URL</a>.</li>
<li>If <var>subScopeURL</var> is failure, <a>throw</a> a <code>TypeError</code> and abort these steps.</li>
<li>Let <var>subScopeString</var> be the <a for="url">serialized</a> <var>subScopeURL</var>.</li>
<li>If <var>subScopeString</var> does not start with <var>scopeString</var>, <a>throw</a> a <code>TypeError</code> and abort these steps.</li>
Expand Down Expand Up @@ -3387,7 +3390,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<li>Invoke <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>installingWorker</var> as the argument.</li>
<li><a>Queue a task</a> <var>task</var> to run the following substeps:
<ol>
<li>Create a <a>trusted event</a> <var>e</var> that uses the {{InstallEvent}} interface, with the event type <code><a href="#service-worker-global-scope-install-event">install</a></code>, which does not bubble, is not cancelable, and has no default action.</li>
<li>Create a <a>trusted event</a> <var>e</var> that uses the {{InstallEvent}} interface, with the event type <code><a href="#service-worker-global-scope-install-event">install</a></code>, which does not bubble and is not cancelable.</li>
<li><a>Dispatch</a> <var>e</var> at <var>installingWorker</var>'s <a>environment settings object</a>'s <a>global object</a> <var>globalObject</var>.</li>
<li><em>WaitForAsynchronousExtensions</em>: Run the following substeps <a>in parallel</a>:
<ol>
Expand Down Expand Up @@ -3477,7 +3480,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<li>Invoke <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>activeWorker</var> as the argument.</li>
<li><a>Queue a task</a> <var>task</var> to run the following substeps:
<ol>
<li>Create a <a>trusted event</a> <var>e</var> that uses the {{ExtendableEvent}} interface, with the event type <code><a href="#service-worker-global-scope-activate-event">activate</a></code>, which does not bubble, is not cancelable, and has no default action.</li>
<li>Create a <a>trusted event</a> <var>e</var> that uses the {{ExtendableEvent}} interface, with the event type <code><a href="#service-worker-global-scope-activate-event">activate</a></code>, which does not bubble and is not cancelable.</li>
<li><a>Dispatch</a> <var>e</var> at <var>activeWorker</var>'s <a>environment settings object</a>'s <a>global object</a>.</li>
<li><em>WaitForAsynchronousExtensions</em>: Wait, <a>in parallel</a>, until <var>e</var>'s <a>extensions allowed flag</a> is unset.</li>
</ol>
Expand Down Expand Up @@ -3626,7 +3629,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<li>Invoke <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>activeWorker</var> as the argument.</li>
<li><a>Queue a task</a> <var>task</var> to run the following substeps:
<ol>
<li>Create a <a>trusted event</a> <var>e</var> that uses the {{FetchEvent}} interface, with the event type <code><a href="#service-worker-global-scope-fetch-event">fetch</a></code>, which does not bubble and has no default action.</li>
<li>Create a <a>trusted event</a> <var>e</var> that uses the {{FetchEvent}} interface, with the event type <code><a href="#service-worker-global-scope-fetch-event">fetch</a></code>, which does not bubble.</li>
<li>Let the <a href="#fetch-event-request-attribute">request</a> attribute of <var>e</var> be initialized to <var>r</var>.</li>
<li>Let the <a href="#fetch-event-clientid-attribute">clientId</a> attribute of <var>e</var> be initialized to <var>client</var>'s <a href="#dfn-service-worker-client-id">id</a> if <var>request</var> is not a <a>non-subresource request</a>, and to null otherwise.</li>
<li>Let the <a href="#fetch-event-isreload-attribute">isReload</a> attribute of <var>e</var> be initialized to <code>true</code> if <var>request</var>'s <a for="request">client</a> is a <a href="#dfn-window-client">window client</a> and the event was dispatched with the user's intention for the page reload, and <code>false</code> otherwise.</li>
Expand Down Expand Up @@ -3707,7 +3710,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
<li>Invoke [[#run-service-worker-algorithm]] algorithm with <var>activeWorker</var> as the argument.</li>
<li><a>Queue a task</a> <var>task</var> to run the following substeps:
<ol>
<li>Create a <a>trusted event</a> <var>e</var> that uses the {{ForeignFetchEvent}} interface, with the event type <code><a href="#service-worker-global-scope-foreignfetch-event">foreignfetch</a></code>, which does not bubble and has no default action.</li>
<li>Create a <a>trusted event</a> <var>e</var> that uses the {{ForeignFetchEvent}} interface, with the event type <code><a href="#service-worker-global-scope-foreignfetch-event">foreignfetch</a></code>, which does not bubble.</li>
<li>Let the {{ForeignFetchEvent/request}} attribute of <var>e</var> be initialized to <var>r</var>.</li>
<li>Let the {{ForeignFetchEvent/origin}} attribute of <var>e</var> be initialized to the <a lt="Unicode serialisation of an origin">Unicode serialization</a> of <var>request</var>'s <a for=request>origin</a>.</li>
<li><a>Dispatch</a> <var>e</var> at <var>activeWorker</var>'s <a>environment settings object</a>'s <a>global object</a>.</li>
Expand Down
Loading

0 comments on commit b546c24

Please sign in to comment.