Skip to content

Commit 6708bc8

Browse files
mgiucaMarcos Cáceres
authored andcommitted
Make Service Worker registration work properly (don't use outdated steps) (#792)
1 parent e46df46 commit 6708bc8

File tree

1 file changed

+63
-42
lines changed

1 file changed

+63
-42
lines changed

index.html

Lines changed: 63 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
}
130130
</style>
131131
</head>
132-
<body data-cite="ENCODING">
132+
<body data-cite="ENCODING SERVICE-WORKERS">
133133
<section id='abstract'>
134134
<p>
135135
This specification defines a JSON-based manifest file that provides
@@ -222,7 +222,7 @@ <h3>
222222
"orientation": "landscape",
223223
"theme_color": "aliceblue",
224224
"background_color": "red",
225-
"serviceworker": {
225+
"serviceworker":
226226
"src": "sw.js",
227227
"scope": "/racer/",
228228
"update_via_cache": "none"
@@ -383,26 +383,14 @@ <h3>
383383
following algorithm:
384384
</p>
385385
<ol>
386-
<li>Let <var>manifest</var> and <var>manifest URL</var> be the values
387-
that were created during <a>steps to determine installability of the
388-
document</a>.
386+
<li>Let <var>manifest</var> be the manifest value created during <a>
387+
steps to determine installability of the document</a>.
389388
</li>
390-
<li>If <var>manifest URL</var> exists, and the result of running <a>
391-
processing the `serviceworker` member</a> with <var>manifest</var>
392-
returns a valid <var>registration</var>, the user agent MAY:
393-
<ol>
394-
<li>Let <var>client</var> be the <a>top-level browsing
395-
context</a> {{Document}}'s <a>relevant settings object</a>, or
396-
<code>null</code> if unavailable.
397-
</li>
398-
<li>Invoke <a>Start Register</a> with <var>scope</var> and <var>
399-
src</var> members of the <var>registration</var>, a new
400-
<var>promise</var>, <var>client</var>, <var>manifest URL</var>,
401-
plus the <var>type</var> and <var>update_via_cache</var>
402-
members of the <var>registration</var>. If the settled
403-
<var>promise</var> is rejected, abort these steps.
404-
</li>
405-
</ol>
389+
<li>If |manifest|.{{WebAppManifest/serviceworker}} is not
390+
<code>undefined</code>, the user agent MAY run the <a>steps for
391+
registering a manifest's service worker</a> with
392+
|manifest|.{{WebAppManifest/serviceworker}}. If those steps return
393+
failure, abort these steps.
406394
</li>
407395
<li>Perform an unspecified sequence of actions to attempt to register
408396
the web application in the user's operating system (e.g., create
@@ -419,7 +407,6 @@ <h3>
419407
context</a> for which the installation took place.
420408
</li>
421409
</ol>
422-
<div class="issue" data-number="789"></div>
423410
</section>
424411
<section>
425412
<!-- TODO(mgiuca): Move this section up above Installation process. (In
@@ -2137,6 +2124,55 @@ <h3>
21372124
}
21382125
</pre>
21392126
</div>
2127+
<p>
2128+
The <dfn>steps for registering a manifest's service worker</dfn> are
2129+
given by the following algorithm, which takes a
2130+
{{ServiceWorkerRegistrationObject}} <var>registration</var> and
2131+
returns success or failure.
2132+
</p>
2133+
<ol>
2134+
<li>Let <var>serviceWorker</var> be the {{ServiceWorkerContainer}}
2135+
associated with the <a>top-level browsing context</a>. If there is
2136+
none, return failure.
2137+
</li>
2138+
<li>Let <var>options</var> be the result of running the <a>steps for
2139+
converting a service worker registration to an options dictionary</a>
2140+
on <var>registration</var>.
2141+
</li>
2142+
<li>Let <var>promise</var> be the result of invoking
2143+
|serviceWorker|.{{ServiceWorkerContainer/register()}} with arguments
2144+
|registration|.{{ServiceWorkerRegistrationObject/src}} and
2145+
<var>options</var>.
2146+
</li>
2147+
<li>Wait until <var>promise</var> settles. If the settled
2148+
<var>promise</var> is rejected, return failure.
2149+
</li>
2150+
<li>Return success.
2151+
</li>
2152+
</ol>
2153+
<p>
2154+
The <dfn>steps for converting a service worker registration to an
2155+
options dictionary</dfn> are given by the following algorithm. The
2156+
algorithm takes a {{ServiceWorkerRegistrationObject}}
2157+
<var>registration</var>, and returns a {{RegistrationOptions}}
2158+
dictionary which is suitable to pass to
2159+
{{ServiceWorkerContainer}}.{{ServiceWorkerContainer/register()}}.
2160+
</p>
2161+
<ol>
2162+
<li>Create a new {{RegistrationOptions}} <var>options</var>.
2163+
</li>
2164+
<li>Set |options|.{{RegistrationOptions/scope}} to
2165+
|registration|.{{ServiceWorkerRegistrationObject/scope}}.
2166+
</li>
2167+
<li>Set |options|.{{RegistrationOptions/type}} to
2168+
|registration|.{{ServiceWorkerRegistrationObject/type}}.
2169+
</li>
2170+
<li>Set |options|.{{RegistrationOptions/updateViaCache}} to
2171+
|registration|.{{ServiceWorkerRegistrationObject/update_via_cache}}.
2172+
</li>
2173+
<li>Return <var>options</var>.
2174+
</li>
2175+
</ol>
21402176
</section>
21412177
<section>
21422178
<h3>
@@ -3236,7 +3272,8 @@ <h3>
32363272
</h3>
32373273
<p>
32383274
The <a>scope</a> member of a <a>ServiceWorkerRegistrationObject</a>
3239-
dictionary is the service worker's associated <a>scope URL</a>.
3275+
dictionary is the service worker's associated <a data-cite=
3276+
"service-workers-1#dfn-scope-url">scope URL</a>.
32403277
</p>
32413278
<p>
32423279
The steps for <dfn>processing the <code>scope</code> member of a
@@ -3276,7 +3313,7 @@ <h3>
32763313
<a>ServiceWorkerRegistrationObject</a> dictionary determines the
32773314
<a data-cite="service-workers-1#dfn-update-via-cache">update via
32783315
cache mode</a> for the service worker. The possible values are those
3279-
of the <a>ServiceWorkerUpdateViaCache</a> enum defined in
3316+
of the {{ServiceWorkerUpdateViaCache}} enum defined in
32803317
[[SERVICE-WORKERS-1]].
32813318
</p>
32823319
</section>
@@ -3988,23 +4025,6 @@ <h3>
39884025
</li>
39894026
</ul>
39904027
</li>
3991-
<li>[[SERVICE-WORKERS-1]] defines the following terms:
3992-
<ul>
3993-
<li>
3994-
<a data-cite=
3995-
"service-workers-1#start-register-algorithm"><dfn>Start
3996-
Register</dfn></a>
3997-
</li>
3998-
<li>
3999-
<a data-cite="service-workers-1#dfn-scope-url"><dfn>scope
4000-
URL</dfn></a>
4001-
</li>
4002-
<li>
4003-
<a data-cite=
4004-
"service-workers-1#dfn-update-via-cache"><dfn>ServiceWorkerUpdateViaCache</dfn></a>
4005-
</li>
4006-
</ul>
4007-
</li>
40084028
<li>[[ECMA-402]] defines the following terms:
40094029
<ul>
40104030
<li>
@@ -4093,7 +4113,8 @@ <h3>
40934113
<ul>
40944114
<li>
40954115
<a data-cite=
4096-
"ECMASCRIPT#sec-ecmascript-data-types-and-values"><dfn>Type</dfn>(<var>x</var>)</a>
4116+
"ECMASCRIPT#sec-ecmascript-data-types-and-values"><dfn data-dfn-for="">
4117+
Type</dfn>(<var>x</var>)</a>
40974118
</li>
40984119
</ul>
40994120
</li>

0 commit comments

Comments
 (0)