Skip to content

Commit f8e8103

Browse files
sideshowbarkerjungkees
authored andcommitted
Update the “Link type "serviceworker"” section (#1110)
* Add new section “Declaring a "serviceworker" Link header” * Drop normative requirement to fire an error if link[workertype] value isn’t a valid worker type; instead just abort. * Drop the partial interface IDL for the HTMLLinkElement interface (the definitions for the IDL attributes have already been merged directly into the HTMLLinkElement interface IDL definition in the HTML spec). Fixes #1073
1 parent fa1f95c commit f8e8103

File tree

2 files changed

+125
-152
lines changed

2 files changed

+125
-152
lines changed

docs/index.bs

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ spec: rfc5988; urlPrefix: https://tools.ietf.org/html/rfc5988
8686
type: dfn
8787
text: context IRI; url: section-5.2
8888
text: target attribute; url: section-5.4
89+
text: target attributes; url: section-5.4
8990
text: target IRI; url: section-5.1
9091

9192
spec: rfc7230; urlPrefix: https://tools.ietf.org/html/rfc7230
@@ -1769,12 +1770,36 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
17691770
</section>
17701771

17711772
<section>
1772-
<h2 id="link-type-serviceworker">Link type "<code>serviceworker</code>"</h2>
1773+
<h2 id="link-type-serviceworker">Link type "`serviceworker`"</h2>
17731774

1774-
The <dfn id="dfn-link-type-serviceworker" lt="serviceworker link type"><code>serviceworker</code></dfn> keyword may be used with <{link}> elements. This keyword creates an <a>external resource link</a> (<dfn id="dfn-serviceworker-link">serviceworker link</dfn>) that is used to declare a [=/service worker registration=] and its [=service worker registration/scope url=].
1775+
A [=/service worker registration=] and its [=service worker registration/scope url=] are created by a <dfn id="dfn-serviceworker-link">serviceworker link</dfn>, which is declared using a <a href="#serviceworker-link-header">"serviceworker" `Link` header</a> or a <{link}> element whose <{link/rel}> attribute contains the keyword "<{link/rel/serviceworker}>".
17751776

17761777
<section>
1777-
<h3 id="link-header-processing">Processing the <code>Link</code> header</h3>
1778+
<h3 id="serviceworker-link-header">Declaring a "serviceworker" <code>Link</code> header</h3>
1779+
1780+
A <a>serviceworker link</a> can be declared using a `Link` header</a> [[!RFC5988]] with "`serviceworker`" as the value of the "`rel`" parameter and a [=URL serializer|serialized=] [=service worker/script url=] inside angle brackets ("`<>`") as the <a>target IRI</a>, and the following optional <a>target attributes</a>:
1781+
1782+
: `scope`
1783+
:: Value: A [=URL serializer|serialized=] [=service worker registration/scope url=].
1784+
1785+
: `workertype`
1786+
:: Value: A [=job/worker type=].
1787+
1788+
: `updateviacache`
1789+
:: Value: An [=service worker registration/update via cache mode=].
1790+
1791+
The "`anchor`" parameter must not be specified.
1792+
1793+
<div class="example">
1794+
<pre class="highlight">
1795+
Link: &lt;sw.js&gt;; rel="serviceworker"; scope="/"; workertype="module"; updateviacache="all"
1796+
</pre>
1797+
</div>
1798+
1799+
</section>
1800+
1801+
<section>
1802+
<h3 id="link-header-processing">Processing a "serviceworker" <code>Link</code> header</h3>
17781803

17791804
When a user agent that supports [[!RFC5988]] processes a <code>Link</code> header that contains a <a>serviceworker link</a>, the user agent *should* run these steps:
17801805

@@ -1793,7 +1818,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
17931818
</section>
17941819

17951820
<section>
1796-
<h3 id="link-element-processing">Processing the <{link}> element</h3>
1821+
<h3 id="link-element-processing">Processing a "serviceworker" <{link}> element</h3>
17971822

17981823
When a <a>serviceworker link</a>'s <{link}> element is <a>inserted into a document</a>, or a <a>serviceworker link</a> is created on a <{link}> element that is already <a>in a document tree</a>, or the <{link/href}>, <{link/scope}>, or <{link/updateviacache}> attributes of the <{link}> element of a <a>serviceworker link</a> is changed, the user agent *should* run these steps:
17991824

@@ -1803,8 +1828,8 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
18031828
1. Let |scriptURL| be the result of <a lt="URL parser">parsing</a> the <{link/href}> attribute with the <{link}> element's <a>node document</a>'s <a>document base URL</a>.
18041829
1. Let |scopeURL| be null.
18051830
1. If the <{link/scope}> attribute is present, set |scopeURL| to the result of <a lt="URL parser">parsing</a> the <{link/scope}> attribute with the <{link}> element's <a>node document</a>'s <a>document base URL</a>.
1806-
1. Let |workerType| be the <{link/workertype}> attribute, or "<code>classic</code>" if the <{link/workertype}> attribute is omitted.
1807-
1. If |workerType| is not a valid {{WorkerType}} value, <a>queue a task</a> to <a>fire an event</a> named <code>error</code> at the <{link}> element, and abort these steps.
1831+
1. Let |workerType| be the state of the <{link/workertype}> attribute.
1832+
1. If |workerType| is <i>invalid</i>, abort these steps.
18081833
1. Let |updateViaCache| be the <{link/updateviacache}> attribute, or "`imports`" if the <{link/updateviacache}> attribute is omitted.
18091834
1. Let |promise| be a new <a>promise</a>.
18101835
1. Invoke [=Start Register=] with |scopeURL|, |scriptURL|, |promise|, |client|, |client|'s <a>creation URL</a>, |workerType|, and |updateViaCache|.
@@ -1836,24 +1861,6 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
18361861
</pre>
18371862
</div>
18381863
</section>
1839-
1840-
<section>
1841-
<h3 id="link-element-interface-extensions">Link element interface extensions</h3>
1842-
1843-
<pre class="idl">
1844-
partial interface HTMLLinkElement {
1845-
[CEReactions] attribute USVString scope;
1846-
[CEReactions] attribute WorkerType workerType;
1847-
[CEReactions] attribute ServiceWorkerUpdateViaCache updateViaCache;
1848-
};
1849-
</pre>
1850-
1851-
The <dfn attribute for="HTMLLinkElement" id="link-scope-attribute">scope</dfn> IDL attribute must <a>reflect</a> the element's <dfn element-attr for="link">scope</dfn> content attribute.
1852-
1853-
The <dfn attribute for="HTMLLinkElement" id="link-workertype-attribute">workerType</dfn> IDL attribute must <a>reflect</a> the element's <dfn element-attr for="link">workertype</dfn> content attribute.
1854-
1855-
The <dfn attribute for="HTMLLinkElement" id="link-updateviacache-attribute">updateViaCache</dfn> IDL attribute must <a>reflect</a> the element's <dfn element-attr for="link">updateViaCache</dfn> content attribute.
1856-
</section>
18571864
</section>
18581865

18591866
<section>

0 commit comments

Comments
 (0)