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 a browsingContext.traverseHistory command #584

Merged
merged 2 commits into from Nov 7, 2023
Merged

Conversation

jgraham
Copy link
Member

@jgraham jgraham commented Oct 30, 2023

This traverses the history by a specified delta (e.g. +1 for forward, or -1 for back).

For now there is no wait parameter; the command always returns as soon as the hsitory traversal has been enqueued (this should eventually be equivalent to setting wait to none).

This model differs somewhat from the CDP model where one navigates to an explicit history entry and failure is only possible if the entry id is invalid. But back/forwward only seems closer to the use cases we have, and allowing events to be traced to a specific traversal seems consistent with the way we handle other navigation-related events.


Preview | Diff

@jgraham
Copy link
Member Author

jgraham commented Oct 30, 2023

Note that this is an extremely basic version of the command, that skips all the issues around trying to wait for the history navigation to complete (or even to start; we currently don't return an error if you try to navigate past the last position in the session history, or before the first position).

However I think it's nearly enough for what Puppeteer does, the CDP's Page.navigateToHistoryEntry also doesn't wait or anything. The main difference is that the CDP method isn't ever called with an invalid history entry, so you know upfront if the navigation will succeed (subject to race conditions).

This traverses the history by a specified `delta` (e.g. +1 for forward,
or -1 for back).

For now there is no `wait` parameter; the command always returns as
soon as the hsitory traversal has been enqueued (this should
eventually be equivalent to setting wait to `none`).

This model differs somewhat from the CDP model where one navigates to
an explicit history entry and failure is only possible if the entry id
is invalid. But back/forwward only seems closer to the use cases we
have, and allowing events to be traced to a specific traversal seems
consistent with the way we handle other navigation-related events.
@jgraham
Copy link
Member Author

jgraham commented Oct 30, 2023

I've tried to fix the error issue by pre-checking the history entry exists. That's not perfect, but I think it's good enough for now.

Copy link
Contributor

@OrKoN OrKoN left a comment

Choose a reason for hiding this comment

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

I think it would work for Puppeteer

index.bs Show resolved Hide resolved
index.bs Outdated Show resolved Hide resolved
index.bs Show resolved Hide resolved
index.bs Show resolved Hide resolved
Copy link
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

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

Generally looks fine to me as well. Just some questions for clarity.

index.bs Show resolved Hide resolved
<dd>
<pre class="cddl local-cddl">
browsingContext.TraverseHistoryResult = {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this for now be an EmptyResult?

Copy link
Member Author

Choose a reason for hiding this comment

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

Could do, but since we're planning to update this in the future it didn't seem helpful to change.

Copy link
Contributor

Choose a reason for hiding this comment

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

The question is when this will happen. Also this current type is not extensible. But if all agree with this I'm fine as well.

index.bs Show resolved Hide resolved
@jgraham jgraham merged commit d606672 into main Nov 7, 2023
4 checks passed
@jgraham jgraham deleted the traverse_history_basic branch November 7, 2023 11:55
github-actions bot added a commit that referenced this pull request Nov 7, 2023
SHA: d606672
Reason: push, by jgraham

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@whimboo
Copy link
Contributor

whimboo commented Nov 7, 2023

FYI we will work the necessary wdspec tests when implementing this feature via https://bugzilla.mozilla.org/show_bug.cgi?id=1841018.

<dt>Command Type</dt>
<dd>
<pre class="cddl remote-cddl">
BrowsingContext.TraverseHistory = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be browsingContext starting with lower case b.

Copy link
Contributor

Choose a reason for hiding this comment

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

Never mind. It is fixed in #601

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants