You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spec/service_worker/index.html
+13-5Lines changed: 13 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -141,7 +141,7 @@ <h1>Service Worker</h1>
141
141
<p>A <ahref="#dfn-service-worker">service worker</a> has an associated <dfnid="dfn-containing-service-worker-registration">containing service worker registration</dfn> (a <ahref="#dfn-service-worker-registration">service worker registration</a>), which contains itself.</p>
142
142
<p>A <ahref="#dfn-service-worker">service worker</a> has an associated <dfnid="dfn-service-worker-id">id</dfn> (an opaque string), which uniquely identifies itself during the lifetime of its <ahref="#dfn-containing-service-worker-registration">containing service worker registration</a>.</p>
143
143
<p>A <ahref="#dfn-service-worker">service worker</a> is dispatched a set of <dfnid="dfn-lifecycle-events">lifecycle events</dfn>, <ahref="#service-worker-global-scope-install-event">install</a> and <ahref="#service-worker-global-scope-activate-event">activate</a>, and <dfnid="dfn-functional-events">functional events</dfn> including <ahref="#service-worker-global-scope-fetch-event">fetch</a>.</p>
144
-
<p>A <ahref="#dfn-service-worker">service worker</a> has an associated <dfnid="dfn-script-resource">script resource</dfn>, which represents its own script resource. It is initially set to null.</p>
144
+
<p>A <ahref="#dfn-service-worker">service worker</a> has an associated <dfnid="dfn-script-resource">script resource</dfn>, which represents its own script resource. It is initially set to null. A <ahref="#dfn-script-resource">script resource</a> has an associated <dfnid="dfn-has-ever-been-evaluated-flag">has ever been evaluated flag</dfn>. It is initially unset.</p>
145
145
<p>A <ahref="#dfn-service-worker">service worker</a> has an associated <dfnid="dfn-script-resource-map">script resource map</dfn> which is a <ahref="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">List</a> of the <ahref="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> {[[key]], [[value]]} where [[key]] is a <ahref="https://url.spec.whatwg.org/#concept-url">URL</a> and [[value]] is a script resource.</p>
146
146
<p>A <ahref="#dfn-service-worker">service worker</a> has an associated <dfnid="dfn-skip-waiting-flag">skip waiting flag</dfn>. Unless stated otherwise it is unset.</p>
147
147
<p>A <ahref="#dfn-service-worker">service worker</a> has an associated <dfnid="dfn-imported-scripts-updated-flag">imported scripts updated flag</dfn>. It is initially unset.</p>
@@ -3078,16 +3078,21 @@ <h1>Run Service Worker</h1>
3078
3078
</dl>
3079
3079
</li>
3080
3080
<li>Create a separate parallel execution environment (i.e. a separate thread or process or equivalent construct), and run the rest of these steps in that context.</li>
3081
-
<li>Let <var>source</var> be the result of running the <ahref="https://html.spec.whatwg.org/multipage/infrastructure.html#utf-8-decode">UTF-8 decode</a> algorithm on the script resource of <var>serviceWorker</var>.</li>
3081
+
<li>Let <var>source</var> be the result of running the <ahref="https://html.spec.whatwg.org/multipage/infrastructure.html#utf-8-decode">UTF-8 decode</a> algorithm on <var>serviceWorker</var>'s <ahref="#dfn-script-resource">script resource</a><var>scriptResource</var>.</li>
3082
3082
<li>Let <var>language</var> be JavaScript.</li>
3083
3083
<li>In the newly created execution environment, create a <ahref="https://html.spec.whatwg.org/multipage/infrastructure.html#javascript-global-environment">JavaScript global environment</a> whose <em>global object</em> is <var>workerGlobalScope</var>. (The <ahref="https://html.spec.whatwg.org/multipage/infrastructure.html#javascript-global-environment">JavaScript global environment</a> whose <em>global object</em> is a <code><ahref="#service-worker-global-scope-interface">ServiceWorkerGlobalScope</a></code> object is defined as the <dfnid="service-worker-environment">service worker environment</dfn>, which is a type of <ahref="https://html.spec.whatwg.org/multipage/webappapis.html#worker-environment">worker environments</a>.)</li>
3084
3084
<li>Let <var>script</var> be a new <ahref="https://html.spec.whatwg.org/multipage/webappapis.html#concept-script">script</a>.</li>
3085
3085
<li>Obtain the appropriate <ahref="https://html.spec.whatwg.org/multipage/webappapis.html#script-execution-environment">script execution environment</a> for the scripting language <var>language</var> from <var>settingsObject</var>.</li>
3086
3086
<li>Parse/compile/initialize <var>source</var> using that <ahref="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 <ahref="https://html.spec.whatwg.org/multipage/webappapis.html#code-entry-point">code entry-point</a>. If the script was not compiled successfully, let the <ahref="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>
3087
3087
<li>Let <var>script</var>'s <ahref="https://html.spec.whatwg.org/multipage/webappapis.html#settings-object">settings object</a> be <var>settingsObject</var>.</li>
3088
3088
<li><ahref="https://html.spec.whatwg.org/multipage/webappapis.html#jump-to-a-code-entry-point">Jump</a> to the <var>script</var>'s <ahref="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 <ahref="https://html.spec.whatwg.org/multipage/workers.html#kill-a-worker">kill a worker</a> or <ahref="#terminate-service-worker-algorithm">Terminate Service Worker</a> algorithms.</li>
3089
-
<li>Set <var>workerGlobalScope</var>'s associated <ahref="#dfn-service-worker-global-scope-service-worker">service worker</a>'s <ahref="#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 <ahref="https://html.spec.whatwg.org/multipage/webappapis.html#global-object">global object</a>'s associated list of <ahref="https://dom.spec.whatwg.org/#concept-event-listener">event listeners</a>' event types.
3090
-
<pclass="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>
3089
+
<li>If <var>scriptResource</var>'s <ahref="#dfn-has-ever-been-evaluated-flag">has ever been evaluated flag</a> is unset, then:
3090
+
<ol>
3091
+
<li>Set <var>workerGlobalScope</var>'s associated <ahref="#dfn-service-worker-global-scope-service-worker">service worker</a>'s <ahref="#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 <ahref="https://html.spec.whatwg.org/multipage/webappapis.html#global-object">global object</a>'s associated list of <ahref="https://dom.spec.whatwg.org/#concept-event-listener">event listeners</a>' event types.
3092
+
<pclass="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 very first evaluation of the worker script.</p>
3093
+
</li>
3094
+
<li>Set <var>scriptResource</var>'s <ahref="#dfn-has-ever-been-evaluated-flag">has ever been evaluated flag</a>.</li>
3095
+
</ol>
3091
3096
</li>
3092
3097
<li>Run the <ahref="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>
3093
3098
<li>Empty <var>workerGlobalScope</var>'s <ahref="https://html.spec.whatwg.org/multipage/webappapis.html#list-of-active-timers">list of active timers</a>.</li>
@@ -3164,7 +3169,7 @@ <h1>Handle Fetch</h1>
3164
3169
</li>
3165
3170
<li>Let <var>activeWorker</var> be <var>registration</var>'s <ahref="#dfn-active-worker">active worker</a>.</li>
3166
3171
<li>If <var>activeWorker</var>'s <ahref="#dfn-set-of-event-types-to-handle">set of event types to handle</a> does not contain <code>fetch</code>, return null.
3167
-
<pclass="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>
3172
+
<pclass="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 very first script execution.</p>
3168
3173
</li>
3169
3174
<li>If <var>activeWorker</var>'s <ahref="#dfn-state">state</a> is <em>activating</em>, wait for <var>activeWorker</var>'s <ahref="#dfn-state">state</a> to become <em>activated</em>.</li>
3170
3175
<li>Invoke <ahref="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>activeWorker</var> as the argument.</li>
<li><ahref="http://www.ecma-international.org/ecma-262/6.0/#sec-algorithm-conventions">Assert</a>: a <ahref="http://www.ecma-international.org/ecma-262/6.0/#sec-list-and-record-specification-type">Record</a> with the [[value]] equals to <var>registration</var> is contained in <ahref="#dfn-scope-to-registration-map">scope to registration map</a>.</li>
3255
3260
<li><ahref="http://www.ecma-international.org/ecma-262/6.0/#sec-algorithm-conventions">Assert</a>: <var>registration</var>'s <ahref="#dfn-active-worker">active worker</a> is not null.</li>
3256
3261
<li>Let <var>activeWorker</var> be <var>registration</var>'s <ahref="#dfn-active-worker">active worker</a>.</li>
3262
+
<li>If <var>activeWorker</var>'s <ahref="#dfn-set-of-event-types-to-handle">set of event types to handle</a> does not contain the event type for this functional event, return.
3263
+
<pclass="note">To avoid unnecessary delays, the Handle Functional Event enforces early return when no event listeners have been deterministically added in the service worker's global during the very first script execution.</p>
3264
+
</li>
3257
3265
<li>If <var>activeWorker</var>'s <ahref="#dfn-state">state</a> is <em>activating</em>, wait for <var>activeWorker</var>'s <ahref="#dfn-state">state</a> to become <em>activated</em>.</li>
3258
3266
<li>Invoke <ahref="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>activeWorker</var> as the argument.</li>
3259
3267
<li><ahref="https://html.spec.whatwg.org/multipage/webappapis.html#queue-a-task">Queue a task</a><var>task</var> to invoke <var>callbackSteps</var> with <var>activeWorker</var>'s <ahref="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object"> environment settings object</a>'s <ahref="https://html.spec.whatwg.org/multipage/webappapis.html#global-object">global object</a> as its argument.
0 commit comments