From 18e9f4574a4d9a0766105145ff5a42c0347dc6f2 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 10 Dec 2024 15:50:42 +0100 Subject: [PATCH] test: Use real mouse events with Chromium in the shell BiDi mouse events work fine on the top-level document (i.e. not in frames). So let's use them to test the shell. This gets rid of the recent TestHostSwitching mouse move hack (reverts commit b5b8c6df31e26), and we can also run `TestPages.testPageStatus` again (reverts commit 529e3347aa11b6). --- test/common/testlib.py | 4 ++-- test/common/webdriver_bidi.py | 3 +++ test/verify/check-pages | 1 - test/verify/check-shell-host-switching | 8 -------- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/test/common/testlib.py b/test/common/testlib.py index c3334ad5941c..cc8c6c73d223 100644 --- a/test/common/testlib.py +++ b/test/common/testlib.py @@ -526,11 +526,11 @@ def mouse( # HACK: Chromium clicks don't work with iframes; use our old "synthesize MouseEvent" approach # https://issues.chromium.org/issues/359616812 # TODO: x and y are not currently implemented: webdriver (0, 0) is the element's center, not top left corner - if self.browser == "chromium" or x != 0 or y != 0: + if (self.browser == "chromium" and not self.driver.in_top_context()) or x != 0 or y != 0: self.call_js_func('ph_mouse', selector, event, x, y, btn, ctrlKey, shiftKey, altKey, metaKey) return - # For Firefox and regular clicks, use the BiDi API, which is more realistic -- it doesn't + # For Firefox and top frame with Chromium, use the BiDi API, which is more realistic -- it doesn't # sidestep the browser element = self.call_js_func('ph_find_scroll_into_view' if scrollVisible else 'ph_find', selector) diff --git a/test/common/webdriver_bidi.py b/test/common/webdriver_bidi.py index 396bdc5d108d..de7e36c70fd4 100644 --- a/test/common/webdriver_bidi.py +++ b/test/common/webdriver_bidi.py @@ -326,6 +326,9 @@ def switch_to_top(self) -> None: self.context = self.top_context log_command.info("← switch_to_top") + def in_top_context(self) -> bool: + return self.context == self.top_context + @contextlib.contextmanager def restore_context(self) -> Iterator[None]: saved = self.context diff --git a/test/verify/check-pages b/test/verify/check-pages index e115e8f8dd64..1205dce5635e 100755 --- a/test/verify/check-pages +++ b/test/verify/check-pages @@ -752,7 +752,6 @@ OnCalendar=daily with b.wait_timeout(60): b.wait_js_func("ph_plot_data_plateau", "pmcd", mem_avail * 0.85, mem_avail * 1.15, 15, "mem") - @testlib.skipBrowser("Headless chromium is missing the synthetic mouseenter", "chromium") def testPageStatus(self): b = self.browser diff --git a/test/verify/check-shell-host-switching b/test/verify/check-shell-host-switching index db4bf02186bf..94e029277457 100755 --- a/test/verify/check-shell-host-switching +++ b/test/verify/check-shell-host-switching @@ -183,14 +183,6 @@ class TestHostSwitching(testlib.MachineCase, HostSwitcherHelpers): b.wait_not_present("#nav-system.interact") b.set_layout("desktop") - # this looks different (focused) when the mouse is inside (default 0,0 possition), so move it away - # chromium is stubborn here, we *have* to move the real mouse, not just do this with synthetic MouseEvents - b.bidi("input.performActions", context=b.driver.context, actions=[{ - "id": "move-away", - "type": "pointer", - "parameters": {"pointerType": "mouse"}, - "actions": [{"type": "pointerMove", "x": 200, "y": 200, "origin": "viewport"}] - }]) b.assert_pixels("#hosts-sel", "hosts-sel-closed") b.click("#hosts-sel button")