Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify active service worker inheritance #2809

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 68 additions & 22 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -76812,6 +76812,10 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
<dt><dfn>creator context security</dfn></dt>
<dd>The result of executing <span>Is environment settings object a secure context?</span> on
<var>creator document</var>'s <span>relevant settings object</span></dd>

<dt><dfn>creator active service worker</dfn></dt>
<dd><var>creator document</var>'s <span>relevant settings object</span>'s <span
data-x="concept-environment-active-service-worker">active service worker</span></dd>
</dl>

<div w-nodev>
Expand Down Expand Up @@ -76854,27 +76858,32 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
<var>document</var>.</p></li>

<li>
<p id="about-blank-origin">Set the <span>origin</span> of <var>document</var>:</p>
<p>If <var>browsingContext</var> has a <span>creator browsing context</span>, then:</p>

<ul>
<li><p>If <var>browsingContext</var> has a <span>creator browsing context</span>, then the
<span>origin</span> of <var>document</var> is the <span>creator origin</span>.</p></li>
<ol>
<li><p id="about-blank-origin">Set the <span>origin</span> of <var>document</var> to the
<span>creator origin</span>.</p></li>

<li><p>Otherwise, the <span>origin</span> of <var>document</var> is a unique <span
data-x="concept-origin-opaque">opaque origin</span>.</p></li>
</ul>
</li>
<li><p>Set <var>document</var>'s <span data-x="the document's referrer">referrer</span> to the
<span data-x="concept-url-serializer">serialization</span> of <span>creator
URL</span>.</p></li>

<li><p>If <var>browsingContext</var> has a <span>creator browsing context</span>, then set
<var>document</var>'s <span data-x="the document's referrer">referrer</span> to the <span
data-x="concept-url-serializer">serialization</span> of <span>creator URL</span>.</p></li>
<li><p>Set <var>document</var>'s <span data-x="concept-document-referrer-policy">referrer
policy</span> to the <span>creator referrer policy</span>.</p></li>

<li><p>If <var>browsingContext</var> has a <span>creator browsing context</span>, then set
<var>document</var>'s <span data-x="concept-document-referrer-policy">referrer policy</span> to
the <span>creator referrer policy</span>.</p></li>
<li><p>Set <var>settingsObject</var>'s
<span data-x="concept-environment-active-service-worker">active service worker</span> to the
<span>creator active service worker</span>.</p></li>
</ol>
</li>

<li><p><span>Implement the sandboxing</span> for <var>document</var>.</p></li>

<li><p>If <var>document</var>'s <span>active sandboxing flag set</span> has its <span>sandboxed
origin browsing context flag</span> set, then set <var>document</var>'s <span>relevant settings
object</span>'s <span data-x="concept-environment-active-service-worker">active service
worker</span> to null.</p></li>

<li><p><span>Set the allow* flags</span> for <var>document</var>.</p></li>

<li><p>Add <var>document</var> to <var>browsingContext</var>'s <span>session
Expand Down Expand Up @@ -79251,8 +79260,10 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

<dt>If the <code>Document</code> is the initial "<code>about:blank</code>" document</dt>

<dd><p><a href="#about-blank-origin">The one it was assigned when its browsing context was
created</a>.</p></dd>
<dd><p>A unique <span data-x="concept-origin-opaque">opaque origin</span> assigned when the
<code>Document</code> is created or <a href="#about-blank-origin">the one it was assigned when
its browsing context was created</a> if the <span>browsing context</span> had a <span>creator
browsing context</span>.</p></dd>


<dt>If the <code>Document</code> is a non-initial "<code>about:blank</code>" document</dt>
Expand Down Expand Up @@ -82134,11 +82145,40 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
additionally run the following algorithm after creating the new object:</p>

<ol>
<li><p>If <var>browsingContext</var>'s only entry in its <span>session history</span> is the
<code>about:blank</code> <code>Document</code> that was added when <var>browsingContext</var>
was <span data-x="creating a new browsing context">created</span>, and navigation is occurring
with <span>replacement enabled</span>, and that <code>Document</code> has the <span>same
origin</span> as the new <code>Document</code>, then do nothing.</p></li>
<li>
<p>If <var>browsingContext</var>'s only entry in its <span>session history</span> is the
<code>about:blank</code> <code>Document</code> that was added when <var>browsingContext</var>
was <span data-x="creating a new browsing context">created</span>, and navigation is occurring
with <span>replacement enabled</span>, and that <code>Document</code> has the <span>same
origin</span> as the new <code>Document</code>, then:</p>

<ol>
<li><p>Let <var>settingsObject</var> be <var>browsingContext</var>'s <span>active
document</span>'s <span>environment settings object</span>.</p></li>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this conditional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to exclude the case where the navigate was done against the (non-initial) about:blank Document. (This is basically the part that overrides the active service worker and the creation URL of the "old" environment settings object with the new values gotten from the navigate fetch.)

Thinking on your comment, I noticed that the about:blank document should have a unique origin. So, I think this condition isn't needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed this in the follow-up commit.

<li><p>Set <var>settingsObject</var>'s <span
data-x="concept-environment-creation-url">creation URL</span> to
<var>reservedEnvironment</var>'s <span data-x="concept-environment-creation-url">creation
URL</span>.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is the "old" document?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I guess for the settings object that doesn't matter...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. This should be the old one because the new one isn't installed yet. This is just to get the handle to the settings object anyway as you pointed.


<li><p>Set <var>settingsObject</var>'s <span
data-x="concept-environment-active-service-worker">active service worker</span> to
<var>reservedEnvironment</var>'s <span
data-x="concept-environment-active-service-worker">active service worker</span>.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be done either way? Is this something that's wrong today?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We reuse the "old" environment settings object for the new Document in this case, but don't have any steps to change the creation URL and the active service worker. Currently without adding this, the resulting (old) environment settings object won't get a controller even though the navigate fetch matched and delivered one.


<li><p>Set <var>reservedEnvironment</var>'s <span data-x="concept-environment-id">id</span>
to the empty string.</p></li>
</ol>

<p class="note">The initial <code>about:blank</code> <code>Document</code>'s <span>environment
settings object</span> is reused for the new <code>Document</code> in this case. The reserved
environment transfers its <span data-x="concept-environment-creation-url">creation URL</span>
and <span data-x="concept-environment-active-service-worker">active service worker</span> to
the reused <span>environment settings object</span> but does not transfer its <span
data-x="concept-environment-id">id</span>. The reserved environment is not searchable by the
<span>environment</span>’s <span data-x="concept-environment-id">id</span> from this point
on.</p>
</li>

<li>
<p>Otherwise:</p>
Expand All @@ -82161,7 +82201,7 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O
</li>

<li><p><span>Set up a window environment settings object</span> with <var>realm execution
context</var> and <var>reservedEnvironment</var>, if present.</p></li>
context</var> and <var>reservedEnvironment</var>.</p></li>
</ol>
</li>

Expand Down Expand Up @@ -82195,6 +82235,12 @@ State: &lt;OUTPUT NAME=I>1&lt;/OUTPUT> &lt;INPUT VALUE="Increment" TYPE=BUTTON O

<li><p><span>Implement the sandboxing</span> for the <code>Document</code>.</p></li>

<li><p>If the <code>Document</code>'s <span>active sandboxing flag set</span> has its
<span>sandboxed origin browsing context flag</span> set, then set the <code>Document</code>'s
<span>relevant settings object</span>'s <span
data-x="concept-environment-active-service-worker">active service worker</span> to
null.</p></li>

<li><p><span>Set the allow* flags</span> for the <code>Document</code>.</p></li>
</ol>
</li>
Expand Down