Bug 941144 - getWindows not matching Selenium command. r=dburns, a=test-only
authorAndreas Tolfsen <ato@mozilla.com>
Fri, 24 Jan 2014 08:30:10 -0500
changeset 176199 286d29768633fc7410fa1bd5aad3ad4e25edff6f
parent 176198 eac6313b75f58fdd2aefacafded95b4cbe12edca
child 176200 9a8f844bfa1d031e6c5495d349f42c1a2763e7c5
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdburns, test-only
bugs941144
milestone28.0a2
Bug 941144 - getWindows not matching Selenium command. r=dburns, a=test-only
testing/marionette/client/marionette/marionette.py
testing/marionette/marionette-server.js
--- a/testing/marionette/client/marionette/marionette.py
+++ b/testing/marionette/client/marionette/marionette.py
@@ -775,23 +775,32 @@ class Marionette(object):
         '''
         Current title of the active window.
         '''
         response = self._send_message('getTitle', 'value')
         return response
 
     @property
     def window_handles(self):
-        '''
-        A list of references to all available browser windows if called in
-        content context. If called while in the chrome context, it will list
-        all available windows, not just browser windows (ie: not just
-        'navigator:browser';).
-        '''
-        response = self._send_message('getWindows', 'value')
+        """Get list of windows in the current context.
+
+        If called in the content context it will return a list of
+        references to all available browser windows.  Called in the
+        chrome context, it will list all available windows, not just
+        browser windows (e.g. not just navigator.browser).
+
+        Each window handle is assigned by the server, and the list of
+        strings returned does not have a guaranteed ordering.
+
+        :returns: unordered list of unique window handles as strings
+
+        """
+
+        response = self._send_message("getCurrentWindowHandles",
+                                      "value")
         return response
 
     @property
     def page_source(self):
         '''
         A string representation of the DOM.
         '''
         response = self._send_message('getPageSource', 'value')
--- a/testing/marionette/marionette-server.js
+++ b/testing/marionette/marionette-server.js
@@ -1198,27 +1198,38 @@ MarionetteServerConnection.prototype = {
     for (let i in this.browsers) {
       if (this.curBrowser == this.browsers[i]) {
         this.sendResponse(i, this.command_id);
       }
     }
   },
 
   /**
-   * Get the server-assigned IDs of all available windows
+   * Get list of windows in the current context.
+   *
+   * If called in the content context it will return a list of
+   * references to all available browser windows.  Called in the
+   * chrome context, it will list all available windows, not just
+   * browser windows (e.g. not just navigator.browser).
+   *
+   * Each window handle is assigned by the server, and the array of
+   * strings returned does not have a guaranteed ordering.
+   *
+   * @return unordered array of unique window handles as strings
    */
-  getWindows: function MDA_getWindows() {
+  getWindowHandles: function MDA_getWindowHandles() {
     this.command_id = this.getCommandId();
     let res = [];
     let winEn = this.getWinEnumerator();
-    while(winEn.hasMoreElements()) {
+    while (winEn.hasMoreElements()) {
       let foundWin = winEn.getNext();
-      let winId = foundWin.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
-      winId = winId + ((appName == "B2G") ? '-b2g' : '');
-      res.push(winId)
+      let winId = foundWin.QueryInterface(Ci.nsIInterfaceRequestor)
+            .getInterface(Ci.nsIDOMWindowUtils).outerWindowID;
+      winId = winId + ((appName == "B2G") ? "-b2g" : "");
+      res.push(winId);
     }
     this.sendResponse(res, this.command_id);
   },
 
   /**
    * Switch to a window based on name or server-assigned id.
    * Searches based on name, then id.
    *
@@ -2426,17 +2437,18 @@ MarionetteServerConnection.prototype.req
   "goUrl": MarionetteServerConnection.prototype.get,  // deprecated
   "getCurrentUrl": MarionetteServerConnection.prototype.getCurrentUrl,
   "getUrl": MarionetteServerConnection.prototype.getCurrentUrl,  // deprecated
   "goBack": MarionetteServerConnection.prototype.goBack,
   "goForward": MarionetteServerConnection.prototype.goForward,
   "refresh":  MarionetteServerConnection.prototype.refresh,
   "getCurrentWindowHandle":  MarionetteServerConnection.prototype.getCurrentWindowHandle,
   "getWindow":  MarionetteServerConnection.prototype.getCurrentWindowHandle,  // deprecated
-  "getWindows":  MarionetteServerConnection.prototype.getWindows,
+  "getCurrentWindowHandles": MarionetteServerConnection.prototype.getWindowHandles,
+  "getWindows":  MarionetteServerConnection.prototype.getWindowHandles,  // deprecated
   "getActiveFrame": MarionetteServerConnection.prototype.getActiveFrame,
   "switchToFrame": MarionetteServerConnection.prototype.switchToFrame,
   "switchToWindow": MarionetteServerConnection.prototype.switchToWindow,
   "deleteSession": MarionetteServerConnection.prototype.deleteSession,
   "emulatorCmdResult": MarionetteServerConnection.prototype.emulatorCmdResult,
   "importScript": MarionetteServerConnection.prototype.importScript,
   "clearImportedScripts": MarionetteServerConnection.prototype.clearImportedScripts,
   "getAppCacheStatus": MarionetteServerConnection.prototype.getAppCacheStatus,