Skip to content

Commit f023ea3

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 6fbb7ff commit f023ea3

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
@@ -82092,54 +82092,79 @@ interface <dfn>Location</dfn> { // but see also <a href="#the-location-interface
8209282092
data-x="concept-request-origin">origin</span> to that <span>browsing context scope
8209382093
origin</span>.</p></li>
8209482094

82095-
<li>
82096-
<p>Create a new <span>environment</span> <var>reservedEnvironment</var>, and set its <span
82097-
data-x="concept-environment-id">id</span> to a new unique opaque string, its <span
82098-
data-x="concept-environment-creation-url">creation URL</span> to <var>request</var>'s
82099-
<span>url</span>, and its <span data-x="concept-environment-target-browsing-context">target
82100-
browsing context</span> to <var>browsingContext</var>.</p>
82095+
<li><p>Let <var>done</var> be false and <var>reservedEnvironment</var> be null.</p></li>
8210182096

82102-
<p class="note">The created environment's <span
82103-
data-x="concept-environment-active-service-worker">active service worker</span> is set in the
82104-
<span data-x="on-fetch-request-algorithm">handle fetch</span> algorithm during the fetch if its
82105-
<span data-x="concept-environment-creation-url">creation URL</span> matches a service worker
82106-
registration. <ref spec="SW"></p>
82107-
</li>
82097+
<li><p>Repeat the following steps until <var>done</var> is true:</p>
8210882098

82109-
<li><p>Set <var>request</var>'s <span data-x="concept-request-reserved-client">reserved
82110-
client</span> to <var>reservedEnvironment</var>.</p></li>
82099+
<ol>
82100+
<li><p>If <var>reservedEnvironment</var> is not null, and <var>response</var>'s <span
82101+
data-x="concept-response-location-url">location URL</span> does not have the
82102+
<span>same origin</span> as <var>reservedEnvironment</var>'s <span
82103+
data-x="concept-environment-creation-url">creation URL</span>, then:</p>
8211182104

82112-
<li>
82113-
<p>If the <span>Should navigation request of type from source in target be blocked by Content
82114-
Security Policy?</span> algorithm returns "<code data-x="">Blocked</code>" when executed upon
82115-
<var>request</var>, <var>navigationType</var>, <var>sourceBrowsingContext</var>, and
82116-
<var>browsingContext</var>, then set <var>response</var> to a network error.
82117-
<ref spec="CSP"></p>
82105+
<ol>
82106+
<li><p>Run the <span>environment discarding steps</span> for <var>reservedEnvironment</var>.
82107+
</p></li>
8211882108

82119-
<p>Otherwise:</p>
82109+
<li><p>Set <var>reservedEnvironment</var> to null.</p></li>
82110+
</ol>
82111+
</li>
8212082112

82121-
<ol>
82122-
<!--FETCH--><li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li>
82113+
<li><p>If <var>reservedEnvironment</var> is null, let <var>reservedEnvironment</var> be a new
82114+
<span>environment</span>, and set its <span data-x="concept-environment-id">id</span> to a new
82115+
unique opaque string, its <span data-x="concept-environment-creation-url">creation URL</span>
82116+
to <var>request</var>'s <span>url</span>, and its <span
82117+
data-x="concept-environment-target-browsing-context">target browsing context</span> to
82118+
<var>browsingContext</var>.</p></li>
8212382119

82124-
<li><p>Wait for the <span data-x="concept-task">task</span> on the <span>networking task
82125-
source</span> to <span>process response</span> and set <var>response</var> to the
82126-
result.</p></li>
82127-
</ol>
82128-
</li>
82120+
<li>
82121+
<p>If <var>response</var> is not null, set <var>reservedEnvironment</var>'s <span
82122+
data-x="concept-environment-creation-url">creation URL</span> to <var>response</var>'s <span
82123+
data-x="concept-response-location-url">location URL</span>.</p>
82124+
82125+
<p class="note">The created environment's <span
82126+
data-x="concept-environment-active-service-worker">active service worker</span> is set in the
82127+
<span data-x="on-fetch-request-algorithm">Handle Fetch</span> algorithm during the fetch if
82128+
the request URL matches a service worker registration. <ref spec="SW"></p>
82129+
</li>
82130+
82131+
<li><p>Set <var>request</var>'s <span data-x="concept-request-reserved-client">reserved
82132+
client</span> to <var>reservedEnvironment</var>.</p></li>
82133+
82134+
<li><p>If the <span>Should navigation request of type from source in target be blocked by Content
82135+
Security Policy?</span> algorithm returns "<code data-x="">Blocked</code>" when executed upon
82136+
<var>request</var>, <var>navigationType</var>, <var>sourceBrowsingContext</var>, and
82137+
<var>browsingContext</var>, then set <var>response</var> to a network error, and set
82138+
<var>done</var> to true. <ref spec="CSP"></p></li>
82139+
82140+
<li><p>Otherwise:</p>
82141+
<ol>
82142+
<li><p>If <var>response</var> is null, <!--FETCH--><span
82143+
data-x="concept-fetch">fetch</span> <var>request</var>.</p></li>
8212982144

82145+
<li><p>Otherwise, perform <span>HTTP-redirect fetch</span> using
82146+
<var>request</var> and <var>response</var>.</p></li>
8213082147

82131-
<li id="navigate-redirect-step">
82132-
<p>If <var>response</var> has a <span data-x="concept-response-location-url">location URL</span>
82133-
and it is either failure or a <span>URL</span> whose <span
82134-
data-x="concept-url-scheme">scheme</span> is an <span>HTTP(S) scheme</span>, then set
82135-
<var>response</var> to the result of performing <span>HTTP-redirect fetch</span> using
82136-
<var>request</var> and <var>response</var> and then run this step again.</p>
82148+
<li><p>Wait for the <span data-x="concept-task">task</span> on the <span>networking task
82149+
source</span> to <span>process response</span> and set <var>response</var> to the
82150+
result.</p></li>
8213782151

82138-
<p class="note">Navigation handles redirects manually as navigation is the only place in the web
82139-
platform that cares for redirects to <code data-x="mailto protocol">mailto:</code> URLs and
82140-
such.</p>
82152+
<li><p>If <var>response</var> does not have a <span
82153+
data-x="concept-response-location-url">location URL</span> or the <span
82154+
data-x="concept-response-location-url">location URL</span> is not a <span>URL</span> whose
82155+
<span data-x="concept-url-scheme">scheme</span> is an <span>HTTP(S) scheme</span>,
82156+
then set <var>done</var> to true.</p></li>
82157+
</ol>
82158+
</li>
82159+
<p class="note">Navigation handles redirects manually as navigation is the only place in the web
82160+
platform that cares for redirects to <code data-x="mailto protocol">mailto:</code> URLs and
82161+
such.</p>
82162+
</ol>
8214182163
</li>
8214282164

82165+
<li><p>If <var>response</var> has a <span data-x="concept-response-location-url">location
82166+
URL</span> that is failure, then set <var>response</var> to a network error.</p></li>
82167+
8214382168
<li><p>Otherwise, if <var>response</var> has a <span
8214482169
data-x="concept-response-location-url">location URL</span> that is a <span>URL</span> whose <span
8214582170
data-x="concept-url-scheme">scheme</span> is "<code data-x="">blob</code>", "<code

0 commit comments

Comments
 (0)