NEW328189
[WebDriver BiDi] browsingContext.traverseHistory navigates to the wrong history entry and returns the wrong errors
https://bugs.webkit.org/show_bug.cgi?id=328189
Summary [WebDriver BiDi] browsingContext.traverseHistory navigates to the wrong histo...
david.burns
Reported 2026-10-20 04:52:45 PDT
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
Radar WebKit Bug Importer
Comment 1 2026-10-20 09:35:34 PDT
david.burns
Comment 2 2026-10-21 05:59:31 PDT
Note You need to log in before you can comment on or make changes to this bug.