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
<li>Let <var>client</var> be the <a>context object</a>'s <a href="#dfn-service-worker-container-interface-client">service worker client</a>.</li>
779
789
<li>If <var>client</var> is not a <a>secure context</a>, reject <var>p</var> with a "{{SecurityError}}" exception and abort these steps.</li>
780
790
<li>Let <var>scriptURL</var> be the result of <a for="url">parsing</a><var>scriptURL</var> with <a>entry settings object</a>'s <a>API base URL</a>.</li>
781
-
<li>If <var>scriptURL</var> is failure, reject <var>p</var> with a <code>TypeError</code> and abort these steps.</li>
782
-
<li>If <var>scriptURL</var>'s <a for="url">scheme</a> is not one of "<code>http</code>" and "<code>https</code>", reject <var>p</var> with a <code>TypeError</code> and abort these steps.</li>
783
-
<li>If any of the strings in <var>scriptURL</var>'s <a for="url">path</a> contains either <a>ASCII case-insensitive</a> "<code>%2f</code>" or <a>ASCII case-insensitive</a> "<code>%5c</code>", reject <var>p</var> with a <code>TypeError</code> and abort these steps.</li>
784
-
<li>Let <var>scopeURL</var> be null.</li>
785
-
<li>If <var>options</var>.{{RegistrationOptions/scope}} is <a lt="present">not present</a>, set <var>scopeURL</var> to the result of <a for="url">parsing</a> a string "<code>./</code>" with <var>scriptURL</var>.
786
-
<p class="note">The scope url for the registration is set to the location of the service worker script by default.</p>
787
-
</li>
788
-
<li>Else, set <var>scopeURL</var> to the result of <a for="url">parsing</a><var>options</var>.{{RegistrationOptions/scope}} with <a>entry settings object</a>'s <a>API base URL</a>.</li>
789
-
<li>If <var>scopeURL</var> is failure, reject <var>p</var> with a <code>TypeError</code> and abort these steps.</li>
790
-
<li>If <var>scopeURL</var>'s <a for="url">scheme</a> is not one of "<code>http</code>" and "<code>https</code>", reject <var>p</var> with a <code>TypeError</code> and abort these steps.</li>
791
-
<li>If any of the strings in <var>scopeURL</var>'s <a for="url">path</a> contains either <a>ASCII case-insensitive</a> "<code>%2f</code>" or <a>ASCII case-insensitive</a> "<code>%5c</code>", reject <var>p</var> with a <code>TypeError</code> and abort these steps.</li>
792
-
<li>Let <var>job</var> be the result of running <a href="#create-job-algorithm">Create Job</a> with <em>register</em>, <var>scopeURL</var>, <var>scriptURL</var>, <var>p</var>, and <var>client</var>'s <a>creation URL</a>.</li>
793
-
<li>Set <var>job</var>'s <a>worker type</a> to <var>options</var>.{{RegistrationOptions/type}}.</li>
794
-
<li>Invoke <a href="#schedule-job-algorithm">Schedule Job</a> with <var>job</var>.</li>
791
+
<li>Invoke [[#start-register-algorithm]] with <var>scopeURL</var>, <var>scriptURL</var>, <var>p</var>, <var>client</var>'s <a>creation URL</a> and <var>options</var>.{{RegistrationOptions/type}}.</li>
<h2 id="link-type-serviceworker">Link type "<code>serviceworker</code>"</h2>
2048
+
<p>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 <a for="service worker registration">service worker registration</a> and its <a for="service worker registration">scope url</a>.</p>
2049
+
2050
+
<section>
2051
+
<h3 id="link-element-processing">Processing</h3>
2052
+
2053
+
<p>When a user agent that supports [[!RFC5988]] processes a <code>Link</code> header that contains a <a>serviceworker link</a>, the user agent <em class="rfc2119" title="SHOULD">should</em> run these steps or their <a href="#dfn-processing-equivalence">equivalent</a>:</p>
2054
+
2055
+
<ol>
2056
+
<li>If the <code>Link</code> header has an "<code>anchor</code>" parameter, abort these steps.</li>
2057
+
<li>Let <var>contextURL</var> be the result of <a for="url">parsing</a> the <a>context IRI</a> of the <code>Link</code> header.</li>
2058
+
<li>If the result of running <a>Is origin potentially trustworthy</a> with the <a for="resource">origin</a> of <var>contextURL</var> is <code>Not Trusted</code>, abort these steps.</li>
2059
+
<li>Let <var>request</var> be the <a for="fetch">request</a> for which this header was received in the response.</li>
2060
+
<li>If <var>request</var>'s <a for="request">client</a> is not a <a>secure context</a>, abort these steps.</li>
2061
+
<li>Let <var>scriptURL</var> be the result of <a for="url">parsing</a> the <a>target IRI</a> of the <code>Link</code> header.</li>
2062
+
<li>Let <var>scopeURL</var> be the "<code>scope</code>" <a>target attribute</a> of the <code>Link</code> header, or null if no such attribute is present.</li>
2063
+
<li>Invoke [[#start-register-algorithm]] with <var>scopeURL</var>, <var>scriptURL</var>, a new <a>promise</a>, null, and <var>contextURL</var>'s <a for="resource">origin</a>.</li>
2064
+
<!-- TODO: worker type -->
2065
+
</ol>
2066
+
2067
+
<p>When a <a>serviceworker link</a>'s <{link}> element is <a lt="in a document">inserted into a document</a>, a <a>serviceworker link</a> is created on a <{link}> element that is already <a>in a Document</a>, or the <{link/href}> or <{link/scope}> attributes of the <{link}> element of a <a>serviceworker link</a> is changed, the user agent <em class="rfc2119" title="SHOULD">should</em> run these steps or their <a href="#dfn-processing-equivalence">equivalent</a>:</p>
2068
+
2069
+
<ol>
2070
+
<li>If the <{link/href}> attribute is the empty string, abort these steps.</li>
2071
+
<li>Let <var>client</var> be the document's <a for="ServiceWorkerContainer">service worker client</a>.</li>
2072
+
<li>If <var>client</var> is not a <a>secure context</a>, <a>queue a task</a> to <a>fire a simple event</a> named <code>error</code> at the <{link}> element, and abort these steps.</li>
2073
+
<li>Let <var>scriptURL</var> be the result of <a for="url">parsing</a> the <{link/href}> attribute with document's <a>document base URL</a>.</li>
2074
+
<li>Let <var>scopeURL</var> be the <{link/scope}> attribute, or null if the <{link/scope}> attribute is omitted.</li>
2075
+
<li>Let <var>promise</var> be a new <a>promise</a>.</li>
2076
+
<li>Invoke [[#start-register-algorithm]] with <var>scopeURL</var>, <var>scriptURL</var>, <var>promise</var>, <var>client</var>, and <var>client</var>'s <a for="resource">origin</a>.</li>
2077
+
<!-- TODO: worker type -->
2078
+
<li>Run the following substeps <a>in parallel</a>:
2079
+
<ol>
2080
+
<li>Wait until <var>promise</var> settles.</li>
2081
+
<li>If <var>promise</var> rejected, <a>queue a task</a> to <a>fire a simple event</a> named <code>error</code> at the <{link}> element.</li>
2082
+
<li>If <var>promise</var> resolved, <a>queue a task</a> to <a>fire a simple event</a> named <code>load</code> at the <{link}> element.</li>
2083
+
</ol>
2084
+
</li>
2085
+
</ol>
2086
+
2087
+
<p>The <a href="#dfn-serviceworker-link">serviceworker link</a> element <em class="rfc2119" title="MUST NOT">must not</em><a href="https://html.spec.whatwg.org/multipage/syntax.html#delay-the-load-event">delay the load event</a> of the element's <a href="https://dom.spec.whatwg.org/#concept-node-document">node document</a>.</p>
2088
+
2089
+
<div class="example">
2090
+
A resource being loaded with the following response header:
<h3 id="link-element-interface-section">Link element interface extensions</h3>
2107
+
2108
+
<pre class="idl">
2109
+
partial interface HTMLLinkElement {
2110
+
attribute USVString scope;
2111
+
};
2112
+
</pre>
2113
+
2114
+
<p>The <dfn id="link-scope-attribute">scope</dfn> attribute returns the value of this element's <dfn element-attr for="link">scope</dfn> attribute.</p>
<dd><var>scriptURL</var>, a <a for="url">URL</a></dd>
3106
+
<dd><var>promise</var>, a <a>promise</a></dd>
3107
+
<dd><var>referrer</var>, a <a for=url>URL</a></dd>
3108
+
<dd><var>workerType</var>, a <a>worker type</a></dd>
3109
+
<dt>Output</dt>
3110
+
<dd>none</dd>
3111
+
</dl>
3112
+
<ol>
3113
+
<li>If <var>scriptURL</var> is failure, reject <var>promise</var> with a <code>TypeError</code> and abort these steps.</li>
3114
+
<li>If <var>scriptURL</var>'s <a for="url">scheme</a> is not one of "<code>http</code>" and "<code>https</code>", reject <var>promise</var> with a <code>TypeError</code> and abort these steps.</li>
3115
+
<li>If any of the strings in <var>scriptURL</var>'s <a for="url">path</a> contains either <a>ASCII case-insensitive</a> "<code>%2f</code>" or <a>ASCII case-insensitive</a> "<code>%5c</code>", reject <var>promise</var> with a <code>TypeError</code> and abort these steps.</li>
3116
+
<li>Let <var>scopeURL</var> be null.</li>
3117
+
<li>If <var>scopeURLString</var> is null, set <var>scopeURL</var> to the result of <a for="url">parsing</a> a string "<code>./</code>" with <var>scriptURL</var>.
3118
+
<p class="note">The scope url for the registration is set to the location of the service worker script by default.</p>
3119
+
</li>
3120
+
<li>Else, set <var>scopeURL</var> to the result of <a for="url">parsing</a><var>scopeURLString</var> with <a>entry settings object</a>'s <a>API base URL</a>.</li>
3121
+
<li>If <var>scopeURL</var> is failure, reject <var>promise</var> with a <code>TypeError</code> and abort these steps.</li>
3122
+
<li>If <var>scopeURL</var>'s <a for="url">scheme</a> is not one of "<code>http</code>" and "<code>https</code>", reject <var>promise</var> with a <code>TypeError</code> and abort these steps.</li>
3123
+
<li>If any of the strings in <var>scopeURL</var>'s <a for="url">path</a> contains either <a>ASCII case-insensitive</a> "<code>%2f</code>" or <a>ASCII case-insensitive</a> "<code>%5c</code>", reject <var>promise</var> with a <code>TypeError</code> and abort these steps.</li>
3124
+
<li>Let <var>job</var> be the result of running [[#create-job-algorithm]] with <em>register</em>, <var>scopeURL</var>, <var>scriptURL</var>, <var>promise</var>, and <var>referrer</var>.</li>
3125
+
<li>Set <var>job</var>'s <a>worker type</a> to <var>workerType</var>.</li>
3126
+
<li>Invoke [[#schedule-job-algorithm]] with <var>job</var>.</li>
<li>If the <a for="resource">origin</a> of <var>job</var>'s <a href="#dfn-job-scope-url">scope url</a> is not <var>job</var>'s <a for=job>referrer</a>'s <a for="resource">origin</a>, then:
3054
-
<ol>
3055
-
<li>Invoke <a href="#reject-job-promise-algorithm">Reject Job Promise</a> with <var>job</var> and a "{{SecurityError}}" exception.</li>
3056
-
<li>Invoke <a href="#finish-job-algorithm">Finish Job</a> with <var>job</var> and abort these steps.</li>
3057
-
</ol>
3058
-
</li>
3059
3153
<li>Let <var>registration</var> be the result of running the <a href="#get-registration-algorithm">Get Registration</a> algorithm passing <var>job</var>'s <a href="#dfn-job-scope-url">scope url</a> as the argument.</li>
0 commit comments