Bug 1418085 followup. Try to fix the Mac-only a11y orange. r=bustage
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 30 Jan 2018 02:30:58 -0500
changeset 748770 6e2d37b1b955d5472b85155ed73431f42e0d270c
parent 748769 09e8b84976182c68921180fccf9ee185e0fecdc7
child 748771 d32017c991aa5c848ead56d8f0b31ac18f86cff3
push id97228
push usersfraser@mozilla.com
push dateTue, 30 Jan 2018 10:21:04 +0000
reviewersbustage
bugs1418085
milestone60.0a1
Bug 1418085 followup. Try to fix the Mac-only a11y orange. r=bustage
accessible/tests/mochitest/events.js
--- a/accessible/tests/mochitest/events.js
+++ b/accessible/tests/mochitest/events.js
@@ -58,16 +58,24 @@ var gA11yEventDumpToConsole = false;
 var gA11yEventDumpToAppConsole = false;
 
 /**
  * Semicolon separated set of logging features.
  */
 var gA11yEventDumpFeature = "";
 
 /**
+ * Function to detect HTML elements when given a node.
+ */
+function isHTMLElement(aNode) {
+  return aNode.nodeType == aNode.ELEMENT_NODE &&
+         aNode.namespaceURI == "http://www.w3.org/1999/xhtml";
+}
+
+/**
  * Executes the function when requested event is handled.
  *
  * @param aEventType  [in] event type
  * @param aTarget     [in] event target
  * @param aFunc       [in] function to call when event is handled
  * @param aContext    [in, optional] object in which context the function is
  *                    called
  * @param aArg1       [in, optional] argument passed into the function
@@ -1054,21 +1062,29 @@ function synthClick(aNodeOrID, aCheckerO
   this.invoke = function synthClick_invoke() {
     var targetNode = this.DOMNode;
     if (targetNode instanceof nsIDOMDocument) {
       targetNode =
         this.DOMNode.body ? this.DOMNode.body : this.DOMNode.documentElement;
     }
 
     // Scroll the node into view, otherwise synth click may fail.
-    targetNode.scrollIntoView(true);
+    if (isHTMLElement(targetNode)) {
+      targetNode.scrollIntoView(true);
+    } else if (targetNode instanceof nsIDOMXULElement) {
+      var targetAcc = getAccessible(targetNode);
+      targetAcc.scrollTo(SCROLL_TYPE_ANYWHERE);
+    }
 
     var x = 1, y = 1;
     if (aArgs && ("where" in aArgs) && aArgs.where == "right") {
-      x = targetNode.getBoundingClientRect().width - 1;
+      if (isHTMLElement(targetNode))
+        x = targetNode.offsetWidth - 1;
+      else if (targetNode instanceof nsIDOMXULElement)
+        x = targetNode.boxObject.width - 1;
     }
     synthesizeMouse(targetNode, x, y, aArgs ? aArgs : {});
   };
 
   this.finalCheck = function synthClick_finalCheck() {
     // Scroll top window back.
     window.top.scrollTo(0, 0);
   };