diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 957bf6a9247..5cb25646afd 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -3137,7 +3137,10 @@ where .send(EmbedderMsg::WebViewClosed(webview_id)); let Some(browsing_context) = browsing_context else { - return; + return warn!( + "fn handle_close_top_level_browsing_context {}: Closing twice", + browsing_context_id + ); }; // https://html.spec.whatwg.org/multipage/#bcg-remove let bc_group_id = browsing_context.bc_group_id; @@ -5523,7 +5526,7 @@ where let browsing_context = match self.browsing_contexts.remove(&browsing_context_id) { Some(ctx) => ctx, None => { - warn!("{browsing_context_id}: Closing twice"); + warn!("fn close_browsing_context: {browsing_context_id}: Closing twice"); return None; }, }; @@ -5679,7 +5682,7 @@ where // the pipeline. let pipeline = match self.pipelines.get(&pipeline_id) { Some(pipeline) => pipeline, - None => return warn!("{}: Closing twice", pipeline_id), + None => return warn!("fn close_pipeline: {pipeline_id}: Closing twice"), }; // Remove this pipeline from pending changes if it hasn't loaded yet. diff --git a/components/webdriver_server/actions.rs b/components/webdriver_server/actions.rs index a5f33abe6a5..890d0fcd4b4 100644 --- a/components/webdriver_server/actions.rs +++ b/components/webdriver_server/actions.rs @@ -764,10 +764,9 @@ impl Handler { web_element: &WebElement, ) -> Result<(i64, i64), ErrorStatus> { let (sender, receiver) = ipc::channel().unwrap(); - self.browsing_context_script_command(WebDriverScriptCommand::GetElementInViewCenterPoint( - web_element.to_string(), - sender, - )) + self.browsing_context_script_command::( + WebDriverScriptCommand::GetElementInViewCenterPoint(web_element.to_string(), sender), + ) .unwrap(); let response = match wait_for_script_response(receiver) { Ok(response) => response, diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index 19af5bafe65..41a47d1e74f 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -703,7 +703,7 @@ impl Handler { Ok(WebDriverResponse::DeleteSession) } - // https://w3c.github.io/webdriver/#status + /// fn handle_status(&self) -> WebDriverResult { Ok(WebDriverResponse::Generic(ValueResponse( if self.session.is_none() { @@ -714,12 +714,16 @@ impl Handler { ))) } - fn browsing_context_script_command( + /// Send command to Script Thread with session's current browsing context. + /// If CHECK_OPEN is true, it would verify the existence of browsing context before sending. + fn browsing_context_script_command( &self, cmd_msg: WebDriverScriptCommand, ) -> WebDriverResult<()> { let browsing_context_id = self.session()?.browsing_context_id; - self.verify_browsing_context_is_open(browsing_context_id)?; + if CHECK_OPEN { + self.verify_browsing_context_is_open(browsing_context_id)?; + } let msg = EmbedderToConstellationMessage::WebDriverCommand( WebDriverCommandMsg::ScriptCommand(browsing_context_id, cmd_msg), ); @@ -727,9 +731,17 @@ impl Handler { Ok(()) } - fn top_level_script_command(&self, cmd_msg: WebDriverScriptCommand) -> WebDriverResult<()> { + /// Send command to Script Thread with session's current top-level browsing context. + /// If CHECK_OPEN is true, it would verify the existence of top-level + /// browsing context before sending. + fn top_level_script_command( + &self, + cmd_msg: WebDriverScriptCommand, + ) -> WebDriverResult<()> { let webview_id = self.session()?.webview_id; - self.verify_top_level_browsing_context_is_open(webview_id)?; + if CHECK_OPEN { + self.verify_top_level_browsing_context_is_open(webview_id)?; + } let browsing_context_id = BrowsingContextId::from(webview_id); let msg = EmbedderToConstellationMessage::WebDriverCommand( WebDriverCommandMsg::ScriptCommand(browsing_context_id, cmd_msg), @@ -780,7 +792,7 @@ impl Handler { fn handle_current_url(&self) -> WebDriverResult { let (sender, receiver) = ipc::channel().unwrap(); - self.top_level_script_command(WebDriverScriptCommand::GetUrl(sender))?; + self.top_level_script_command::(WebDriverScriptCommand::GetUrl(sender))?; let url = wait_for_script_response(receiver)?; @@ -861,13 +873,9 @@ impl Handler { } fn handle_is_enabled(&self, element: &WebElement) -> WebDriverResult { - // Step 1. If session's current browsing context is no longer open, - // return error with error code no such window. - self.verify_browsing_context_is_open(self.session()?.browsing_context_id)?; - let (sender, receiver) = ipc::channel().unwrap(); - self.top_level_script_command(WebDriverScriptCommand::IsEnabled( + self.browsing_context_script_command::(WebDriverScriptCommand::IsEnabled( element.to_string(), sender, ))?; @@ -881,13 +889,9 @@ impl Handler { } fn handle_is_selected(&self, element: &WebElement) -> WebDriverResult { - // Step 1. If session's current browsing context is no longer open, - // return error with error code no such window. - self.verify_browsing_context_is_open(self.session()?.browsing_context_id)?; - let (sender, receiver) = ipc::channel().unwrap(); - self.top_level_script_command(WebDriverScriptCommand::IsSelected( + self.browsing_context_script_command::(WebDriverScriptCommand::IsSelected( element.to_string(), sender, ))?; @@ -939,7 +943,7 @@ impl Handler { fn handle_title(&self) -> WebDriverResult { let (sender, receiver) = ipc::channel().unwrap(); - self.top_level_script_command(WebDriverScriptCommand::GetTitle(sender))?; + self.top_level_script_command::(WebDriverScriptCommand::GetTitle(sender))?; let value = wait_for_script_response(receiver)?; Ok(WebDriverResponse::Generic(ValueResponse( @@ -991,7 +995,7 @@ impl Handler { parameters.value.clone(), sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, LocatorStrategy::LinkText | LocatorStrategy::PartialLinkText => { let cmd = WebDriverScriptCommand::FindElementLinkText( @@ -999,12 +1003,12 @@ impl Handler { parameters.using == LocatorStrategy::PartialLinkText, sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, LocatorStrategy::TagName => { let cmd = WebDriverScriptCommand::FindElementTagName(parameters.value.clone(), sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, _ => { return Err(WebDriverError::new( @@ -1165,7 +1169,7 @@ impl Handler { let (sender, receiver) = ipc::channel().unwrap(); let cmd = WebDriverScriptCommand::GetBrowsingContextId(frame_id, sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; match wait_for_script_response(receiver)? { Ok(browsing_context_id) => { @@ -1192,7 +1196,7 @@ impl Handler { parameters.value.clone(), sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, LocatorStrategy::LinkText | LocatorStrategy::PartialLinkText => { let cmd = WebDriverScriptCommand::FindElementsLinkText( @@ -1200,12 +1204,12 @@ impl Handler { parameters.using == LocatorStrategy::PartialLinkText, sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, LocatorStrategy::TagName => { let cmd = WebDriverScriptCommand::FindElementsTagName(parameters.value.clone(), sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, _ => { return Err(WebDriverError::new( @@ -1245,7 +1249,7 @@ impl Handler { element.to_string(), sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, LocatorStrategy::LinkText | LocatorStrategy::PartialLinkText => { let cmd = WebDriverScriptCommand::FindElementElementLinkText( @@ -1254,7 +1258,7 @@ impl Handler { parameters.using == LocatorStrategy::PartialLinkText, sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, LocatorStrategy::TagName => { let cmd = WebDriverScriptCommand::FindElementElementTagName( @@ -1262,7 +1266,7 @@ impl Handler { element.to_string(), sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, _ => { return Err(WebDriverError::new( @@ -1304,7 +1308,7 @@ impl Handler { element.to_string(), sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, LocatorStrategy::LinkText | LocatorStrategy::PartialLinkText => { let cmd = WebDriverScriptCommand::FindElementElementsLinkText( @@ -1313,7 +1317,7 @@ impl Handler { parameters.using == LocatorStrategy::PartialLinkText, sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, LocatorStrategy::TagName => { let cmd = WebDriverScriptCommand::FindElementElementsTagName( @@ -1321,7 +1325,7 @@ impl Handler { element.to_string(), sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, _ => { return Err(WebDriverError::new( @@ -1364,7 +1368,7 @@ impl Handler { shadow_root.to_string(), sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, LocatorStrategy::LinkText | LocatorStrategy::PartialLinkText => { let cmd = WebDriverScriptCommand::FindShadowElementsLinkText( @@ -1373,7 +1377,7 @@ impl Handler { parameters.using == LocatorStrategy::PartialLinkText, sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, LocatorStrategy::TagName => { let cmd = WebDriverScriptCommand::FindShadowElementsTagName( @@ -1381,7 +1385,7 @@ impl Handler { shadow_root.to_string(), sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; }, _ => { return Err(WebDriverError::new( @@ -1432,7 +1436,7 @@ impl Handler { fn handle_get_shadow_root(&self, element: WebElement) -> WebDriverResult { let (sender, receiver) = ipc::channel().unwrap(); let cmd = WebDriverScriptCommand::GetElementShadowRoot(element.to_string(), sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; match wait_for_script_response(receiver)? { Ok(value) => { let Some(value) = value else { @@ -1450,7 +1454,7 @@ impl Handler { fn handle_element_rect(&self, element: &WebElement) -> WebDriverResult { let (sender, receiver) = ipc::channel().unwrap(); let cmd = WebDriverScriptCommand::GetElementRect(element.to_string(), sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; match wait_for_script_response(receiver)? { Ok(rect) => { let response = ElementRectResponse { @@ -1469,7 +1473,7 @@ impl Handler { fn handle_element_text(&self, element: &WebElement) -> WebDriverResult { let (sender, receiver) = ipc::channel().unwrap(); let cmd = WebDriverScriptCommand::GetElementText(element.to_string(), sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; match wait_for_script_response(receiver)? { Ok(value) => Ok(WebDriverResponse::Generic(ValueResponse( serde_json::to_value(value)?, @@ -1482,7 +1486,7 @@ impl Handler { fn handle_active_element(&self) -> WebDriverResult { let (sender, receiver) = ipc::channel().unwrap(); let cmd = WebDriverScriptCommand::GetActiveElement(sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; let value = wait_for_script_response(receiver)? .map(|x| serde_json::to_value(WebElement(x)).unwrap()); // Step 4. If active element is a non-null element, return success @@ -1503,7 +1507,7 @@ impl Handler { fn handle_computed_role(&self, element: &WebElement) -> WebDriverResult { let (sender, receiver) = ipc::channel().unwrap(); let cmd = WebDriverScriptCommand::GetComputedRole(element.to_string(), sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; match wait_for_script_response(receiver)? { Ok(value) => Ok(WebDriverResponse::Generic(ValueResponse( serde_json::to_value(value)?, @@ -1515,7 +1519,7 @@ impl Handler { fn handle_element_tag_name(&self, element: &WebElement) -> WebDriverResult { let (sender, receiver) = ipc::channel().unwrap(); let cmd = WebDriverScriptCommand::GetElementTagName(element.to_string(), sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; match wait_for_script_response(receiver)? { Ok(value) => Ok(WebDriverResponse::Generic(ValueResponse( serde_json::to_value(value)?, @@ -1535,7 +1539,7 @@ impl Handler { name.to_owned(), sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; match wait_for_script_response(receiver)? { Ok(value) => Ok(WebDriverResponse::Generic(ValueResponse( serde_json::to_value(value)?, @@ -1556,7 +1560,7 @@ impl Handler { name.to_owned(), sender, ); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; match wait_for_script_response(receiver)? { Ok(value) => Ok(WebDriverResponse::Generic(ValueResponse( @@ -1574,7 +1578,7 @@ impl Handler { let (sender, receiver) = ipc::channel().unwrap(); let cmd = WebDriverScriptCommand::GetElementCSS(element.to_string(), name.to_owned(), sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; match wait_for_script_response(receiver)? { Ok(value) => Ok(WebDriverResponse::Generic(ValueResponse( serde_json::to_value(value)?, @@ -1586,7 +1590,7 @@ impl Handler { fn handle_get_cookies(&self) -> WebDriverResult { let (sender, receiver) = ipc::channel().unwrap(); let cmd = WebDriverScriptCommand::GetCookies(sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; let cookies = match wait_for_script_response(receiver)? { Ok(cookies) => cookies, Err(error) => return Err(WebDriverError::new(error, "")), @@ -1601,7 +1605,7 @@ impl Handler { fn handle_get_cookie(&self, name: String) -> WebDriverResult { let (sender, receiver) = ipc::channel().unwrap(); let cmd = WebDriverScriptCommand::GetCookie(name, sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; let cookies = match wait_for_script_response(receiver)? { Ok(cookies) => cookies, Err(error) => return Err(WebDriverError::new(error, "")), @@ -1635,7 +1639,7 @@ impl Handler { }; let cmd = WebDriverScriptCommand::AddCookie(cookie_builder.build(), sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; match wait_for_script_response(receiver)? { Ok(_) => Ok(WebDriverResponse::Void), Err(error) => Err(WebDriverError::new(error, "")), @@ -1645,7 +1649,7 @@ impl Handler { fn handle_delete_cookie(&self, name: String) -> WebDriverResult { let (sender, receiver) = ipc::channel().unwrap(); let cmd = WebDriverScriptCommand::DeleteCookie(name, sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; match wait_for_script_response(receiver)? { Ok(_) => Ok(WebDriverResponse::Void), Err(error) => Err(WebDriverError::new(error, "")), @@ -1655,7 +1659,7 @@ impl Handler { fn handle_delete_cookies(&self) -> WebDriverResult { let (sender, receiver) = ipc::channel().unwrap(); let cmd = WebDriverScriptCommand::DeleteCookies(sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; match wait_for_script_response(receiver)? { Ok(_) => Ok(WebDriverResponse::Void), Err(error) => Err(WebDriverError::new(error, "")), @@ -1712,7 +1716,7 @@ impl Handler { let (sender, receiver) = ipc::channel().unwrap(); let cmd = WebDriverScriptCommand::GetPageSource(sender); - self.browsing_context_script_command(cmd)?; + self.browsing_context_script_command::(cmd)?; match wait_for_script_response(receiver)? { Ok(source) => Ok(WebDriverResponse::Generic(ValueResponse( @@ -1802,7 +1806,7 @@ impl Handler { let (sender, receiver) = ipc::channel().unwrap(); let command = WebDriverScriptCommand::ExecuteScript(script, sender); - self.browsing_context_script_command(command)?; + self.browsing_context_script_command::(command)?; let result = wait_for_script_response(receiver)?; self.postprocess_js_result(result) } @@ -1846,7 +1850,7 @@ impl Handler { let (sender, receiver) = ipc::channel().unwrap(); let command = WebDriverScriptCommand::ExecuteAsyncScript(script, sender); - self.browsing_context_script_command(command)?; + self.browsing_context_script_command::(command)?; let result = wait_for_script_response(receiver)?; self.postprocess_js_result(result) } @@ -1933,7 +1937,7 @@ impl Handler { // Steps 1 - 7 let command = WebDriverScriptCommand::ElementClick(element.to_string(), sender); - self.browsing_context_script_command(command)?; + self.browsing_context_script_command::(command)?; match wait_for_script_response(receiver)? { Ok(element_id) => match element_id { @@ -2086,7 +2090,7 @@ impl Handler { let (sender, receiver) = ipc::channel().unwrap(); let command = WebDriverScriptCommand::GetBoundingClientRect(element.to_string(), sender); - self.browsing_context_script_command(command)?; + self.browsing_context_script_command::(command)?; match wait_for_script_response(receiver)? { Ok(rect) => { diff --git a/tests/wpt/meta/webdriver/tests/classic/is_element_enabled/enabled.py.ini b/tests/wpt/meta/webdriver/tests/classic/is_element_enabled/enabled.py.ini index 362bc856d4a..1fc6b68dc9f 100644 --- a/tests/wpt/meta/webdriver/tests/classic/is_element_enabled/enabled.py.ini +++ b/tests/wpt/meta/webdriver/tests/classic/is_element_enabled/enabled.py.ini @@ -2,9 +2,6 @@ [test_no_browsing_context] expected: FAIL - [test_stale_element_reference[child_context\]] - expected: FAIL - [test_option_with_select[disabled\]] expected: FAIL diff --git a/tests/wpt/meta/webdriver/tests/classic/is_element_selected/selected.py.ini b/tests/wpt/meta/webdriver/tests/classic/is_element_selected/selected.py.ini index 5020632dabd..e944d67084b 100644 --- a/tests/wpt/meta/webdriver/tests/classic/is_element_selected/selected.py.ini +++ b/tests/wpt/meta/webdriver/tests/classic/is_element_selected/selected.py.ini @@ -1,6 +1,3 @@ [selected.py] [test_no_browsing_context] expected: FAIL - - [test_stale_element_reference[child_context\]] - expected: FAIL