From 616b86fb6d44c6e8f897aef4a0217101654b118b Mon Sep 17 00:00:00 2001 From: Euclid Ye Date: Thu, 7 Aug 2025 17:16:50 +0800 Subject: [PATCH] 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 17a269a8ade22ec768a566224b29cb4795e94fca due to script execution, and exposes new problem: https://github.com/servo/servo/pull/38497#discussion_r2257866612 --------- Signed-off-by: Euclid Ye --- components/script/webdriver_handlers.rs | 14 ++++++++++++-- .../tests/classic/element_clear/clear.py.ini | 3 --- .../element_click/interactability.py.ini | 3 --- .../tests/classic/element_click/select.py.ini | 18 ++++++++++++++++++ .../classic/element_click/shadow_dom.py.ini | 9 +++++++++ .../element_send_keys/form_controls.py.ini | 3 +++ .../element_send_keys/scroll_into_view.py.ini | 12 ------------ .../tests/classic/get_current_url/file.py.ini | 3 --- 8 files changed, 42 insertions(+), 23 deletions(-) delete mode 100644 tests/wpt/meta/webdriver/tests/classic/element_click/interactability.py.ini create mode 100644 tests/wpt/meta/webdriver/tests/classic/element_click/shadow_dom.py.ini delete mode 100644 tests/wpt/meta/webdriver/tests/classic/get_current_url/file.py.ini diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index 4d9ca1e18ae..e42dabc8215 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -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::() + .Contains(Some(paint_tree[0].upcast::())) + { + return Err(ErrorStatus::ElementClickIntercepted); + } // Step 8 for