summaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to 'testing')
-rw-r--r--testing/marionette/element.js16
-rw-r--r--testing/marionette/error.js21
-rw-r--r--testing/marionette/harness/marionette_harness/tests/unit/test_click.py17
-rw-r--r--testing/marionette/test_error.js20
4 files changed, 63 insertions, 11 deletions
diff --git a/testing/marionette/element.js b/testing/marionette/element.js
index 8e66ee6df..9687fb27d 100644
--- a/testing/marionette/element.js
+++ b/testing/marionette/element.js
@@ -953,6 +953,12 @@ element.getContainer = function (el) {
* pointer-interactable, if it is found somewhere in the
* |elementsFromPoint| list at |el|'s in-view centre coordinates.
*
+ * Before running the check, we change |el|'s pointerEvents style property
+ * to "auto", since elements without pointer events enabled do not turn
+ * up in the paint tree we get from document.elementsFromPoint. This is
+ * a specialisation that is only relevant when checking if the element is
+ * in view.
+ *
* @param {Element} el
* Element to check if is in view.
*
@@ -960,8 +966,14 @@ element.getContainer = function (el) {
* True if |el| is inside the viewport, or false otherwise.
*/
element.isInView = function (el) {
- let tree = element.getPointerInteractablePaintTree(el);
- return tree.includes(el);
+ let originalPointerEvents = el.style.pointerEvents;
+ try {
+ el.style.pointerEvents = "auto";
+ const tree = element.getPointerInteractablePaintTree(el);
+ return tree.includes(el);
+ } finally {
+ el.style.pointerEvents = originalPointerEvents;
+ }
};
/**
diff --git a/testing/marionette/error.js b/testing/marionette/error.js
index 97cc3fb25..c36dace25 100644
--- a/testing/marionette/error.js
+++ b/testing/marionette/error.js
@@ -260,10 +260,23 @@ class ElementClickInterceptedError extends WebDriverError {
if (obscuredEl && coords) {
const doc = obscuredEl.ownerDocument;
const overlayingEl = doc.elementFromPoint(coords.x, coords.y);
- msg = error.pprint`Element ${obscuredEl} is not clickable ` +
- `at point (${coords.x},${coords.y}) ` +
- error.pprint`because another element ${overlayingEl} ` +
- `obscures it`;
+
+ switch (obscuredEl.style.pointerEvents) {
+ case "none":
+ msg = error.pprint`Element ${obscuredEl} is not clickable ` +
+ `at point (${coords.x},${coords.y}) ` +
+ `because it does not have pointer events enabled, ` +
+ error.pprint`and element ${overlayingEl} ` +
+ `would receive the click instead`;
+ break;
+
+ default:
+ msg = error.pprint`Element ${obscuredEl} is not clickable ` +
+ `at point (${coords.x},${coords.y}) ` +
+ error.pprint`because another element ${overlayingEl} ` +
+ `obscures it`;
+ break;
+ }
}
super(msg);
diff --git a/testing/marionette/harness/marionette_harness/tests/unit/test_click.py b/testing/marionette/harness/marionette_harness/tests/unit/test_click.py
index d03062e85..06019834a 100644
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_click.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_click.py
@@ -252,3 +252,20 @@ class TestClick(TestLegacyClick):
with self.assertRaises(errors.ElementClickInterceptedException):
obscured.click()
self.assertFalse(self.marionette.execute_script("return window.clicked", sandbox=None))
+
+ def test_pointer_events_none(self):
+ self.marionette.navigate(inline("""
+ <button style="pointer-events: none">click me</button>
+ <script>
+ window.clicked = false;
+ let button = document.querySelector("button");
+ button.addEventListener("click", () => window.clicked = true);
+ </script>
+ """))
+ button = self.marionette.find_element(By.TAG_NAME, "button")
+ self.assertEqual("none", button.value_of_css_property("pointer-events"))
+
+ with self.assertRaisesRegexp(errors.ElementClickInterceptedException,
+ "does not have pointer events enabled"):
+ button.click()
+ self.assertFalse(self.marionette.execute_script("return window.clicked", sandbox=None))
diff --git a/testing/marionette/test_error.js b/testing/marionette/test_error.js
index f27212637..a905f02f0 100644
--- a/testing/marionette/test_error.js
+++ b/testing/marionette/test_error.js
@@ -209,15 +209,25 @@ add_test(function test_ElementClickInterceptedError() {
return otherEl;
},
},
+ style: {
+ pointerEvents: "auto",
+ }
};
- let err = new ElementClickInterceptedError(obscuredEl, {x: 1, y: 2});
- equal("ElementClickInterceptedError", err.name);
+ let err1 = new ElementClickInterceptedError(obscuredEl, {x: 1, y: 2});
+ equal("ElementClickInterceptedError", err1.name);
equal("Element <b> is not clickable at point (1,2) " +
"because another element <a> obscures it",
- err.message);
- equal("element click intercepted", err.status);
- ok(err instanceof WebDriverError);
+ err1.message);
+ equal("element click intercepted", err1.status);
+ ok(err1 instanceof WebDriverError);
+
+ obscuredEl.style.pointerEvents = "none";
+ let err2 = new ElementClickInterceptedError(obscuredEl, {x: 1, y: 2});
+ equal("Element <b> is not clickable at point (1,2) " +
+ "because it does not have pointer events enabled, " +
+ "and element <a> would receive the click instead",
+ err2.message);
run_next_test();
});