Bug 328189
| Summary: | [WebDriver BiDi] browsingContext.traverseHistory navigates to the wrong history entry and returns the wrong errors | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | david.burns |
| Component: | WebDriver | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | a_panta, bburg, rcaliman, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | All | ||
| OS: | All | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=288334 | ||
| Bug Depends on: | |||
| Bug Blocks: | 282981 | ||
david.burns
browsingContext.traverseHistory landed in 301579@main (bug 288334), but the implementation almost never reaches the requested entry and its error handling does not follow the specification.
WebAutomationSession::traverseHistoryInBrowsingContext() computes an absolute index, backListCount + delta, and passes it to WebBackForwardList::itemAtDeltaFromCurrentIndex(), which takes a delta relative to the current entry. With a history of page1 -> page2 -> page3 and page3 current:
delta -1: index 1 is passed, so one entry FORWARD is requested; there is none, and the command fails with "unknown error" instead of going to page2.
delta -2: index 0 is passed, so delta 0 is requested and the page stays on page3 instead of going to page1.
Only a traversal where backListCount + delta happens to equal delta (an empty back list) lands where it should.
The errors also differ from the specification:
- a delta outside the session history returns "invalid argument" instead of "no such history entry";
- an unknown or empty context returns "no such window" instead of "no such frame";
- a child browsing context, which has no session history of its own, is accepted instead of rejected with "invalid argument";
- a non-integer delta (1.5) or one outside the safe-integer range is truncated instead of rejected with "invalid argument".
Steps to reproduce:
1. Start a BiDi session, navigate the top-level context to page1, then page2, then page3 with wait "complete".
2. Send browsingContext.traverseHistory with { context, delta: -1 }.
Expected: the context navigates to page2 and the command succeeds.
Actual: the command fails with "unknown error" and the context stays on page3.
WebDriverTests/TestExpectations.json still expects imported/w3c/webdriver/tests/bidi/browsing_context/traverse_history/context.py and delta.py to FAIL in full, plus invalid.py's test_params_context_invalid_value, test_delta_invalid_value[-2], test_delta_invalid_value[1] and test_iframe, all tagged with the resolved bug 288334. With the fix 23 of the 24 tests pass; delta.py test_history_push_state still fails because of bug 288058 (script.callFunction parses string arguments twice).
Tested on GTK, release build with asserts, 20 October 2026.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/190530418>
david.burns
Pull Request: https://github.com/WebKit/WebKit/pull/77635
EWS
Committed 325961@main (3924a6ec36c5): <https://commits.webkit.org/325961@main>
Reviewed commits have been landed. Closing PR #77634 and removing active labels.