Bug 941144 - getWindows not matching Selenium command. r=dburns
authorAndreas Tolfsen <ato@mozilla.com>
Fri, 24 Jan 2014 08:30:10 -0500
changeset 181074 a53cbf955a909247cbac06e35d63a298e9f70941
parent 181073 96f5df57e9b797c35e2cc1fc27ab67e506022123
child 181075 b21f20e9f9e82a6fd994ffabcf8dbcb8759b869c
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdburns
bugs941144
milestone29.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 941144 - getWindows not matching Selenium command. r=dburns
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
@@ -789,23 +789,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
@@ -1178,27 +1178,38 @@ MarionetteServerConnection.prototype = {
       if (this.curBrowser == this.browsers[i]) {
         this.sendResponse(i, this.command_id);
         return;
       }
     }
   },
 
   /**
-   * 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.
    *
@@ -2394,17 +2405,18 @@ MarionetteServerConnection.prototype.req
   "goUrl": MarionetteServerConnection.prototype.goUrl,
   "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,