Skip to content

Commit

Permalink
Fix the type of the key of the registration map
Browse files Browse the repository at this point in the history
This changes the type of the key of the scope to registration map from a
URL to a string. The algorithms that reference the scope to registration
map (including the Match Service Worker Registration) were correctly
using the keys as strings.

This changes the variable names in the Match Service Worker Registration
to clarify the types of the values of the variables.

(This doesn't affect any behavior.)

Fixes #1118.
  • Loading branch information
jungkees committed May 10, 2017
1 parent 1f54324 commit f259d18
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
16 changes: 8 additions & 8 deletions docs/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
<section>
<h4 id="service-worker-registration-lifetime">Lifetime</h4>

A user agent *must* persistently keep a list of <a>registered</a> [=/service worker registrations=] unless otherwise they are explicitly <a>unregistered</a>. A user agent has a <a>scope to registration map</a> that stores the entries of the tuple of [=/service worker registration=]'s [=service worker registration/scope url=] and the corresponding [=/service worker registration=]. The lifetime of [=/service worker registrations=] is beyond that of the {{ServiceWorkerRegistration}} objects which represent them within the lifetime of their corresponding [=/service worker clients=].
A user agent *must* persistently keep a list of <a>registered</a> [=/service worker registrations=] unless otherwise they are explicitly <a>unregistered</a>. A user agent has a <a>scope to registration map</a> that stores the entries of the tuple of [=/service worker registration=]'s [=service worker registration/scope url=], [=URL serializer|serialized=], and the corresponding [=/service worker registration=]. The lifetime of [=/service worker registrations=] is beyond that of the {{ServiceWorkerRegistration}} objects which represent them within the lifetime of their corresponding [=/service worker clients=].
</section>
</section>

Expand Down Expand Up @@ -2400,7 +2400,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

The following definitions are the user agent's internal data structures used throughout the specification.

A <dfn id="dfn-scope-to-registration-map">scope to registration map</dfn> is an <a>ordered map</a> where the keys are [=service worker registration/scope urls=] and the values are [=/service worker registrations=].
A <dfn id="dfn-scope-to-registration-map">scope to registration map</dfn> is an <a>ordered map</a> where the keys are [=service worker registration/scope urls=], [=URL serializer|serialized=], and the values are [=/service worker registrations=].

A <dfn id="dfn-job">job</dfn> is an abstraction of one of register, update, and unregister request for a [=/service worker registration=].

Expand Down Expand Up @@ -3341,15 +3341,15 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

1. Run the following steps atomically.
1. Let |clientURLString| be <a lt="URL serializer">serialized</a> |clientURL|.
1. Let |matchingScope| be the empty string.
1. Let |allScopes| be the result of [=map/get the keys|getting the keys=] from <a>scope to registration map</a>.
1. Set |matchingScope| to the longest value in |allScopes| which the value of |clientURLString| starts with, if it exists.
1. Let |matchingScopeString| be the empty string.
1. Let |scopeStringSet| be the result of [=map/get the keys|getting the keys=] from <a>scope to registration map</a>.
1. Set |matchingScopeString| to the longest value in |scopeStringSet| which the value of |clientURLString| starts with, if it exists.

Note: The URL string matching in this step is prefix-based rather than path-structural (e.g. a client URL string with "/prefix-of/resource.html" will match a registration for a scope with "/prefix").

1. Let |parsedMatchingScope| be null.
1. If |matchingScope| is not the empty string, set |parsedMatchingScope| to the result of <a lt="URL parser">parsing</a> |matchingScope|.
1. Let |registration| be the result of running <a>Get Registration</a> algorithm passing |parsedMatchingScope| as the argument.
1. Let |matchingScope| be null.
1. If |matchingScopeString| is not the empty string, set |matchingScope| to the result of <a lt="URL parser">parsing</a> |matchingScopeString|.
1. Let |registration| be the result of running <a>Get Registration</a> algorithm passing |matchingScope| as the argument.
1. If |registration| is not null and |registration|'s <a>uninstalling flag</a> is set, return null.
1. Return |registration|.
</section>
Expand Down
20 changes: 10 additions & 10 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@
}
}
</style>
<meta content="Bikeshed version 5bd73bb15eb04ad9f7d1a57f012e9ee6eca5a765" name="generator">
<meta content="Bikeshed version 3e4ecbe0ef0589381cdca6fa15e8ab0ea3856450" name="generator">
<link href="https://www.w3.org/TR/service-workers/" rel="canonical">
<style>/* style-md-lists */

Expand Down Expand Up @@ -1425,7 +1425,7 @@
<div class="head">
<p data-fill-with="logo"><a class="logo" href="https://www.w3.org/"> <img alt="W3C" height="48" src="https://www.w3.org/StyleSheets/TR/2016/logos/W3C" width="72"> </a> </p>
<h1 class="p-name no-ref" id="title">Service Workers Nightly</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="2017-05-04">4 May 2017</time></span></h2>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="2017-05-10">10 May 2017</time></span></h2>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:
Expand Down Expand Up @@ -1807,7 +1807,7 @@ <h3 class="heading settled" data-level="2.2" id="service-worker-registration-con
<p>A <a data-link-type="dfn" href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-18">service worker registration</a> has an associated <dfn class="dfn-paneled" data-dfn-for="service worker registration" data-dfn-type="dfn" data-export="" id="service-worker-registration-navigation-preload-header-value">navigation preload header value</dfn>, which is a <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#byte-sequence">byte sequence</a>. It is initially set to `<code>true</code>`.</p>
<section>
<h4 class="heading settled" data-level="2.2.1" id="service-worker-registration-lifetime"><span class="secno">2.2.1. </span><span class="content">Lifetime</span><a class="self-link" href="#service-worker-registration-lifetime"></a></h4>
<p>A user agent <em>must</em> persistently keep a list of <a data-link-type="dfn" href="#register" id="ref-for-register-1">registered</a> <a data-link-type="dfn" href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-19">service worker registrations</a> unless otherwise they are explicitly <a data-link-type="dfn" href="#unregister" id="ref-for-unregister-1">unregistered</a>. A user agent has a <a data-link-type="dfn" href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-1">scope to registration map</a> that stores the entries of the tuple of <a data-link-type="dfn" href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-20">service worker registration</a>'s <a data-link-type="dfn" href="#dfn-scope-url" id="ref-for-dfn-scope-url-4">scope url</a> and the corresponding <a data-link-type="dfn" href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-21">service worker registration</a>. The lifetime of <a data-link-type="dfn" href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-22">service worker registrations</a> is beyond that of the <code class="idl"><a data-link-type="idl" href="#serviceworkerregistration" id="ref-for-serviceworkerregistration-1">ServiceWorkerRegistration</a></code> objects which represent them within the lifetime of their corresponding <a data-link-type="dfn" href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-3">service worker clients</a>.</p>
<p>A user agent <em>must</em> persistently keep a list of <a data-link-type="dfn" href="#register" id="ref-for-register-1">registered</a> <a data-link-type="dfn" href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-19">service worker registrations</a> unless otherwise they are explicitly <a data-link-type="dfn" href="#unregister" id="ref-for-unregister-1">unregistered</a>. A user agent has a <a data-link-type="dfn" href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-1">scope to registration map</a> that stores the entries of the tuple of <a data-link-type="dfn" href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-20">service worker registration</a>'s <a data-link-type="dfn" href="#dfn-scope-url" id="ref-for-dfn-scope-url-4">scope url</a>, <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a>, and the corresponding <a data-link-type="dfn" href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-21">service worker registration</a>. The lifetime of <a data-link-type="dfn" href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-22">service worker registrations</a> is beyond that of the <code class="idl"><a data-link-type="idl" href="#serviceworkerregistration" id="ref-for-serviceworkerregistration-1">ServiceWorkerRegistration</a></code> objects which represent them within the lifetime of their corresponding <a data-link-type="dfn" href="#dfn-service-worker-client" id="ref-for-dfn-service-worker-client-3">service worker clients</a>.</p>
</section>
</section>
<section>
Expand Down Expand Up @@ -4566,7 +4566,7 @@ <h3 class="heading settled" data-level="8.4" id="request-functional-event-dispat
<section>
<h2 class="heading settled" id="algorithms"><span class="content">Appendix A: Algorithms</span><a class="self-link" href="#algorithms"></a></h2>
<p>The following definitions are the user agent’s internal data structures used throughout the specification.</p>
<p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-scope-to-registration-map">scope to registration map</dfn> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ordered-map">ordered map</a> where the keys are <a data-link-type="dfn" href="#dfn-scope-url" id="ref-for-dfn-scope-url-13">scope urls</a> and the values are <a data-link-type="dfn" href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-56">service worker registrations</a>.</p>
<p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-scope-to-registration-map">scope to registration map</dfn> is an <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#ordered-map">ordered map</a> where the keys are <a data-link-type="dfn" href="#dfn-scope-url" id="ref-for-dfn-scope-url-13">scope urls</a>, <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a>, and the values are <a data-link-type="dfn" href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-56">service worker registrations</a>.</p>
<p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="dfn-job">job</dfn> is an abstraction of one of register, update, and unregister request for a <a data-link-type="dfn" href="#dfn-service-worker-registration" id="ref-for-dfn-service-worker-registration-57">service worker registration</a>.</p>
<div>
A <a data-link-type="dfn" href="#dfn-job" id="ref-for-dfn-job-1">job</a> has a <dfn class="dfn-paneled" data-dfn-for="job" data-dfn-type="dfn" data-noexport="" id="dfn-job-type">job type</dfn>, which is one of <em>register</em>, <em>update</em>, and <em>unregister</em>.
Expand Down Expand Up @@ -6139,18 +6139,18 @@ <h3 class="heading settled" id="scope-match-algorithm"><span class="content"><df
<li data-md="">
<p>Let <var>clientURLString</var> be <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a> <var>clientURL</var>.</p>
<li data-md="">
<p>Let <var>matchingScope</var> be the empty string.</p>
<p>Let <var>matchingScopeString</var> be the empty string.</p>
<li data-md="">
<p>Let <var>allScopes</var> be the result of <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#map-getting-the-keys">getting the keys</a> from <a data-link-type="dfn" href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-11">scope to registration map</a>.</p>
<p>Let <var>scopeStringSet</var> be the result of <a data-link-type="dfn" href="https://infra.spec.whatwg.org/#map-getting-the-keys">getting the keys</a> from <a data-link-type="dfn" href="#dfn-scope-to-registration-map" id="ref-for-dfn-scope-to-registration-map-11">scope to registration map</a>.</p>
<li data-md="">
<p>Set <var>matchingScope</var> to the longest value in <var>allScopes</var> which the value of <var>clientURLString</var> starts with, if it exists.</p>
<p>Set <var>matchingScopeString</var> to the longest value in <var>scopeStringSet</var> which the value of <var>clientURLString</var> starts with, if it exists.</p>
<p class="note" role="note"><span>Note:</span> The URL string matching in this step is prefix-based rather than path-structural (e.g. a client URL string with "/prefix-of/resource.html" will match a registration for a scope with "/prefix").</p>
<li data-md="">
<p>Let <var>parsedMatchingScope</var> be null.</p>
<p>Let <var>matchingScope</var> be null.</p>
<li data-md="">
<p>If <var>matchingScope</var> is not the empty string, set <var>parsedMatchingScope</var> to the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">parsing</a> <var>matchingScope</var>.</p>
<p>If <var>matchingScopeString</var> is not the empty string, set <var>matchingScope</var> to the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">parsing</a> <var>matchingScopeString</var>.</p>
<li data-md="">
<p>Let <var>registration</var> be the result of running <a data-link-type="dfn" href="#get-registration" id="ref-for-get-registration-4">Get Registration</a> algorithm passing <var>parsedMatchingScope</var> as the argument.</p>
<p>Let <var>registration</var> be the result of running <a data-link-type="dfn" href="#get-registration" id="ref-for-get-registration-4">Get Registration</a> algorithm passing <var>matchingScope</var> as the argument.</p>
<li data-md="">
<p>If <var>registration</var> is not null and <var>registration</var>’s <a data-link-type="dfn" href="#dfn-uninstalling-flag" id="ref-for-dfn-uninstalling-flag-9">uninstalling flag</a> is set, return null.</p>
<li data-md="">
Expand Down
16 changes: 8 additions & 8 deletions docs/v1/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe
<section>
<h4 id="service-worker-registration-lifetime">Lifetime</h4>

A user agent *must* persistently keep a list of <a>registered</a> [=/service worker registrations=] unless otherwise they are explicitly <a>unregistered</a>. A user agent has a <a>scope to registration map</a> that stores the entries of the tuple of [=/service worker registration=]'s [=service worker registration/scope url=] and the corresponding [=/service worker registration=]. The lifetime of [=/service worker registrations=] is beyond that of the {{ServiceWorkerRegistration}} objects which represent them within the lifetime of their corresponding [=/service worker clients=].
A user agent *must* persistently keep a list of <a>registered</a> [=/service worker registrations=] unless otherwise they are explicitly <a>unregistered</a>. A user agent has a <a>scope to registration map</a> that stores the entries of the tuple of [=/service worker registration=]'s [=service worker registration/scope url=], [=URL serializer|serialized=], and the corresponding [=/service worker registration=]. The lifetime of [=/service worker registrations=] is beyond that of the {{ServiceWorkerRegistration}} objects which represent them within the lifetime of their corresponding [=/service worker clients=].
</section>
</section>

Expand Down Expand Up @@ -2054,7 +2054,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

The following definitions are the user agent's internal data structures used throughout the specification.

A <dfn id="dfn-scope-to-registration-map">scope to registration map</dfn> is an <a>ordered map</a> where the keys are [=service worker registration/scope urls=] and the values are [=/service worker registrations=].
A <dfn id="dfn-scope-to-registration-map">scope to registration map</dfn> is an <a>ordered map</a> where the keys are [=service worker registration/scope urls=], [=URL serializer|serialized=], and the values are [=/service worker registrations=].

A <dfn id="dfn-job">job</dfn> is an abstraction of one of register, update, and unregister request for a [=/service worker registration=].

Expand Down Expand Up @@ -2861,15 +2861,15 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe

1. Run the following steps atomically.
1. Let |clientURLString| be <a lt="URL serializer">serialized</a> |clientURL|.
1. Let |matchingScope| be the empty string.
1. Let |allScopes| be the result of [=map/get the keys|getting the keys=] from <a>scope to registration map</a>.
1. Set |matchingScope| to the longest value in |allScopes| which the value of |clientURLString| starts with, if it exists.
1. Let |matchingScopeString| be the empty string.
1. Let |scopeStringSet| be the result of [=map/get the keys|getting the keys=] from <a>scope to registration map</a>.
1. Set |matchingScopeString| to the longest value in |scopeStringSet| which the value of |clientURLString| starts with, if it exists.

Note: The URL string matching in this step is prefix-based rather than path-structural (e.g. a client URL string with "/prefix-of/resource.html" will match a registration for a scope with "/prefix").

1. Let |parsedMatchingScope| be null.
1. If |matchingScope| is not the empty string, set |parsedMatchingScope| to the result of <a lt="URL parser">parsing</a> |matchingScope|.
1. Let |registration| be the result of running <a>Get Registration</a> algorithm passing |parsedMatchingScope| as the argument.
1. Let |matchingScope| be null.
1. If |matchingScopeString| is not the empty string, set |matchingScope| to the result of <a lt="URL parser">parsing</a> |matchingScopeString|.
1. Let |registration| be the result of running <a>Get Registration</a> algorithm passing |matchingScope| as the argument.
1. If |registration| is not null and |registration|'s <a>uninstalling flag</a> is set, return null.
1. Return |registration|.
</section>
Expand Down
Loading

0 comments on commit f259d18

Please sign in to comment.