diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index 8a25ba1827f..5eb3fa42a84 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -950,11 +950,19 @@ impl Handler { } fn handle_is_enabled(&self, element: &WebElement) -> WebDriverResult { - let (sender, receiver) = ipc::channel().unwrap(); + // Step 1. If session's current browsing context is no longer open, + // return error with error code no such window. + let browsing_context = self.session()?.browsing_context_id; + self.verify_browsing_context_is_open(browsing_context)?; + // Step 2. Try to handle any user prompts with session. + let webview_id = self.session()?.webview_id; + self.handle_any_user_prompts(webview_id)?; + + let (sender, receiver) = ipc::channel().unwrap(); self.browsing_context_script_command( WebDriverScriptCommand::IsEnabled(element.to_string(), sender), - VerifyBrowsingContextIsOpen::Yes, + VerifyBrowsingContextIsOpen::No, )?; match wait_for_ipc_response(receiver)? { @@ -966,11 +974,19 @@ impl Handler { } fn handle_is_selected(&self, element: &WebElement) -> WebDriverResult { - let (sender, receiver) = ipc::channel().unwrap(); + // Step 1. If session's current browsing context is no longer open, + // return error with error code no such window. + let browsing_context = self.session()?.browsing_context_id; + self.verify_browsing_context_is_open(browsing_context)?; + // Step 2. Try to handle any user prompts with session. + let webview_id = self.session()?.webview_id; + self.handle_any_user_prompts(webview_id)?; + + let (sender, receiver) = ipc::channel().unwrap(); self.browsing_context_script_command( WebDriverScriptCommand::IsSelected(element.to_string(), sender), - VerifyBrowsingContextIsOpen::Yes, + VerifyBrowsingContextIsOpen::No, )?; match wait_for_ipc_response(receiver)? { @@ -2233,13 +2249,7 @@ impl Handler { } fn take_screenshot(&self, rect: Option>) -> WebDriverResult { - // Step 1. If session's current top-level browsing context is no longer open, - // return error with error code no such window. let webview_id = self.session()?.webview_id; - self.verify_top_level_browsing_context_is_open(webview_id)?; - - self.handle_any_user_prompts(webview_id)?; - let mut img = None; let interval = 1000; @@ -2292,6 +2302,14 @@ impl Handler { } fn handle_take_screenshot(&self) -> WebDriverResult { + // Step 1. If session's current top-level browsing context is no longer open, + // return error with error code no such window. + let webview_id = self.session()?.webview_id; + self.verify_top_level_browsing_context_is_open(webview_id)?; + + self.handle_any_user_prompts(webview_id)?; + + // Step 2 let encoded = self.take_screenshot(None)?; Ok(WebDriverResponse::Generic(ValueResponse( @@ -2305,13 +2323,24 @@ impl Handler { ) -> WebDriverResult { let (sender, receiver) = ipc::channel().unwrap(); + // Step 1. If session's current top-level browsing context is no longer open, + // return error with error code no such window. + let webview_id = self.session()?.webview_id; + self.verify_top_level_browsing_context_is_open(webview_id)?; + + // Step 2. Try to handle any user prompts with session. + self.handle_any_user_prompts(webview_id)?; + + // Step 3 - 4 let cmd = WebDriverScriptCommand::GetBoundingClientRect(element.to_string(), sender); - self.browsing_context_script_command(cmd, VerifyBrowsingContextIsOpen::Yes)?; + self.browsing_context_script_command(cmd, VerifyBrowsingContextIsOpen::No)?; match wait_for_ipc_response(receiver)? { Ok(rect) => { + // Step 5 let encoded = self.take_screenshot(Some(Rect::from_untyped(&rect)))?; + // Step 6 return success with data encoded string. Ok(WebDriverResponse::Generic(ValueResponse( serde_json::to_value(encoded)?, ))) diff --git a/tests/wpt/meta/webdriver/tests/classic/is_element_enabled/user_prompts.py.ini b/tests/wpt/meta/webdriver/tests/classic/is_element_enabled/user_prompts.py.ini deleted file mode 100644 index 0b2f6ad9d2a..00000000000 --- a/tests/wpt/meta/webdriver/tests/classic/is_element_enabled/user_prompts.py.ini +++ /dev/null @@ -1,2 +0,0 @@ -[user_prompts.py] - expected: TIMEOUT diff --git a/tests/wpt/meta/webdriver/tests/classic/is_element_selected/user_prompts.py.ini b/tests/wpt/meta/webdriver/tests/classic/is_element_selected/user_prompts.py.ini deleted file mode 100644 index 0b2f6ad9d2a..00000000000 --- a/tests/wpt/meta/webdriver/tests/classic/is_element_selected/user_prompts.py.ini +++ /dev/null @@ -1,2 +0,0 @@ -[user_prompts.py] - expected: TIMEOUT diff --git a/tests/wpt/meta/webdriver/tests/classic/take_element_screenshot/user_prompts.py.ini b/tests/wpt/meta/webdriver/tests/classic/take_element_screenshot/user_prompts.py.ini deleted file mode 100644 index 0b2f6ad9d2a..00000000000 --- a/tests/wpt/meta/webdriver/tests/classic/take_element_screenshot/user_prompts.py.ini +++ /dev/null @@ -1,2 +0,0 @@ -[user_prompts.py] - expected: TIMEOUT