Bug 1250102 - Correct exported symbol from testing/marionette/element.js; r=automatedtester
authorAndreas Tolfsen <ato@mozilla.com>
Tue, 23 Feb 2016 15:01:12 +0000
changeset 321766 c73978b005c82ad5673765fc200a34d5cffbdfa9
parent 321765 aa5e5a12ce6376ab68e1da6fbcef1bc690b6ff76
child 321767 9a57362d5fcaf0acc056f2e52576d695f8eccda6
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester
bugs1250102
milestone47.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 1250102 - Correct exported symbol from testing/marionette/element.js; r=automatedtester MozReview-Commit-ID: 9naIfpy9HPD
testing/marionette/driver.js
testing/marionette/element.js
testing/marionette/event.js
testing/marionette/interaction.js
testing/marionette/listener.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -506,17 +506,17 @@ GeckoDriver.prototype.listeningPromise =
     this.mm.addMessageListener(li, cb);
   });
 };
 
 /** Create a new session. */
 GeckoDriver.prototype.newSession = function*(cmd, resp) {
   this.sessionId = cmd.parameters.sessionId ||
       cmd.parameters.session_id ||
-      elements.generateUUID();
+      element.generateUUID();
 
   this.newSessionCommandId = cmd.id;
   this.setSessionCapabilities(cmd.parameters.capabilities);
   this.scriptTimeout = 10000;
 
   let registerBrowsers = this.registerPromise();
   let browserListening = this.listeningPromise();
 
--- a/testing/marionette/element.js
+++ b/testing/marionette/element.js
@@ -22,17 +22,17 @@ Cu.import("chrome://marionette/content/e
  * is the same.
  *
  * The element manager provides a mapping between web element references
  * and DOM elements for each browsing context.  It also provides
  * functionality for looking up and retrieving elements.
  */
 
 this.EXPORTED_SYMBOLS = [
-  "elements",
+  "element",
   "ElementManager",
   "CLASS_NAME",
   "SELECTOR",
   "ID",
   "NAME",
   "LINK_TEXT",
   "PARTIAL_LINK_TEXT",
   "TAG",
@@ -80,33 +80,33 @@ ElementManager.prototype = {
   * Add element to list of seen elements
   *
   * @param nsIDOMElement element
   *        The element to add
   *
   * @return string
   *        Returns the server-assigned reference ID
   */
-  addToKnownElements: function EM_addToKnownElements(element) {
+  addToKnownElements: function EM_addToKnownElements(el) {
     for (let i in this.seenItems) {
       let foundEl = null;
       try {
         foundEl = this.seenItems[i].get();
       } catch (e) {}
       if (foundEl) {
-        if (XPCNativeWrapper(foundEl) == XPCNativeWrapper(element)) {
+        if (XPCNativeWrapper(foundEl) == XPCNativeWrapper(el)) {
           return i;
         }
       } else {
         // cleanup reference to GC'd element
         delete this.seenItems[i];
       }
     }
-    let id = elements.generateUUID();
-    this.seenItems[id] = Cu.getWeakReference(element);
+    let id = element.generateUUID();
+    this.seenItems[id] = Cu.getWeakReference(el);
     return id;
   },
 
   /**
    * Retrieve element from its unique ID
    *
    * @param String id
    *        The DOM reference ID
@@ -592,19 +592,19 @@ ElementManager.prototype = {
         break;
       default:
         throw new InvalidSelectorError(`No such strategy: ${using}`);
     }
     return elements;
   },
 };
 
-this.elements = {};
 
-elements.generateUUID = function() {
+this.element = {};
+element.generateUUID = function() {
   let uuid = uuidGen.generateUUID().toString();
   return uuid.substring(1, uuid.length - 1);
 };
 
 /**
  * This function generates a pair of coordinates relative to the viewport
  * given a target element and coordinates relative to that element's
  * top-left corner.
@@ -614,17 +614,17 @@ elements.generateUUID = function() {
  * @param {number=} x
  *     Horizontal offset relative to target.  Defaults to the centre of
  *     the target's bounding box.
  * @param {number=} y
  *     Vertical offset relative to target.  Defaults to the centre of
  *     the target's bounding box.
  */
 // TODO(ato): Replicated from listener.js for the time being
-elements.coordinates = function(node, x = undefined, y = undefined) {
+element.coordinates = function(node, x = undefined, y = undefined) {
   let box = node.getBoundingClientRect();
   if (!x) {
     x = box.width / 2.0;
   }
   if (!y) {
     y = box.height / 2.0;
   }
   return {
@@ -640,19 +640,19 @@ elements.coordinates = function(node, x 
  *     Target element.
  * @param {number=} x
  *     Horizontal offset relative to target.  Defaults to the centre of
  *     the target's bounding box.
  * @param {number=} y
  *     Vertical offset relative to target.  Defaults to the centre of
  *     the target's bounding box.
  */
-elements.inViewport = function(el, x = undefined, y = undefined) {
+element.inViewport = function(el, x = undefined, y = undefined) {
   let win = el.ownerDocument.defaultView;
-  let c = elements.coordinates(el, x, y);
+  let c = element.coordinates(el, x, y);
   let vp = {
     top: win.pageYOffset,
     left: win.pageXOffset,
     bottom: (win.pageYOffset + win.innerHeight),
     right: (win.pageXOffset + win.innerWidth)
   };
 
   return (vp.left <= c.x + win.pageXOffset &&
@@ -671,37 +671,37 @@ elements.inViewport = function(el, x = u
  *     Window object.
  * @param {number=} x
  *     Horizontal offset relative to target.  Defaults to the centre of
  *     the target's bounding box.
  * @param {number=} y
  *     Vertical offset relative to target.  Defaults to the centre of
  *     the target's bounding box.
  */
-elements.checkVisible = function(el, win, x = undefined, y = undefined) {
+element.checkVisible = function(el, win, x = undefined, y = undefined) {
   // Bug 1094246: Webdriver's isShown doesn't work with content xul
   let ns = atom.getElementAttribute(el, "namespaceURI", win);
   if (ns.indexOf("there.is.only.xul") < 0 &&
       !atom.isElementDisplayed(el, win)) {
     return false;
   }
 
   if (el.tagName.toLowerCase() == "body") {
     return true;
   }
 
-  if (!elements.inViewport(el, x, y)) {
+  if (!element.inViewport(el, x, y)) {
     if (el.scrollIntoView) {
       el.scrollIntoView(false);
-      if (!elements.inViewport(el)) {
+      if (!element.inViewport(el)) {
         return false;
       }
     } else {
       return false;
     }
   }
   return true;
 };
 
-elements.isXULElement = function(el) {
+element.isXULElement = function(el) {
   let ns = atom.getElementAttribute(el, "namespaceURI");
   return ns.indexOf("there.is.only.xul") >= 0;
 };
--- a/testing/marionette/event.js
+++ b/testing/marionette/event.js
@@ -926,20 +926,20 @@ function focusElement(element) {
 
 /**
  * @param {Array.<string>} keySequence
  * @param {Element} element
  * @param {Object.<string, boolean>=} opts
  * @param {Window=} window
  */
 event.sendKeysToElement = function(
-    keySequence, element, opts = {}, window = undefined) {
+    keySequence, el, opts = {}, window = undefined) {
 
-  if (opts.ignoreVisibility || elements.checkVisible(element, window)) {
-    focusElement(element);
+  if (opts.ignoreVisibility || element.checkVisible(el, window)) {
+    focusElement(el);
 
     // make Object.<modifier, false> map
     let modifiers = Object.create(event.Modifiers);
     for (let modifier in event.Modifiers) {
       modifiers[modifier] = false;
     }
 
     let value = keySequence.join("");
--- a/testing/marionette/interaction.js
+++ b/testing/marionette/interaction.js
@@ -91,26 +91,26 @@ Interactions.prototype = {
    *
    * @param ElementManager elementManager
    *
    * @param String id
    *        The DOM reference ID
    */
   clickElement(container, elementManager, id) {
     let el = elementManager.getKnownElement(id, container);
-    let visible = elements.checkVisible(el, container.frame);
+    let visible = element.checkVisible(el, container.frame);
     if (!visible) {
       throw new ElementNotVisibleError('Element is not visible');
     }
     return this.accessibility.getAccessibleObject(el, true).then(acc => {
       this.accessibility.checkVisible(acc, el, visible);
       if (atom.isElementEnabled(el)) {
         this.accessibility.checkEnabled(acc, el, true, container);
         this.accessibility.checkActionable(acc, el);
-        if (elements.isXULElement(el)) {
+        if (element.isXULElement(el)) {
           el.click();
         } else {
           let rects = el.getClientRects();
           let win = el.ownerDocument.defaultView;
           event.synthesizeMouseAtPoint(
               rects[0].left + rects[0].width / 2,
               rects[0].top + rects[0].height / 2,
               {} /* opts */,
@@ -183,17 +183,17 @@ Interactions.prototype = {
    *     Reference to web element.
    *
    * @return {boolean}
    *     True if enabled, false otherwise.
    */
   isElementEnabled(container, elementManager, id) {
     let el = elementManager.getKnownElement(id, container);
     let enabled = true;
-    if (elements.isXULElement(el)) {
+    if (element.isXULElement(el)) {
       // Check if XUL element supports disabled attribute
       if (DISABLED_ATTRIBUTE_SUPPORTED_XUL.has(el.tagName.toUpperCase())) {
         let disabled = atom.getElementAttribute(el, 'disabled', container.frame);
         if (disabled && disabled === 'true') {
           enabled = false;
         }
       }
     } else {
@@ -217,17 +217,17 @@ Interactions.prototype = {
    * @param ElementManager elementManager
    *
    * @param {WebElement} id
    *     Reference to web element.
    */
   isElementSelected(container, elementManager, id) {
     let el = elementManager.getKnownElement(id, container);
     let selected = true;
-    if (elements.isXULElement(el)) {
+    if (element.isXULElement(el)) {
       let tagName = el.tagName.toUpperCase();
       if (CHECKED_PROPERTY_SUPPORTED_XUL.has(tagName)) {
         selected = el.checked;
       }
       if (SELECTED_PROPERTY_SUPPORTED_XUL.has(tagName)) {
         selected = el.selected;
       }
     } else {
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -888,17 +888,17 @@ function coordinates(target, x, y) {
 }
 
 /**
  * Function that perform a single tap
  */
 function singleTap(id, corx, cory) {
   let el = elementManager.getKnownElement(id, curContainer);
   // after this block, the element will be scrolled into view
-  let visible = elements.checkVisible(el, curContainer.frame, corx, cory);
+  let visible = element.checkVisible(el, curContainer.frame, corx, cory);
   if (!visible) {
     throw new ElementNotVisibleError("Element is not currently visible and may not be manipulated");
   }
   return interactions.accessibility.getAccessibleObject(el, true).then(acc => {
     interactions.accessibility.checkVisible(acc, el, visible);
     interactions.accessibility.checkActionable(acc, el);
     if (!curContainer.frame.document.createTouch) {
       actions.mouseEventsOnly = true;