Skip to content

Specify browser UI-initiated navigations better #11250

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

Merged
merged 4 commits into from
May 19, 2025
Merged
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
176 changes: 130 additions & 46 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2705,6 +2705,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x="concept-request-user-activation" data-x-href="https://fetch.spec.whatwg.org/#request-user-activation">user-activation</dfn></li>
<li><dfn data-x="concept-request-render-blocking" data-x-href="https://fetch.spec.whatwg.org/#request-render-blocking">render-blocking</dfn></li>
<li><dfn data-x="concept-request-initiator-type" data-x-href="https://fetch.spec.whatwg.org/#request-initiator-type">initiator type</dfn></li>
<li><dfn data-x="concept-request-service-workers-mode" data-x-href="https://fetch.spec.whatwg.org/#request-service-workers-mode">service-workers mode</dfn></li>
<li><dfn data-x="concept-request-traversable-for-user-prompts" data-x-href="https://fetch.spec.whatwg.org/#concept-request-window">traversable for user prompts</dfn></li>
<li><dfn data-x-href="https://fetch.spec.whatwg.org/#concept-request-add-range-header">add a range header</dfn></li>
</ul>
</li>
Expand Down Expand Up @@ -101172,36 +101174,66 @@ location.href = '#foo';</code></pre>
<dd>a boolean</dd>

<dt><dfn data-x="source-snapshot-params-client">fetch client</dfn></dt>
<dd>an <span>environment settings object</span>, only to be used as a <span
<dd>an <span>environment settings object</span> or null, only to be used as a <span
data-x="concept-request-client">request client</span></dd>

<dt><dfn data-x="source-snapshot-params-policy-container">source policy container</dfn></dt>
<dd>a <span>policy container</span></dd>
</dl>

<p>To <dfn data-x="snapshotting source snapshot params">snapshot source snapshot params</dfn>
given a <code>Document</code> <var>sourceDocument</var>, return a new <span>source snapshot
params</span> with</p>
given a <code>Document</code>-or-null <var>sourceDocument</var>:</p>

<dl class="props">
<dt><span data-x="source-snapshot-params-activation">has transient activation</span></dt>
<dd>true if <var>sourceDocument</var>'s <span>relevant global object</span> has <span>transient
activation</span>; otherwise false</dd>
<ol>
<li>
<p>If <var>sourceDocument</var> is null, then return a new <span>source snapshot params</span>
with</p>

<dl class="props">
<dt><span data-x="source-snapshot-params-activation">has transient activation</span></dt>
<dd>true</dd>

<dt><span data-x="source-snapshot-params-sandbox">sandboxing flags</span></dt>
<dd><var>sourceDocument</var>'s <span>active sandboxing flag set</span></dd>
<dt><span data-x="source-snapshot-params-sandbox">sandboxing flags</span></dt>
<dd>an empty <span>sandboxing flag set</span></dd>

<dt><span data-x="source-snapshot-params-download">allows downloading</span></dt>
<dd>false if <var>sourceDocument</var>'s <span>active sandboxing flag set</span> has the
<span>sandboxed downloads browsing context flag</span> set; otherwise true</dd>
<dt><span data-x="source-snapshot-params-download">allows downloading</span></dt>
<dd>true</dd>

<dt><span data-x="source-snapshot-params-client">fetch client</span></dt>
<dd><var>sourceDocument</var>'s <span>relevant settings object</span></dd>
<dt><span data-x="source-snapshot-params-client">fetch client</span></dt>
<dd>null</dd>

<dt><span data-x="source-snapshot-params-policy-container">source policy container</span></dt>
<dd>a <span data-x="clone a policy container">clone</span> of <var>sourceDocument</var>'s <span
data-x="concept-document-policy-container">policy container</span></dd>
</dl>
<dt><span data-x="source-snapshot-params-policy-container">source policy container</span></dt>
<dd>a new <span>policy container</span></dd>
</dl>

<p class="note">This <a href="#assert-null-sourcedocument">only occurs</a> in the case of a
browser UI-initiated navigation.</p>
</li>

<li>
<p>Return a new <span>source snapshot params</span> with

<dl class="props">
<dt><span data-x="source-snapshot-params-activation">has transient activation</span></dt>
<dd>true if <var>sourceDocument</var>'s <span>relevant global object</span> has <span>transient
activation</span>; otherwise false</dd>

<dt><span data-x="source-snapshot-params-sandbox">sandboxing flags</span></dt>
<dd><var>sourceDocument</var>'s <span>active sandboxing flag set</span></dd>

<dt><span data-x="source-snapshot-params-download">allows downloading</span></dt>
<dd>false if <var>sourceDocument</var>'s <span>active sandboxing flag set</span> has the
<span>sandboxed downloads browsing context flag</span> set; otherwise true</dd>

<dt><span data-x="source-snapshot-params-client">fetch client</span></dt>
<dd><var>sourceDocument</var>'s <span>relevant settings object</span></dd>

<dt><span data-x="source-snapshot-params-policy-container">source policy container</span></dt>
<dd>a <span data-x="clone a policy container">clone</span> of <var>sourceDocument</var>'s <span
data-x="concept-document-policy-container">policy container</span></dd>
</dl>
</li>
</ol>

<hr>

Expand Down Expand Up @@ -101404,22 +101436,22 @@ location.href = '#foo';</code></pre>
it, search for "DONAV" -->

<p>To <dfn export>navigate</dfn> a <span>navigable</span> <var>navigable</var> to a
<span>URL</span> <var>url</var> using a <code>Document</code> <var
id="source-browsing-context">sourceDocument</var>, with an optional <span>POST resource</span>,
string, or null <dfn for="navigate" data-x="navigation-resource"
<span>URL</span> <var>url</var> using an optional <code>Document</code>-or-null <var
id="source-browsing-context">sourceDocument</var> (default null), with an optional <span>POST
resource</span>, string, or null <dfn for="navigate" data-x="navigation-resource"
export><var>documentResource</var></dfn> (default null), an optional <span
data-x="concept-response">response</span>-or-null <dfn for="navigate"
data-x="navigation-response" export><var>response</var></dfn> (default null), an optional boolean
<dfn for="navigate" id="exceptions-enabled" export><var>exceptionsEnabled</var></dfn> (default
false), an optional <code>NavigationHistoryBehavior</code> <dfn for="navigate"
data-x="navigation-hh" export><var>historyHandling</var></dfn> (default "<code
data-x="concept-response">response</span>-or-null <dfn for="navigate" data-x="navigation-response"
export><var>response</var></dfn> (default null), an optional boolean <dfn for="navigate"
id="exceptions-enabled" export><var>exceptionsEnabled</var></dfn> (default false), an optional
<code>NavigationHistoryBehavior</code> <dfn for="navigate" data-x="navigation-hh"
export><var>historyHandling</var></dfn> (default "<code
data-x="NavigationHistoryBehavior-auto">auto</code>"), an optional <span>serialized
state</span>-or-null <dfn for="navigate" data-x="navigation-navigation-api-state"
export><var>navigationAPIState</var></dfn> (default null), an optional <span>entry list</span> or
null <dfn for="navigate" data-x="navigation-form-data-entry-list"
export><var>formDataEntryList</var></dfn> (default null), an optional <span>referrer
policy</span> <dfn data-x="navigation-referrer-policy"><var>referrerPolicy</var></dfn> (default
the empty string), an optional <span>user navigation involvement</span> <dfn
export><var>formDataEntryList</var></dfn> (default null), an optional <span>referrer policy</span>
<dfn data-x="navigation-referrer-policy"><var>referrerPolicy</var></dfn> (default the empty
string), an optional <span>user navigation involvement</span> <dfn
data-x="navigation-user-involvement"><var>userInvolvement</var></dfn> (default "<code
data-x="uni-none">none</code>"), and an optional <code>Element</code> <dfn
data-x="navigation-source-element"><var>sourceElement</var></dfn> (default null):</p>
Expand All @@ -101431,22 +101463,49 @@ location.href = '#foo';</code></pre>
<li><p>Let <var>sourceSnapshotParams</var> be the result of <span>snapshotting source snapshot
params</span> given <var>sourceDocument</var>.</p></li>

<li><p>Let <var>initiatorOriginSnapshot</var> be <var>sourceDocument</var>'s <span
data-x="concept-document-origin">origin</span>.</p></li>
<li><p>Let <var>initiatorOriginSnapshot</var> be a new <span
data-x="concept-origin-opaque">opaque origin</span>.</p></li>

<li><p>Let <var>initiatorBaseURLSnapshot</var> be <var>sourceDocument</var>'s <span>document base
URL</span>.</p></li>
<li><p>Let <var>initiatorBaseURLSnapshot</var> be <code>about:blank</code>.</p></li>

<li id="sandboxLinks">
<p>If <var>sourceDocument</var>'s <span>node navigable</span> is not <span>allowed by
sandboxing to navigate</span> <var>navigable</var> given <var>sourceSnapshotParams</var>,
then:</p>
<li>
<p>If <var>sourceDocument</var> is null:</p>

<ol>
<li><p>If <var>exceptionsEnabled</var> is true, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>
<li id="assert-null-sourcedocument"><p><span>Assert</span>: <var>userInvolvement</var> is
"<code data-x="uni-browser-ui">browser UI</code>".</p></li>

<li><p>Return.</p></li>
<li><p>If <var>url</var>'s <span data-x="concept-url-scheme">scheme</span> is "<code
data-x="javascript protocol">javascript</code>", then set <var>initiatorOriginSnapshot</var> to
<var>navigable</var>'s <span data-x="nav-document">active document</span>'s <span
data-x="concept-document-origin">origin</span>.</p></li>
</ol>
</li>

<li>
<p>Otherwise:</p>

<ol>
<li><p><span>Assert</span>: <var>userInvolvement</var> is not "<code
data-x="uni-browser-ui">browser UI</code>".</p></li>

<li id="sandboxLinks">
<p>If <var>sourceDocument</var>'s <span>node navigable</span> is not <span>allowed by
sandboxing to navigate</span> <var>navigable</var> given <var>sourceSnapshotParams</var>:</p>

<ol>
<li><p>If <var>exceptionsEnabled</var> is true, then throw a
<span>"<code>SecurityError</code>"</span> <code>DOMException</code>.</p></li>

<li><p>Return.</p></li>
</ol>
</li>

<li><p>Set <var>initiatorOriginSnapshot</var> to <var>sourceDocument</var>'s <span
data-x="concept-document-origin">origin</span>.</p></li>

<li><p>Set <var>initiatorBaseURLSnapshot</var> to <var>sourceDocument</var>'s <span>document
base URL</span>.</p></li>
</ol>
</li>

Expand Down Expand Up @@ -101741,14 +101800,17 @@ location.href = '#foo';</code></pre>
responses</span> after the initial response.</p>

<ol>
<li><p>Let <var>sourcePolicyContainer</var> be a <span data-x="clone a policy
container">clone</span> of the <var>sourceDocument</var>'s <span
data-x="concept-document-policy-container">policy container</span>, if
<var>sourceDocument</var> is not null; otherwise null.</p></li>

<li><p>Let <var>policyContainer</var> be the result of <span data-x="determining navigation
params policy container">determining navigation params policy container</span> given <span
data-x="concept-response">response</span>'s <span data-x="concept-response-url">URL</span>,
null, a <span data-x="clone a policy container">clone</span> of the
<var>sourceDocument</var>'s <span data-x="concept-document-policy-container">policy
container</span>, <var>navigable</var>'s <span data-x="nav-container-document">container
document</span>'s <span data-x="concept-document-policy-container">policy container</span>,
and null.</p></li>
null, <var>sourcePolicyContainer</var>, <var>navigable</var>'s <span
data-x="nav-container-document">container document</span>'s <span
data-x="concept-document-policy-container">policy container</span>, and null.</p></li>

<li><p>Let <var>finalSandboxFlags</var> be the <span data-x="set union">union</span> of
<var>targetSnapshotParams</var>'s <span data-x="target-snapshot-params-sandbox">sandboxing
Expand Down Expand Up @@ -103673,11 +103735,33 @@ location.href = '#foo';</code></pre>
<dt><span data-x="concept-request-policy-container">policy container</span></dt>
<dd><var>sourceSnapshotParams</var>'s <span
data-x="source-snapshot-params-policy-container">source policy container</span></dd>

<dt><span data-x="concept-request-traversable-for-user-prompts">traversable for user prompts</span></dt>
<dd><var>navigable</var>'s <span data-x="nav-top">top-level traversable</span></dd>
</dl>
</li>

<li>
<p>If <var>documentResource</var> is a <span>POST resource</span>, then:</p>
<p>If <var>request</var>'s <span data-x="concept-request-client">client</span> is null:</p>

<p class="note">This <a href="#assert-null-sourcedocument">only occurs</a> in the case of a
browser UI-initiated navigation.</p>

<ol>
<li><p>Set <var>request</var>'s <span data-x="concept-request-origin">origin</span> to a new
<span data-x="concept-origin-opaque">opaque origin</span>.</p></li>

<li><p>Set <var>request</var>'s <span
data-x="concept-request-service-workers-mode">service-workers mode</span> to "<code
data-x="">all</code>".</p></li>

<li><p>Set <var>request</var>'s <span data-x="concept-request-referrer">referrer</span> to
"<code data-x="">no-referrer</code>".</p></li>
</ol>
</li>

<li>
<p>If <var>documentResource</var> is a <span>POST resource</span>:</p>

<ol>
<li><p>Set <var>request</var>'s <span data-x="concept-request-method">method</span> to `<code
Expand Down