Implement GetComputedRole in wd (#36552)

Implement Webdriver Get Computed Role.

[spec](https://w3c.github.io/webdriver/#get-computed-role)

Signed-off-by: Kenzie Raditya Tirtarahardja <kenzieradityatirtarahardja.18@gmail.com>
Co-authored-by: Kenzie Raditya Tirtarahardja <kenzieradityatirtarahardja.18@gmail.com>
This commit is contained in:
Kenzie Raditya Tirtarahardja 2025-04-16 11:55:15 +08:00 committed by GitHub
parent cef7aa58ec
commit 15199ba2ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 40 additions and 0 deletions

View file

@ -2253,6 +2253,14 @@ impl ScriptThread {
WebDriverScriptCommand::GetActiveElement(reply) => {
webdriver_handlers::handle_get_active_element(&documents, pipeline_id, reply)
},
WebDriverScriptCommand::GetComputedRole(node_id, reply) => {
webdriver_handlers::handle_get_computed_role(
&documents,
pipeline_id,
node_id,
reply,
)
},
WebDriverScriptCommand::GetPageSource(reply) => {
webdriver_handlers::handle_get_page_source(&documents, pipeline_id, reply, can_gc)
},

View file

@ -799,6 +799,24 @@ pub(crate) fn handle_get_active_element(
.unwrap();
}
pub(crate) fn handle_get_computed_role(
documents: &DocumentCollection,
pipeline: PipelineId,
node_id: String,
reply: IpcSender<Result<Option<String>, ErrorStatus>>,
) {
reply
.send(
find_node_by_unique_id(documents, pipeline, node_id).and_then(|node| {
match node.downcast::<Element>() {
Some(element) => Ok(element.GetRole().map(String::from)),
None => Err(ErrorStatus::UnknownError),
}
}),
)
.unwrap();
}
pub(crate) fn handle_get_page_source(
documents: &DocumentCollection,
pipeline: PipelineId,