diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 580c37954e0..2bcb1d23056 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -2461,7 +2461,7 @@ impl ScriptThread { ) }, WebDriverScriptCommand::GetElementText(node_id, reply) => { - webdriver_handlers::handle_get_text(&documents, pipeline_id, node_id, reply) + webdriver_handlers::handle_get_text(&documents, pipeline_id, node_id, reply, can_gc) }, WebDriverScriptCommand::GetElementInViewCenterPoint(node_id, reply) => { webdriver_handlers::handle_get_element_in_view_center_point( diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index 827276cd0e7..67fc12abbfb 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -71,6 +71,7 @@ use crate::script_module::ScriptFetchOptions; use crate::script_runtime::{CanGc, JSContext as SafeJSContext}; use crate::script_thread::ScriptThread; +/// fn find_node_by_unique_id( documents: &DocumentCollection, pipeline: PipelineId, @@ -1217,16 +1218,21 @@ pub(crate) fn handle_get_bounding_client_rect( .unwrap(); } +/// pub(crate) fn handle_get_text( documents: &DocumentCollection, pipeline: PipelineId, node_id: String, reply: IpcSender>, + can_gc: CanGc, ) { reply .send( - find_node_by_unique_id(documents, pipeline, node_id) - .map(|node| node.GetTextContent().map_or("".to_owned(), String::from)), + find_node_by_unique_id(documents, pipeline, node_id).map(|node| { + node.downcast::() + .map(|element| element.InnerText(can_gc).to_string()) + .unwrap_or_else(|| node.GetTextContent().map_or("".to_owned(), String::from)) + }), ) .unwrap(); } diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index c9d27fe7574..b364b88423b 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -1318,6 +1318,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);