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

Add navigation hooks for WebDriver BiDi history traversal #6921

Open
wants to merge 7 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
78 changes: 59 additions & 19 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -4393,6 +4393,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-fragment-navigated">WebDriver BiDi fragment navigated</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-dom-content-loaded">WebDriver BiDi DOM content loaded</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-load-complete">WebDriver BiDi load complete</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-page-show">WebDriver BiDi page show</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-pop-state">WebDriver BiDi pop state</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-user-prompt-closed">WebDriver BiDi user prompt closed</dfn></li>
<li><dfn data-x-href="https://w3c.github.io/webdriver-bidi/#webdriver-bidi-user-prompt-opened">WebDriver BiDi user prompt opened</dfn></li>
</ul>
Expand Down Expand Up @@ -94550,28 +94552,57 @@ location.href = '#foo';</code></pre>
<li><p><span>Restore the history object state</span> given <var>document</var> and
<var>entry</var>.</p></li>

<li><p>If <var>documentIsNew</var> is false, then <span data-x="concept-event-fire">fire an
event</span> named <code data-x="event-popstate">popstate</code> at <var>document</var>'s
<span>relevant global object</span>, using <code>PopStateEvent</code>, with the <code
data-x="dom-PopStateEvent-state">state</code> attribute initialized to <var>document</var>'s
<span data-x="doc-history">history object</span>'s <span
data-x="concept-history-state">state</span>.</p>
<li>
<p>If <var>documentIsNew</var> is false, then:</p>

<ol>
<li><p><span data-x="concept-event-fire">Fire an event</span> named <code
data-x="event-popstate">popstate</code> at <var>document</var>'s <span>relevant global
object</span>, using <code>PopStateEvent</code>, with the <code
data-x="dom-PopStateEvent-state">state</code> attribute initialized to <var>document</var>'s
<span data-x="doc-history">history object</span>'s <span
data-x="concept-history-state">state</span>.</p></li>

<li><p>Invoke <span>WebDriver BiDi pop state</span> with <var>document</var>'s
<span data-x="concept-document-bc">browsing context</span> and a new <span>WebDriver
BiDi navigation status</span> whose <span data-x="navigation-status-id">id</span> is
<var>document</var>'s <span data-x="concept-document-navigation-id">navigation id</span>,
Copy link
Member

Choose a reason for hiding this comment

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

I'm skeptical that we should use document's navigation id here and below. We should instead pass it through as an argument to "update document for history step application".

Copy link
Member

@foolip foolip Feb 23, 2023

Choose a reason for hiding this comment

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

Actually I'm not sure these changes are needed, because we're inside of "update document for history step application". When that's called from "navigate to a fragment" it will be followed by invoking "WebDriver BiDi fragment navigated".

But when it's called from "apply the history step" it's much harder to follow all of the call sites. I think there are ways for "traverse the history by a delta" to end without invoking any BiDi callback. But more importantly that algorithm doesn't take a navigation id because I failed to carry that forward when resolving conflicts, see https://github.com/whatwg/html/pull/6921/files/9afc0d64707caa64ae750dc8117cbb2c4194a52a for @jgraham's original changes.

<span data-x="navigation-status-url">url</span> is the <span
data-x="concept-url-serializer">serialization</span> of <var>entry</var>'s <span
data-x="she-url">URL</span>, and <span data-x="navigation-status-status">status</span> is
"<code data-x="navigation-status-complete">complete</code>".</p></li>
</ol>
</li>

<li><p><span>Restore persisted state</span> given <var>entry</var>.</p></li>

<li><p>If <var>documentIsNew</var> is false, and <var>oldURL</var>'s <span
data-x="concept-url-fragment">fragment</span> is not equal to <var>entry</var>'s <span
data-x="she-url">URL</span>'s <span data-x="concept-url-fragment">fragment</span>, then
<span>queue a global task</span> on the <span>DOM manipulation task source</span> given
<var>document</var>'s <span>relevant global object</span> to <span
data-x="concept-event-fire">fire an event</span> named <code
data-x="event-hashchange">hashchange</code> at <var>document</var>'s <span>relevant global
object</span>, using <code>HashChangeEvent</code>, with the <code
data-x="dom-HashChangeEvent-oldURL">oldURL</code> attribute initialized to the <span
data-x="concept-url-serializer">serialization</span> of <var>oldURL</var> and the <code
data-x="dom-HashChangeEvent-newURL">newURL</code> attribute initialized to the <span
data-x="concept-url-serializer">serialization</span> of <var>entry</var>'s <span
data-x="she-url">URL</span>.</p></li>
<li>
<p>If <var>documentIsNew</var> is false, and <var>oldURL</var>'s <span
data-x="concept-url-fragment">fragment</span> is not equal to <var>entry</var>'s <span
data-x="she-url">URL</span>'s <span data-x="concept-url-fragment">fragment</span>, then
<span>queue a global task</span> on the <span>DOM manipulation task source</span> given
<var>document</var>'s <span>relevant global object</span> to:</p>

<ol>
<li><p><span data-x="concept-event-fire">Fire an event</span> named <code
data-x="event-hashchange">hashchange</code> at <var>document</var>'s <span>relevant global
object</span>, using <code>HashChangeEvent</code>, with the <code
data-x="dom-HashChangeEvent-oldURL">oldURL</code> attribute initialized to the <span
data-x="concept-url-serializer">serialization</span> of <var>oldURL</var> and the <code
data-x="dom-HashChangeEvent-newURL">newURL</code> attribute initialized to the <span
data-x="concept-url-serializer">serialization</span> of <var>entry</var>'s <span
data-x="she-url">URL</span>.</p></li>

<li><p>Invoke <span>WebDriver BiDi fragment navigated</span> with <var>document</var>'s
<span data-x="concept-document-bc">browsing context</span> and a new <span>WebDriver
BiDi navigation status</span> whose <span data-x="navigation-status-id">id</span> is
<var>document</var>'s <span data-x="concept-document-navigation-id">navigation id</span>,
<span data-x="navigation-status-url">url</span> is the <span
data-x="concept-url-serializer">serialization</span> of <var>entry</var>'s <span
data-x="she-url">URL</span>, and <span data-x="navigation-status-status">status</span> is
"<code data-x="navigation-status-complete">complete</code>".</p></li>
</ol>
</li>
</ol>
</li>

Expand Down Expand Up @@ -94679,6 +94710,15 @@ location.href = '#foo';</code></pre>
<li><p><span>Fire a page transition event</span> named <code
data-x="event-pageshow">pageshow</code> at <var>document</var>'s <span>relevant global
object</span> with true.</p></li>

<li><p>Invoke <span>WebDriver BiDi page show</span> with <var>document</var>'s <span
data-x="concept-document-bc">browsing context</span> and a new <span>WebDriver BiDi
navigation status</span> whose <span data-x="navigation-status-id">id</span> is
<var>document</var>'s <span data-x="concept-document-navigation-id">navigation id</span>, <span
data-x="navigation-status-status">status</span> is "<code
data-x="navigation-status-complete">complete</code>", and <span
data-x="navigation-status-url">url</span> is <var>document</var>'s <span
data-x="concept-document-url">URL</span>.</p></li>
</ol>

<!-- an interesting thing to test would be to traverse back during onload, before the first
Expand Down