Skip to content

Commit f137c8a

Browse files
committed
Create a new reserved environment for cross-origin redirects.
Previously, a navigation would create a reserved environment once, and use it for all redirects. This commit changes that so a new environment is created on a cross-origin redirect. This also runs CSP for each redirect, which is probably more correct. Per w3c/ServiceWorker#1316
1 parent 753e9fe commit f137c8a

File tree

1 file changed

+62
-37
lines changed

1 file changed

+62
-37
lines changed

source

Lines changed: 62 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -82033,54 +82033,79 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
8203382033
data-x="concept-request-origin">origin</span> to that <span>browsing context scope
8203482034
origin</span>.</p></li>
8203582035

82036-
<li>
82037-
<p>Create a new <span>environment</span> <var>reservedEnvironment</var>, and set its <span
82038-
data-x="concept-environment-id">id</span> to a new unique opaque string, its <span
82039-
data-x="concept-environment-creation-url">creation URL</span> to <var>request</var>'s
82040-
<span>url</span>, and its <span data-x="concept-environment-target-browsing-context">target
82041-
browsing context</span> to <var>browsingContext</var>.</p>
82036+
<li><p>Let <var>done</var> be false and <var>reservedEnvironment</var> be null.</p></li>
8204282037

82043-
<p class="note">The created environment's <span
82044-
data-x="concept-environment-active-service-worker">active service worker</span> is set in the
82045-
<span data-x="on-fetch-request-algorithm">handle fetch</span> algorithm during the fetch if its
82046-
<span data-x="concept-environment-creation-url">creation URL</span> matches a service worker
82047-
registration. <ref spec="SW"></p>
82048-
</li>
82038+
<li><p>Repeat the following steps until <var>done</var> is true:</p>
8204982039

82050-
<li><p>Set <var>request</var>'s <span data-x="concept-request-reserved-client">reserved
82051-
client</span> to <var>reservedEnvironment</var>.</p></li>
82040+
<ol>
82041+
<li><p>If <var>reservedEnvironment</var> is not null, and <var>response</var>'s <span
82042+
data-x="concept-response-location-url">location URL</span> does not have the
82043+
<span>same origin</span> as <var>reservedEnvironment</var>'s <span
82044+
data-x="concept-environment-creation-url">creation URL</span>, then:</p>
8205282045

82053-
<li>
82054-
<p>If the <span>Should navigation request of type from source in target be blocked by Content
82055-
Security Policy?</span> algorithm returns "<code data-x="">Blocked</code>" when executed upon
82056-
<var>request</var>, <var>navigationType</var>, <var>sourceBrowsingContext</var>, and
82057-
<var>browsingContext</var>, then set <var>response</var> to a network error.
82058-
<ref spec="CSP"></p>
82046+
<ol>
82047+
<li><p>Run the <span>environment discarding steps</span> for <var>reservedEnvironment</var>.
82048+
</p></li>
8205982049

82060-
<p>Otherwise:</p>
82050+
<li><p>Set <var>reservedEnvironment</var> to null.</p></li>
82051+
</ol>
82052+
</li>
8206182053

82062-
<ol>
82063-
<!--FETCH--><li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li>
82054+
<li><p>If <var>reservedEnvironment</var> is null, let <var>reservedEnvironment</var> be a new
82055+
<span>environment</span>, and set its <span data-x="concept-environment-id">id</span> to a new
82056+
unique opaque string, its <span data-x="concept-environment-creation-url">creation URL</span>
82057+
to <var>request</var>'s <span>url</span>, and its <span
82058+
data-x="concept-environment-target-browsing-context">target browsing context</span> to
82059+
<var>browsingContext</var>.</p></li>
8206482060

82065-
<li><p>Wait for the <span data-x="concept-task">task</span> on the <span>networking task
82066-
source</span> to <span>process response</span> and set <var>response</var> to the
82067-
result.</p></li>
82068-
</ol>
82069-
</li>
82061+
<li>
82062+
<p>If <var>response</var> is not null, set <var>reservedEnvironment</var>'s <span
82063+
data-x="concept-environment-creation-url">creation URL</span> to <var>response</var>'s <span
82064+
data-x="concept-response-location-url">location URL</span>.</p>
82065+
82066+
<p class="note">The created environment's <span
82067+
data-x="concept-environment-active-service-worker">active service worker</span> is set in the
82068+
<span data-x="on-fetch-request-algorithm">Handle Fetch</span> algorithm during the fetch if
82069+
the request URL matches a service worker registration. <ref spec="SW"></p>
82070+
</li>
82071+
82072+
<li><p>Set <var>request</var>'s <span data-x="concept-request-reserved-client">reserved
82073+
client</span> to <var>reservedEnvironment</var>.</p></li>
82074+
82075+
<li><p>If the <span>Should navigation request of type from source in target be blocked by Content
82076+
Security Policy?</span> algorithm returns "<code data-x="">Blocked</code>" when executed upon
82077+
<var>request</var>, <var>navigationType</var>, <var>sourceBrowsingContext</var>, and
82078+
<var>browsingContext</var>, then set <var>response</var> to a network error, and set
82079+
<var>done</var> to true. <ref spec="CSP"></p></li>
82080+
82081+
<li><p>Otherwise:</p>
82082+
<ol>
82083+
<li><p>If <var>response</var> is null, <!--FETCH--><span
82084+
data-x="concept-fetch">fetch</span> <var>request</var>.</p></li>
8207082085

82086+
<li><p>Otherwise, perform <span>HTTP-redirect fetch</span> using
82087+
<var>request</var> and <var>response</var>.</p></li>
8207182088

82072-
<li id="navigate-redirect-step">
82073-
<p>If <var>response</var> has a <span data-x="concept-response-location-url">location URL</span>
82074-
and it is either failure or a <span>URL</span> whose <span
82075-
data-x="concept-url-scheme">scheme</span> is an <span>HTTP(S) scheme</span>, then set
82076-
<var>response</var> to the result of performing <span>HTTP-redirect fetch</span> using
82077-
<var>request</var> and <var>response</var> and then run this step again.</p>
82089+
<li><p>Wait for the <span data-x="concept-task">task</span> on the <span>networking task
82090+
source</span> to <span>process response</span> and set <var>response</var> to the
82091+
result.</p></li>
8207882092

82079-
<p class="note">Navigation handles redirects manually as navigation is the only place in the web
82080-
platform that cares for redirects to <code data-x="mailto protocol">mailto:</code> URLs and
82081-
such.</p>
82093+
<li><p>If <var>response</var> does not have a <span
82094+
data-x="concept-response-location-url">location URL</span> or the <span
82095+
data-x="concept-response-location-url">location URL</span> is not a <span>URL</span> whose
82096+
<span data-x="concept-url-scheme">scheme</span> is an <span>HTTP(S) scheme</span>,
82097+
then set <var>done</var> to true.</p></li>
82098+
</ol>
82099+
</li>
82100+
<p class="note">Navigation handles redirects manually as navigation is the only place in the web
82101+
platform that cares for redirects to <code data-x="mailto protocol">mailto:</code> URLs and
82102+
such.</p>
82103+
</ol>
8208282104
</li>
8208382105

82106+
<li><p>If <var>response</var> has a <span data-x="concept-response-location-url">location
82107+
URL</span> that is failure, then set <var>response</var> to a network error.</p></li>
82108+
8208482109
<li><p>Otherwise, if <var>response</var> has a <span
8208582110
data-x="concept-response-location-url">location URL</span> that is a <span>URL</span> whose <span
8208682111
data-x="concept-url-scheme">scheme</span> is "<code data-x="">blob</code>", "<code

0 commit comments

Comments
 (0)