Bug 1317386 - Test pointer interactability of first element in paint order. r=automatedtester, a=test-only
authorAndreas Tolfsen <ato@mozilla.com>
Tue, 15 Nov 2016 11:21:32 +0000
changeset 352570 229a089df41414b71536dcbfadd93f0afd205f0d
parent 352569 54e23725434ea1aefd120b7d663a9ee16a113140
child 352571 0d440483f80c9b8072b3aa6b55e91824c92f7f61
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester, test-only
bugs1317386
milestone52.0a2
Bug 1317386 - Test pointer interactability of first element in paint order. r=automatedtester, a=test-only When returning the tree of interactable elemenets under the cursor, we want to test the first one against the passed element, not that there are _any_ interactable elements under the cursor. MozReview-Commit-ID: AUvKAWKHgZk
testing/marionette/element.js
testing/marionette/harness/marionette/tests/unit/test_click.py
--- a/testing/marionette/element.js
+++ b/testing/marionette/element.js
@@ -932,17 +932,17 @@ element.isInteractable = function(el) {
  * @param {DOMElement} el
  *     Element determine if is pointer-interactable.
  *
  * @return {boolean}
  *     True if interactable, false otherwise.
  */
 element.isPointerInteractable = function(el) {
   let tree = element.getInteractableElementTree(el, el.ownerDocument);
-  return tree.length > 0;
+  return tree[0] === el;
 };
 
 /**
  * Calculate the in-view centre point of the area of the given DOM client
  * rectangle that is inside the viewport.
  *
  * @param {DOMRect} rect
  *     Element off a DOMRect sequence produced by calling |getClientRects|
--- a/testing/marionette/harness/marionette/tests/unit/test_click.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_click.py
@@ -96,11 +96,105 @@ class TestClick(TestLegacyClick):
     checks.
     """
 
     def setUp(self):
         TestLegacyClick.setUp(self)
         self.marionette.delete_session()
         self.marionette.start_session({"specificationLevel": 1})
 
-    @skip("fails with spec compatible interactability checks")
-    def test_clicking_an_element_that_is_not_displayed_raises(self):
-        pass
+    def test_click_element_obscured_by_absolute_positioned_element(self):
+        self.marionette.navigate(inline("""
+            <style>
+            * { margin: 0; padding: 0; }
+            div { display: block; width: 100%; height: 100%; }
+            #obscured { background-color: blue }
+            #overlay { background-color: red; position: absolute; top: 0; }
+            </style>
+
+            <div id=obscured></div>
+            <div id=overlay></div>"""))
+
+        overlay = self.marionette.find_element(By.ID, "overlay")
+        obscured = self.marionette.find_element(By.ID, "obscured")
+
+        overlay.click()
+        with self.assertRaises(ElementNotVisibleException):
+            obscured.click()
+
+    def test_centre_outside_viewport_vertically(self):
+        self.marionette.navigate(inline("""
+            <style>
+            * { margin: 0; padding: 0; }
+            div {
+             display: block;
+             position: absolute;
+             background-color: blue;
+             width: 200px;
+             height: 200px;
+
+             /* move centre point off viewport vertically */
+             top: -105px;
+            }
+            </style>
+
+            <div></div>"""))
+
+        self.marionette.find_element(By.TAG_NAME, "div").click()
+
+    def test_centre_outside_viewport_horizontally(self):
+        self.marionette.navigate(inline("""
+            <style>
+            * { margin: 0; padding: 0; }
+            div {
+             display: block;
+             position: absolute;
+             background-color: blue;
+             width: 200px;
+             height: 200px;
+
+             /* move centre point off viewport horizontally */
+             left: -105px;
+            }
+            </style>
+
+            <div></div>"""))
+
+        self.marionette.find_element(By.TAG_NAME, "div").click()
+
+    def test_centre_outside_viewport(self):
+        self.marionette.navigate(inline("""
+            <style>
+            * { margin: 0; padding: 0; }
+            div {
+             display: block;
+             position: absolute;
+             background-color: blue;
+             width: 200px;
+             height: 200px;
+
+             /* move centre point off viewport */
+             left: -105px;
+             top: -105px;
+            }
+            </style>
+
+            <div></div>"""))
+
+        self.marionette.find_element(By.TAG_NAME, "div").click()
+
+    def test_css_transforms(self):
+        self.marionette.navigate(inline("""
+            <style>
+            * { margin: 0; padding: 0; }
+            div {
+             display: block;
+             background-color: blue;
+             width: 200px;
+             height: 200px;
+
+             transform: translateX(-105px);
+            }
+            </style>
+
+            <div></div>"""))
+
+        self.marionette.find_element(By.TAG_NAME, "div").click()