Skip to content

Commit

Permalink
Add service worker's set of event types to handle internal slot and e…
Browse files Browse the repository at this point in the history
…nforce a rule in Handle Fetch.
  • Loading branch information
jungkees committed Jul 7, 2015
1 parent 65a0f1b commit f8d94f5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion spec/service_worker/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ <h1>Service Worker</h1>
<p>A <a href="#dfn-service-worker">service worker</a> has an associated <dfn id="dfn-script-resource-map">script resource map</dfn> which is a <a href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">List</a> of the <a href="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} where [[key]] is a <a href="https://url.spec.whatwg.org/#concept-url">URL</a> and [[value]] is a script resource.</p>
<p>A <a href="#dfn-service-worker">service worker</a> has an associated <dfn id="dfn-skip-waiting-flag">skip waiting flag</dfn>. Unless stated otherwise it is unset.</p>
<p>A <a href="#dfn-service-worker">service worker</a> has an associated <dfn id="dfn-imported-scripts-updated-flag">imported scripts updated flag</dfn>. It is initially unset.</p>
<p>A <a href="#dfn-service-worker">service worker</a> has an associated <dfn id="dfn-set-of-event-types-to-handle">set of event types to handle</dfn> whose element type is an <a href="https://dom.spec.whatwg.org/#concept-event-listener">event listener</a>'s event type. It is initially set to null.</p>

<spec-section id="service-worker-lifetime">
<h1>Lifetime</h1>
Expand Down Expand Up @@ -2846,6 +2847,9 @@ <h1>Run Service Worker</h1>
<li>Parse/compile/initialize <var>source</var> using that <a href="https://html.spec.whatwg.org/multipage/webappapis.html#script-execution-environment">script execution environment</a>, as appropriate for <var>language</var>, and thus obtain a <a href="https://html.spec.whatwg.org/multipage/webappapis.html#code-entry-point">code entry-point</a>. If the script was not compiled successfully, let the <a href="https://html.spec.whatwg.org/multipage/webappapis.html#code-entry-point">code entry-point</a> be a no-op script, and act as if a corresponding uncaught script error had occurred.</li>
<li>Let <var>script</var>'s <a href="https://html.spec.whatwg.org/multipage/webappapis.html#settings-object">settings object</a> be <var>settingsObject</var>.</li>
<li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#jump-to-a-code-entry-point">Jump</a> to the <var>script</var>'s <a href="https://html.spec.whatwg.org/multipage/webappapis.html#code-entry-point">code entry-point</a>, and let that run until it either returns, fails to catch an exception, or gets aborted by the <a href="https://html.spec.whatwg.org/multipage/workers.html#kill-a-worker">kill a worker</a> or <a href="https://html.spec.whatwg.org/multipage/workers.html#terminate-a-worker">terminate a worker</a> algorithms.</li>
<li>Set <var>workerGlobalScope</var>'s associated <a href="#dfn-service-worker-global-scope-service-worker">service worker</a>'s <a href="#dfn-set-of-event-types-to-handle">set of event types to handle</a> to the set of event types created from <var>settingsObject</var>'s <a href="https://html.spec.whatwg.org/multipage/webappapis.html#global-object">global object</a>'s associated list of <a href="https://dom.spec.whatwg.org/#concept-event-listener">event listeners</a>' event types.
<p class="note">If the global object's associated list of event listeners does not have any event listener added at this moment, the service worker's set of event types to handle is set to an empty set. The user agents are encouraged to show a warning that the event listeners must be added on the initial evaluation of worker script.</p>
</li>
<li>Run the <a href="https://html.spec.whatwg.org/multipage/webappapis.html#responsible-event-loop">responsible event loop</a> specified by <var>settingsObject</var> until it is destroyed.</li>
<li>Empty <var>workerGlobalScope</var>'s <a href="">list of active timers</a>.</li>
</ol>
Expand Down Expand Up @@ -2919,12 +2923,14 @@ <h1>Handle Fetch</h1>
</ol>
</li>
<li>Let <var>activeWorker</var> be <var>registration</var>'s <a href="#dfn-active-worker">active worker</a>.</li>
<li>If <var>activeWorker</var>'s <a href="#dfn-set-of-event-types-to-handle">set of event types to handle</a> does not contain <code>fetch</code>, return null.
<p class="note">To avoid unnecessary delays, the Handle Fetch enforces early return when no event listeners have been deterministically added in the service worker's global during the initial script execution.</p>
</li>
<li>If <var>activeWorker</var>'s <a href="#dfn-state">state</a> is <em>activating</em>, then:
<ol>
<li>Wait for <var>activeWorker</var>'s <a href="#dfn-state">state</a> to become <em>activated</em>.</li>
</ol>
</li>
<li><a href="http://www.ecma-international.org/ecma-262/6.0/#sec-algorithm-conventions">Assert</a>: <var>activeWorker</var> is not null, and its <a href="#dfn-state">state</a> is <em>activated</em>.</li>
<li>Invoke <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>activeWorker</var> as the arguement.</li>
<li><a href="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a> <var>task</var> to run the following substeps:
<ol>
Expand Down

0 comments on commit f8d94f5

Please sign in to comment.