Skip to content

Commit 7d7bcac

Browse files
committed
Use referrer policy language
Change SW to use referrer policy language (instead of using a url typed referrer source). The referrer policy value is stored along with fetched SW script, and this value is used to set the worker global scope's referrer policy when it's created. This patch also fixes plumbing of HTTPS state setup. Fixes #834.
1 parent eb7a693 commit 7d7bcac

File tree

4 files changed

+114
-60
lines changed

4 files changed

+114
-60
lines changed

docs/index.bs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ spec: fetch; urlPrefix: https://fetch.spec.whatwg.org/
145145
text: get a reader; url: concept-get-reader
146146
text: header; url: concept-header
147147
text: http fetch; url: concept-http-fetch
148+
text: HTTPS state value; url: concept-https-state-value
148149
text: internal response; url: concept-internal-response
149150
text: locked; url: concept-body-locked
150151
text: navigation request
@@ -187,6 +188,7 @@ spec: fetch; urlPrefix: https://fetch.spec.whatwg.org/
187188
text: cache state
188189
text: CORS-exposed header-name list
189190
text: header list
191+
text: https state
190192
text: response
191193
text: status
192194
text: termination reason
@@ -222,6 +224,7 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
222224
text: https state; for: environment settings object
223225
text: module script
224226
text: realm execution context
227+
text: referrer policy; for: environment settings object; url: concept-settings-object-referrer-policy
225228
text: relevant Realm; url: concept-relevant-realm
226229
text: relevant global object; url: concept-relevant-global
227230
text: report the error
@@ -243,6 +246,7 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
243246
text: web worker; url: workers
244247
for: workerglobalscope; urlPrefix: #concept-workerglobalscope-
245248
text: https state
249+
text: referrer policy
246250
text: type
247251
text: url
248252
type: event
@@ -333,7 +337,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
333337
<p>A <a href="#dfn-service-worker">service worker</a> has an associated <dfn id="dfn-containing-service-worker-registration">containing service worker registration</dfn> (a <a href="#dfn-service-worker-registration">service worker registration</a>), which contains itself.</p>
334338
<p>A <a href="#dfn-service-worker">service worker</a> has an associated <dfn id="dfn-service-worker-id">id</dfn> (an opaque string), which uniquely identifies itself during the lifetime of its <a href="#dfn-containing-service-worker-registration">containing service worker registration</a>.</p>
335339
<p>A <a href="#dfn-service-worker">service worker</a> is dispatched a set of <dfn id="dfn-lifecycle-events">lifecycle events</dfn>, <a href="#service-worker-global-scope-install-event">install</a> and <a href="#service-worker-global-scope-activate-event">activate</a>, and <dfn id="dfn-functional-events">functional events</dfn> including <a href="#service-worker-global-scope-fetch-event">fetch</a>.</p>
336-
<p>A <a href="#dfn-service-worker">service worker</a> has an associated <dfn id="dfn-script-resource">script resource</dfn> (a <a>script</a>), which represents its own script resource. It is initially set to null. A <a href="#dfn-script-resource">script resource</a> has an associated <dfn id="dfn-has-ever-been-evaluated-flag">has ever been evaluated flag</dfn>. It is initially unset. A <a href="#dfn-script-resource">script resource</a> has an associated <dfn id="dfn-https-state">HTTPS state</dfn> which is "<code>none</code>", "<code>deprecated</code>", or "<code>modern</code>". Unless stated otherwise, it is "<code>none</code>".</p>
340+
<p>A <a href="#dfn-service-worker">service worker</a> has an associated <dfn id="dfn-script-resource">script resource</dfn> (a <a>script</a>), which represents its own script resource. It is initially set to null. A <a href="#dfn-script-resource">script resource</a> has an associated <dfn id="dfn-has-ever-been-evaluated-flag">has ever been evaluated flag</dfn>. It is initially unset. A <a href="#dfn-script-resource">script resource</a> has an associated <dfn id="dfn-https-state">HTTPS state</dfn> (an <a>HTTPS state value</a>). It is initially "<code>none</code>". A <a href="#dfn-script-resource">script resource</a> has an associated <dfn id="dfn-referrer-policy">referrer policy</dfn> (a <a href="https://w3c.github.io/webappsec-referrer-policy/#referrer-policy">referrer policy</a>). It is initially the empty string.</p>
337341
<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>List</a> of the <a>Record</a> {\[[key]], \[[value]]} where \[[key]] is a <a for="url">URL</a> and \[[value]] is a <a for="response">response</a>.</p>
338342
<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>
339343
<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>
@@ -3241,6 +3245,8 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
32413245
<li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.</li>
32423246
</ol>
32433247
</li>
3248+
<li>Let <var>httpsState</var> be "<code>none</code>".</li>
3249+
<li>Let <var>referrerPolicy</var> be the empty string.</li>
32443250
<li>Switching on <var>job</var>'s <a>worker type</a>, run these substeps with the following options:
32453251
<dl>
32463252
<dt><em>"<code>classic</code>"</em></dt>
@@ -3270,6 +3276,8 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
32703276
<li>Let <var>serviceWorkerAllowed</var> be the result of <a for="header">parsing</a> `<code>Service-Worker-Allowed</code>` in <var>response</var>'s <a for="response">header list</a>.
32713277
<p class="note">See the definition of the Service-Worker-Allowed header in Appendix B: Extended HTTP headers.</p>
32723278
</li>
3279+
<li>Set <var>httpsState</var> to <var>response</var>'s <a for="response">HTTPS state</a>.</li>
3280+
<li>Set <var>referrerPolicy</var> to the result of <a href="https://w3c.github.io/webappsec-referrer-policy/#parse-referrer-policy-from-header">parsing the `<code>Referrer-Policy</code>` header</a> of <var>response</var>.</li>
32733281
<li>If <var>serviceWorkerAllowed</var> is failure, then:
32743282
<ol>
32753283
<li>Asynchronously complete these steps with a <a>network error</a>.</li>
@@ -3325,6 +3333,8 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
33253333
<li>Let <var>worker</var> be a new <a href="#dfn-service-worker">service worker</a>.</li>
33263334
<li>Generate a unique opaque string and set <var>worker</var>'s <a href="#dfn-service-worker-id">id</a> to the value.</li>
33273335
<li>Set <var>worker</var>'s <a href="#dfn-script-url">script url</a> to <var>job</var>'s <a href="#dfn-job-script-url">script url</a>, <var>worker</var>'s <a href="#dfn-script-resource">script resource</a> to <var>script</var>, and <var>worker</var>'s <a href="#dfn-type">type</a> to <var>job</var>'s <a>worker type</a>.</li>
3336+
<li>Set <var>worker</var>'s <a href="#dfn-script-resource">script resource</a>'s <a href="#dfn-https-state">HTTPS state</a> to <var>httpsState</var>.</li>
3337+
<li>Set <var>worker</var>'s <a href="#dfn-script-resource">script resource</a>'s <a href="#dfn-referrer-policy">referrer policy</a> to <var>referrerPolicy</var>.</li>
33283338
<li>Invoke <a href="#run-service-worker-algorithm">Run Service Worker</a> algorithm with <var>worker</var> as the argument.</li>
33293339
<li>If an uncaught runtime script error occurs during the above step, then:
33303340
<ol>
@@ -3517,9 +3527,8 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
35173527
<dd>Return <var>workerGlobalScope</var>.</dd>
35183528
<dt>The <a>responsible event loop</a></dt>
35193529
<dd>Return <var>workerEventLoop</var>.</dd>
3520-
<dt>The <a>referrer source</a></dt>
3521-
<dd>Return <var>serviceWorker</var>'s <a href="#dfn-script-url">script url</a>.</dd>
3522-
<p class="issue">Remove this definition after sorting out the referencing sites.</p>
3530+
<dt>The <a for="environment settings object">referrer policy</a></dt>
3531+
<dd>Return <var>workerGlobalScope</var>'s <a for="workerglobalscope">referrer policy</a>.</dd>
35233532
<dt>The <a>API URL character encoding</a></dt>
35243533
<dd>Return UTF-8.</dd>
35253534
<dt>The <a>API base URL</a></dt>
@@ -3534,6 +3543,7 @@ spec: webidl; urlPrefix: https://heycam.github.io/webidl/
35343543
</li>
35353544
<li>Set <var>workerGlobalScope</var>'s <a for="workerglobalscope">url</a> to <var>serviceWorker</var>'s <a href="#dfn-script-url">script url</a>.</li>
35363545
<li>Set <var>workerGlobalScope</var>'s <a for="workerglobalscope">HTTPS state</a> to <var>serviceWorker</var>'s <a>script resource</a>'s <a href="#dfn-https-state">HTTPS state</a>.</li>
3546+
<li>Set <var>workerGlobalScope</var>'s <a for="workerglobalscope">referrer policy</a> to <var>serviceWorker</var>'s <a>script resource</a>'s <a href="#dfn-referrer-policy">referrer policy</a>.</li>
35373547
<li>Set <var>workerGlobalScope</var>'s <a for="workerglobalscope">type</a> to <var>serviceWorker</var>'s <a href="#dfn-type">type</a>.</li>
35383548
<li>Create a new {{WorkerLocation}} object and associate it with <var>workerGlobalScope</var>.</li>
35393549
<li>If <var>serviceWorker</var> is an <a href="#dfn-active-worker">active worker</a>, and there are any <a>tasks</a> queued in <var>serviceWorker</var>'s <a href="#dfn-containing-service-worker-registration">containing service worker registration</a>'s <a href="#dfn-service-worker-registration-task-queue">task queues</a>, <a lt="queue a task">queue</a> them to <var>serviceWorker</var>'s <a>event loop</a>'s <a for="event loop">task queues</a> in the same order using their original <a>task sources</a>.</li>

0 commit comments

Comments
 (0)