WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED INVALID
291586
[WebDriver][GLIB] Incorrect browsing context check after moving to a frame-less page
https://bugs.webkit.org/show_bug.cgi?id=291586
Summary
[WebDriver][GLIB] Incorrect browsing context check after moving to a frame-le...
Lauro Moura
Reported
2025-04-15 12:55:16 PDT
imported/selenium/py/test/selenium/webdriver/common/frame_switching_tests.py::test_should_focus_on_the_replacement_when_aframe_follows_alink_to_a_top_targeted_page Test code: pages.load("frameset.html") driver.switch_to.frame(0) driver.find_element(By.LINK_TEXT, "top").click() expectedTitle = "XHTML Test Page" WebDriverWait(driver, 3).until(EC.title_is(expectedTitle)) WebDriverWait(driver, 3).until(EC.presence_of_element_located((By.ID, "only-exists-on-xhtmltest"))) Test is returning `"no such window"` inside `Session::findElements` due to `m_currentBrowsingContext` being null. This var is cleared by `Session::waitForNavigationToComplete` completion handler after moving away to a frame-less page. But `m_currentBrowsingContext` is allowed to be null in a number of scenarios, defaulting to the main frame inside the browser. For example, it's usually passed as the "frameHandle" parameter in methods from `Automation.json`:
> "frameHandle": The handle for the frame in which to search for the frame. The main frame is used if this parameter empty string or excluded.
And `Session::findElements` code indeed expects this behavior, checking if m_currentBrowsingContext is null or not. So, looks like the correct check would be whether `m_toplevelBrowsingContext` is valid nor not. On top of `Session::findElements`, there are other `Session` methods with this behavior, like `getActiveElement`, `executeScript`, etc.
Attachments
Add attachment
proposed patch, testcase, etc.
Lauro Moura
Comment 1
2025-04-16 12:50:06 PDT
Actually, the check is correct per the spec, as seen in the `find_element/find.py` tests: ``` def test_no_browsing_context(session, closed_frame): response = find_element(session, "css selector", "foo") assert_error(response, "no such window") ``` Related spec links: - Spec PR:
https://github.com/w3c/webdriver/pull/1543
- Related tests:
https://bugzilla.mozilla.org/show_bug.cgi?id=1493108
- WebKit update to match behavior:
https://commits.webkit.org/230029@main
IIUC, the client needs to ensure a valid "current browsing context" is selected in these scenarios instead of the driver "implicitly" falling back to the top level context. For example, by switching explicitly after eventually closing the current one. So the issue is in the Selenium test (which actually is marked as fail in other browsers) Closing as invalid, sorry for the noise.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug