webdriver: Simplify get_element_pointer_interactable_paint_tree (#38469)

Add step 1 and simplify step 2 - 5 to remove duplicate `GetClientRects`
call.

There is some issue with spec to be updated later.

Testing: No behaviour change.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
Euclid Ye 2025-08-06 13:36:34 +08:00 committed by GitHub
parent 4b7d659cf6
commit 62b181dc85
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 168 additions and 45 deletions

View file

@ -1922,24 +1922,23 @@ fn get_element_pointer_interactable_paint_tree(
document: &Document,
can_gc: CanGc,
) -> Vec<DomRoot<Element>> {
// Step 2. Let rectangles be the DOMRect sequence returned by calling getClientRects()
let rect = element.GetClientRects(can_gc);
if rect.first().is_some() {
// Step 4. Let center point be the in-view center point of
// the first indexed element in rectangles.
match get_element_in_view_center_point(element, can_gc) {
// Step 5. Return the elements from point given the coordinates center point
Some(center_point) => document.ElementsFromPoint(
Finite::wrap(center_point.x as f64),
Finite::wrap(center_point.y as f64),
),
None => Vec::new(),
}
} else {
// Step 3. If rectangles has the length of 0, return an empty sequence
Vec::new()
// Step 1. If element is not in the same tree as session's
// current browsing context's active document, return an empty sequence.
if !element.is_connected() {
return Vec::new();
}
// Step 2 - 5: Return "elements from point" w.r.t. in-view center point of element.
// Spec has bugs in description and can be simplified.
// The original step 4 "compute in-view center point" takes an element as argument
// which internally computes first DOMRect of getClientRects
get_element_in_view_center_point(element, can_gc).map_or(Vec::new(), |center_point| {
document.ElementsFromPoint(
Finite::wrap(center_point.x as f64),
Finite::wrap(center_point.y as f64),
)
})
}
pub(crate) fn handle_is_enabled(

View file

@ -1,6 +1,6 @@
[add.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR
[test_cookie_unsupported_scheme[about\]]
expected: FAIL

View file

@ -1,3 +1,3 @@
[delete.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR

View file

@ -10,3 +10,9 @@
[test_dismiss_in_popup_window]
expected: FAIL
[test_no_browsing_context]
expected: ERROR
[test_dismiss_alert]
expected: FAIL

View file

@ -0,0 +1,54 @@
[user_prompts.py]
[test_accept[alert-None\]]
expected: FAIL
[test_accept[confirm-True\]]
expected: FAIL
[test_accept[prompt-\]]
expected: FAIL
[test_accept_and_notify[alert-None\]]
expected: FAIL
[test_accept_and_notify[confirm-True\]]
expected: FAIL
[test_accept_and_notify[prompt-\]]
expected: FAIL
[test_dismiss[alert-None\]]
expected: FAIL
[test_dismiss[confirm-False\]]
expected: FAIL
[test_dismiss[prompt-None\]]
expected: FAIL
[test_dismiss_and_notify[alert-None\]]
expected: FAIL
[test_dismiss_and_notify[confirm-False\]]
expected: FAIL
[test_dismiss_and_notify[prompt-None\]]
expected: FAIL
[test_ignore[alert\]]
expected: FAIL
[test_ignore[confirm\]]
expected: FAIL
[test_ignore[prompt\]]
expected: FAIL
[test_default[alert-None\]]
expected: FAIL
[test_default[confirm-False\]]
expected: FAIL
[test_default[prompt-None\]]
expected: FAIL

View file

@ -1,3 +1,3 @@
[click.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR

View file

@ -1,4 +1,5 @@
[navigate.py]
expected: TIMEOUT
[test_link_hash]
expected: FAIL

View file

@ -0,0 +1,21 @@
[form_controls.py]
[test_input]
expected: FAIL
[test_textarea]
expected: FAIL
[test_input_append]
expected: FAIL
[test_textarea_append]
expected: FAIL
[test_input_insert_when_focused]
expected: FAIL
[test_textarea_insert_when_focused]
expected: FAIL
[test_date]
expected: FAIL

View file

@ -2,9 +2,6 @@
[test_document_element_is_interactable]
expected: FAIL
[test_readonly_element]
expected: FAIL
[test_display_none]
expected: FAIL
@ -13,3 +10,9 @@
[test_hidden]
expected: FAIL
[test_iframe_is_interactable]
expected: FAIL
[test_transparent_element]
expected: FAIL

View file

@ -0,0 +1,9 @@
[user_prompts.py]
[test_accept[confirm-True\]]
expected: FAIL
[test_accept[prompt-\]]
expected: FAIL
[test_dismiss[prompt-None\]]
expected: FAIL

View file

@ -1,3 +1,3 @@
[find.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR

View file

@ -1,6 +1,6 @@
[find.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR
[test_parent_htmldocument]
expected: FAIL

View file

@ -1,6 +1,3 @@
[get.py]
[test_get_confirm_text]
expected: FAIL
[test_get_prompt_text]
expected: FAIL

View file

@ -1,6 +1,6 @@
[get.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR
[test_computed_roles[<article>foo</article>-article-article\]]
expected: FAIL

View file

@ -0,0 +1,3 @@
[get.py]
[test_no_browsing_context]
expected: ERROR

View file

@ -1,3 +1,3 @@
[get.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR

View file

@ -1,6 +1,6 @@
[get.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR
[test_web_reference[shadowRoot-ShadowRoot\]]
expected: FAIL

View file

@ -1,3 +1,3 @@
[get.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR

View file

@ -1,3 +1,3 @@
[get.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR

View file

@ -1,6 +1,6 @@
[get.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR
[test_get_element_tag_name]
expected: FAIL

View file

@ -1,6 +1,6 @@
[get.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR
[test_shadow_root_slot[custom outside\]]
expected: FAIL

View file

@ -1,6 +1,6 @@
[get.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR
[test_get_named_session_cookie]
expected: FAIL

View file

@ -1,3 +1,3 @@
[source.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR

View file

@ -0,0 +1,3 @@
[get.py]
[test_no_browsing_context]
expected: ERROR

View file

@ -0,0 +1,3 @@
[get.py]
[test_no_browsing_context]
expected: ERROR

View file

@ -0,0 +1,3 @@
[get.py]
[test_no_browsing_context]
expected: ERROR

View file

@ -1,6 +1,6 @@
[enabled.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR
[test_option_with_select[disabled\]]
expected: FAIL

View file

@ -10,3 +10,6 @@
[test_maximize_twice_is_idempotent]
expected: FAIL
[test_no_browsing_context]
expected: ERROR

View file

@ -3,7 +3,7 @@
expected: FAIL
[test_no_browsing_context]
expected: FAIL
expected: ERROR
[test_response_payload]
expected: FAIL

View file

@ -0,0 +1,3 @@
[new.py]
[test_no_browsing_context]
expected: ERROR

View file

@ -1,6 +1,6 @@
[key.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR
[test_key_down_closes_browsing_context]
expected: FAIL

View file

@ -1,6 +1,6 @@
[pointer_mouse.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR
[test_pointer_down_closes_browsing_context]
expected: FAIL

View file

@ -1,6 +1,6 @@
[pointer_touch.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR
[test_pointer_down_closes_browsing_context]
expected: FAIL

View file

@ -3,7 +3,7 @@
expected: FAIL
[test_no_browsing_context]
expected: FAIL
expected: ERROR
[test_html_document]
expected: FAIL

View file

@ -1,3 +1,3 @@
[release.py]
[test_no_browsing_context]
expected: FAIL
expected: ERROR

View file

@ -16,3 +16,6 @@
[test_send_alert_text[Fed\\terer\]]
expected: FAIL
[test_unexpected_alert]
expected: FAIL

View file

@ -1,9 +1,12 @@
[switch.py]
[test_no_browsing_context[0\]]
expected: FAIL
expected: ERROR
[test_no_browsing_context[id2\]]
expected: FAIL
[test_find_element_while_frame_is_still_loading]
expected: FAIL
[test_no_browsing_context[None\]]
expected: ERROR

View file

@ -0,0 +1,3 @@
[switch.py]
[test_no_browsing_context]
expected: FAIL

View file

@ -0,0 +1,3 @@
[screenshot.py]
[test_no_browsing_context]
expected: ERROR

View file

@ -0,0 +1,3 @@
[screenshot.py]
[test_no_browsing_context]
expected: ERROR