Workaround test_driver.actions not working with shadow DOM.

This works around https://github.com/web-platform-tests/wpt/issues/41257
and enables the tests.

Differential Revision: https://phabricator.services.mozilla.com/D203152

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1878104
gecko-commit: 343b540522ec81232a7eaa98161c1065d3391796
gecko-reviewers: dholbert
diff --git a/html/semantics/popovers/resources/popover-utils.js b/html/semantics/popovers/resources/popover-utils.js
index bfc1f89..96ac7e0 100644
--- a/html/semantics/popovers/resources/popover-utils.js
+++ b/html/semantics/popovers/resources/popover-utils.js
@@ -7,9 +7,13 @@
 }
 
 async function clickOn(element) {
-  const actions = new test_driver.Actions();
   await waitForRender();
-  await actions.pointerMove(0, 0, {origin: element})
+  let rect = element.getBoundingClientRect();
+  let actions = new test_driver.Actions();
+  // FIXME: Switch to pointerMove(0, 0, {origin: element}) once
+  // https://github.com/web-platform-tests/wpt/issues/41257 is fixed.
+  await actions
+      .pointerMove(Math.round(rect.x + rect.width / 2), Math.round(rect.y + rect.height / 2), {})
       .pointerDown({button: actions.ButtonType.LEFT})
       .pointerUp({button: actions.ButtonType.LEFT})
       .send();