From aa098ba2a305aa086bcf588d283407b67a16e67f Mon Sep 17 00:00:00 2001 From: batu_hoang <55729155+longvatrong111@users.noreply.github.com> Date: Tue, 15 Jul 2025 12:14:03 +0800 Subject: [PATCH] webdriver: Allow script thread to fail to send response for `ExecuteScript` (#38054) When script thread executes script sent from webdriver, if an alert appears, webdriver can stop waiting for the script response and process the next command. This PR allows script thread to fail to send response for `ExecuteScript` if the channel is closed. cc: @xiaochengh Signed-off-by: batu_hoang --- components/script/webdriver_handlers.rs | 11 ++++++++--- .../classic/execute_script/execute.py.ini | 19 ------------------- .../classic/switch_to_window/switch.py.ini | 6 ------ 3 files changed, 8 insertions(+), 28 deletions(-) delete mode 100644 tests/wpt/meta/webdriver/tests/classic/switch_to_window/switch.py.ini diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index 1cd253d4eec..7c6677cc6b9 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -528,12 +528,17 @@ pub(crate) fn handle_execute_script( Err(WebDriverJSError::JSError) }; - reply.send(result).unwrap(); + if reply.send(result).is_err() { + info!("Webdriver might already be released by embedder before reply is sent"); + }; }, None => { - reply + if reply .send(Err(WebDriverJSError::BrowsingContextNotFound)) - .unwrap(); + .is_err() + { + info!("Webdriver might already be released by embedder before reply is sent"); + }; }, } } diff --git a/tests/wpt/meta/webdriver/tests/classic/execute_script/execute.py.ini b/tests/wpt/meta/webdriver/tests/classic/execute_script/execute.py.ini index ff13c80a5fe..d5462080853 100644 --- a/tests/wpt/meta/webdriver/tests/classic/execute_script/execute.py.ini +++ b/tests/wpt/meta/webdriver/tests/classic/execute_script/execute.py.ini @@ -1,25 +1,6 @@ [execute.py] - expected: TIMEOUT [test_no_browsing_context] expected: FAIL [test_opening_new_window_keeps_current_window_handle] expected: FAIL - - [test_abort_by_user_prompt[alert\]] - expected: FAIL - - [test_abort_by_user_prompt[confirm\]] - expected: FAIL - - [test_abort_by_user_prompt[prompt\]] - expected: FAIL - - [test_abort_by_user_prompt_twice[alert\]] - expected: FAIL - - [test_abort_by_user_prompt_twice[confirm\]] - expected: FAIL - - [test_abort_by_user_prompt_twice[prompt\]] - expected: FAIL diff --git a/tests/wpt/meta/webdriver/tests/classic/switch_to_window/switch.py.ini b/tests/wpt/meta/webdriver/tests/classic/switch_to_window/switch.py.ini deleted file mode 100644 index ba3819d135b..00000000000 --- a/tests/wpt/meta/webdriver/tests/classic/switch_to_window/switch.py.ini +++ /dev/null @@ -1,6 +0,0 @@ -[switch.py] - [test_finds_exising_user_prompt_after_tab_switch[confirm\]] - expected: ERROR - - [test_finds_exising_user_prompt_after_tab_switch[prompt\]] - expected: ERROR