Verify webview still open in webdriver switch frame command (#37411)

SwitchToParentFrame webdriver commands do not handle the case where the
current top-level browsing context has been closed.

Tests:

`./tests/wpt/tests/webdriver/tests/classic/switch_to_parent_frame/switch.py`
`./tests/wpt/tests/webdriver/tests/classic/switch_to_frame/switch.py`

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
This commit is contained in:
batu_hoang 2025-06-13 16:32:59 +08:00 committed by GitHub
parent 1bbdcb1911
commit 4c598037a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 12 deletions

View file

@ -1043,6 +1043,8 @@ impl Handler {
&mut self,
parameters: &SwitchToFrameParameters,
) -> WebDriverResult<WebDriverResponse> {
self.verify_top_level_browsing_context_is_open(self.session()?.webview_id)?;
use webdriver::common::FrameId;
let frame_id = match parameters.id {
FrameId::Top => {
@ -1058,6 +1060,11 @@ impl Handler {
}
fn handle_switch_to_parent_frame(&mut self) -> WebDriverResult<WebDriverResponse> {
let webview_id = self.session()?.webview_id;
self.verify_top_level_browsing_context_is_open(webview_id)?;
if self.session()?.browsing_context_id == webview_id {
return Ok(WebDriverResponse::Void);
}
self.switch_to_frame(WebDriverFrameId::Parent)
}