Bug 1359059 - Skip visibility checks when clicking in XUL; r=whimboo
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 24 Apr 2017 15:01:41 +0100
changeset 354777 c2c1bba57c7bd104bf1535fdde87a64ab034fffb
parent 354776 325df3ebf1a679b1eb548f312dc7b88ed862c197
child 354778 9eea9af9e21e4e7534c3622192ae29644dcba0e2
push id41444
push useratolfsen@mozilla.com
push dateTue, 25 Apr 2017 16:03:21 +0000
treeherderautoland@c2c1bba57c7b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1359059
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1359059 - Skip visibility checks when clicking in XUL; r=whimboo This patch removes the call to element.isVisible when clicking XUL elements because it does not do anything useful. element.isVisible skips the Selenium atom.isElementDisplayed check for XUL elements and runs a few web content/viewport centric tests that always pass in XUL. It also splits the chrome click out to a separate function to avoid a few if-conditions. MozReview-Commit-ID: EkcwT77ku3C
testing/marionette/interaction.js
--- a/testing/marionette/interaction.js
+++ b/testing/marionette/interaction.js
@@ -111,17 +111,19 @@ this.interaction = {};
  *     in |specCompat| mode.
  * @throws {ElementNotAccessibleError}
  *     If |strict| is true and element is not accessible.
  * @throws {InvalidElementStateError}
  *     If |el| is not enabled.
  */
 interaction.clickElement = function* (el, strict = false, specCompat = false) {
   const a11y = accessibility.get(strict);
-  if (specCompat) {
+  if (element.isXULElement(el)) {
+    yield chromeClick(el, a11y);
+  } else if (specCompat) {
     yield webdriverClickElement(el, a11y);
   } else {
     yield seleniumClickElement(el, a11y);
   }
 };
 
 function* webdriverClickElement (el, a11y) {
   const win = getWindow(el);
@@ -161,42 +163,48 @@ function* webdriverClickElement (el, a11
 
   yield a11y.getAccessible(el, true).then(acc => {
     a11y.assertVisible(acc, el, true);
     a11y.assertEnabled(acc, el, true);
     a11y.assertActionable(acc, el);
   });
 
   // step 8
-
-  // chrome elements
-  if (element.isXULElement(el)) {
-    if (el.localName == "option") {
-      interaction.selectOption(el);
-    } else {
-      el.click();
-    }
-
-  // content elements
+  if (el.localName == "option") {
+    interaction.selectOption(el);
   } else {
-    if (el.localName == "option") {
-      interaction.selectOption(el);
-    } else {
-      event.synthesizeMouseAtPoint(clickPoint.x, clickPoint.y, {}, win);
-    }
+    event.synthesizeMouseAtPoint(clickPoint.x, clickPoint.y, {}, win);
   }
 
   // step 9
   yield interaction.flushEventLoop(win);
 
   // step 10
   // TODO(ato): if the click causes navigation,
   // run post-navigation checks
 }
 
+function* chromeClick (el, a11y) {
+  if (!atom.isElementEnabled(el)) {
+    throw new InvalidElementStateError("Element is not enabled");
+  }
+
+  yield a11y.getAccessible(el, true).then(acc => {
+    a11y.assertVisible(acc, el, true);
+    a11y.assertEnabled(acc, el, true);
+    a11y.assertActionable(acc, el);
+  });
+
+  if (el.localName == "option") {
+    interaction.selectOption(el);
+  } else {
+    el.click();
+  }
+}
+
 function* seleniumClickElement (el, a11y) {
   let win = getWindow(el);
 
   let visibilityCheckEl  = el;
   if (el.localName == "option") {
     visibilityCheckEl = element.getContainer(el);
   }
 
@@ -209,34 +217,23 @@ function* seleniumClickElement (el, a11y
   }
 
   yield a11y.getAccessible(el, true).then(acc => {
     a11y.assertVisible(acc, el, true);
     a11y.assertEnabled(acc, el, true);
     a11y.assertActionable(acc, el);
   });
 
-  // chrome elements
-  if (element.isXULElement(el)) {
-    if (el.localName == "option") {
-      interaction.selectOption(el);
-    } else {
-      el.click();
-    }
-
-  // content elements
+  if (el.localName == "option") {
+    interaction.selectOption(el);
   } else {
-    if (el.localName == "option") {
-      interaction.selectOption(el);
-    } else {
-      let rects = el.getClientRects();
-      let centre = element.getInViewCentrePoint(rects[0], win);
-      let opts = {};
-      event.synthesizeMouseAtPoint(centre.x, centre.y, opts, win);
-    }
+    let rects = el.getClientRects();
+    let centre = element.getInViewCentrePoint(rects[0], win);
+    let opts = {};
+    event.synthesizeMouseAtPoint(centre.x, centre.y, opts, win);
   }
 };
 
 /**
  * Select <option> element in a <select> list.
  *
  * Because the dropdown list of select elements are implemented using
  * native widget technology, our trusted synthesised events are not able