webdriver: Check if container is obscured for "Element Click" (#38497)

Implement step 7 of [Element
Click](https://w3c.github.io/webdriver/#element-click): check whether
container is obscured.

Testing: `/webdriver/tests/classic/element_click/interactability.py` can
now fully pass. Other changes are combined effect with
17a269a8ad due to script execution, and
exposes new problem:
https://github.com/servo/servo/pull/38497#discussion_r2257866612

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
Euclid Ye 2025-08-07 17:16:50 +08:00 committed by GitHub
parent b23cf9c6cd
commit 616b86fb6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 42 additions and 23 deletions

View file

@ -1846,8 +1846,18 @@ pub(crate) fn handle_element_click(
return Err(ErrorStatus::ElementNotInteractable);
}
// Step 7
// TODO: return error if obscured
// Step 7. If element's container is obscured by another element,
// return error with error code element click intercepted.
// https://w3c.github.io/webdriver/#dfn-obscuring
// An element is obscured if the pointer-interactable paint tree is empty,
// or the first element in this tree is not an inclusive descendant of itself.
// `paint_tree` is guaranteed not empty as element is "in view".
if !container
.upcast::<Node>()
.Contains(Some(paint_tree[0].upcast::<Node>()))
{
return Err(ErrorStatus::ElementClickIntercepted);
}
// Step 8 for <option> element.
match element.downcast::<HTMLOptionElement>() {

View file

@ -10,6 +10,3 @@
[test_designmode]
expected: FAIL
[test_scroll_into_view]
expected: FAIL

View file

@ -1,3 +0,0 @@
[interactability.py]
[test_element_intercepted]
expected: FAIL

View file

@ -13,3 +13,21 @@
[test_out_of_view_dropdown]
expected: FAIL
[test_click_multiple_option]
expected: FAIL
[test_click_preselected_multiple_option]
expected: FAIL
[test_click_multiple_does_not_deselect_others]
expected: FAIL
[test_click_selected_multiple_option]
expected: FAIL
[test_out_of_view_multiple]
expected: FAIL
[test_option_disabled]
expected: FAIL

View file

@ -0,0 +1,9 @@
[shadow_dom.py]
[test_shadow_element_click[host_element\]]
expected: FAIL
[test_nested_shadow_element_click[outer_element\]]
expected: FAIL
[test_nested_shadow_element_click[inner_element\]]
expected: FAIL

View file

@ -16,3 +16,6 @@
[test_date]
expected: FAIL
[test_textarea_append]
expected: FAIL

View file

@ -1,24 +1,12 @@
[scroll_into_view.py]
[test_element_outside_of_scrollable_viewport]
expected: FAIL
[test_contenteditable_element_outside_of_scrollable_viewport]
expected: FAIL
[test_element_already_in_viewport[{block: 'start'}\]]
expected: FAIL
[test_element_already_in_viewport[{block: 'center'}\]]
expected: FAIL
[test_element_already_in_viewport[{block: 'end'}\]]
expected: FAIL
[test_element_already_in_viewport[{block: 'nearest'}\]]
expected: FAIL
[test_element_just_outside_viewport[Just above viewport\]]
expected: FAIL
[test_element_just_outside_viewport[Just below viewport\]]
expected: FAIL

View file

@ -1,3 +0,0 @@
[file.py]
[test_get_current_url_file_protocol]
expected: ERROR