Bug 941136 - getUrl not matching webdriver command getCurrentUrl. r=dburns, a=test-only
authorAndreas Tolfsen <ato@mozilla.com>
Tue, 21 Jan 2014 13:31:31 -0500
changeset 176156 7ecef9a70b64ba387adbb1f2f0236c6b9bf14548
parent 176155 483aca96334d308c4fbac3e67978879cb5c6cdb5
child 176157 c7f586adde66e3b95b3fa613ef7bbd6a2a5d56c6
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
bugs941136
milestone28.0a2
Bug 941136 - getUrl not matching webdriver command getCurrentUrl. r=dburns, a=test-only
testing/marionette/client/marionette/marionette.py
testing/marionette/marionette-listener.js
testing/marionette/marionette-server.js
--- a/testing/marionette/client/marionette/marionette.py
+++ b/testing/marionette/client/marionette/marionette.py
@@ -843,20 +843,30 @@ class Marionette(object):
         '''
         if isinstance(frame, HTMLElement):
             response = self._send_message('switchToFrame', 'ok', element=frame.id, focus=focus)
         else:
             response = self._send_message('switchToFrame', 'ok', id=frame, focus=focus)
         return response
 
     def get_url(self):
-        '''
-        Returns the url of the active page in the browser.
-        '''
-        response = self._send_message('getUrl', 'value')
+        """Get a string representing the current URL.
+
+        On Desktop this returns a string representation of the URL of
+        the current top level browsing context.  This is equivalent to
+        document.location.href.
+
+        When in the context of the chrome, this returns the canonical
+        URL of the current resource.
+
+        :returns: string representation of URL
+
+        """
+
+        response = self._send_message("getCurrentUrl", "value")
         return response
 
     def get_window_type(self):
         '''
         Gets the windowtype attribute of the window Marionette is currently acting on.
 
         This command only makes sense in a chrome context. You might use this
         method to distinguish a browser window from an editor window.
--- a/testing/marionette/marionette-listener.js
+++ b/testing/marionette/marionette-listener.js
@@ -125,17 +125,17 @@ function startListeners() {
   addMessageListenerId("Marionette:newSession", newSession);
   addMessageListenerId("Marionette:executeScript", executeScript);
   addMessageListenerId("Marionette:executeAsyncScript", executeAsyncScript);
   addMessageListenerId("Marionette:executeJSScript", executeJSScript);
   addMessageListenerId("Marionette:singleTap", singleTap);
   addMessageListenerId("Marionette:actionChain", actionChain);
   addMessageListenerId("Marionette:multiAction", multiAction);
   addMessageListenerId("Marionette:goUrl", goUrl);
-  addMessageListenerId("Marionette:getUrl", getUrl);
+  addMessageListenerId("Marionette:getCurrentUrl", getCurrentUrl);
   addMessageListenerId("Marionette:getTitle", getTitle);
   addMessageListenerId("Marionette:getPageSource", getPageSource);
   addMessageListenerId("Marionette:goBack", goBack);
   addMessageListenerId("Marionette:goForward", goForward);
   addMessageListenerId("Marionette:refresh", refresh);
   addMessageListenerId("Marionette:findElementContent", findElementContent);
   addMessageListenerId("Marionette:findElementsContent", findElementsContent);
   addMessageListenerId("Marionette:getActiveElement", getActiveElement);
@@ -222,17 +222,17 @@ function deleteSession(msg) {
   removeMessageListenerId("Marionette:executeAsyncScript", executeAsyncScript);
   removeMessageListenerId("Marionette:executeJSScript", executeJSScript);
   removeMessageListenerId("Marionette:singleTap", singleTap);
   removeMessageListenerId("Marionette:actionChain", actionChain);
   removeMessageListenerId("Marionette:multiAction", multiAction);
   removeMessageListenerId("Marionette:goUrl", goUrl);
   removeMessageListenerId("Marionette:getTitle", getTitle);
   removeMessageListenerId("Marionette:getPageSource", getPageSource);
-  removeMessageListenerId("Marionette:getUrl", getUrl);
+  removeMessageListenerId("Marionette:getCurrentUrl", getCurrentUrl);
   removeMessageListenerId("Marionette:goBack", goBack);
   removeMessageListenerId("Marionette:goForward", goForward);
   removeMessageListenerId("Marionette:refresh", refresh);
   removeMessageListenerId("Marionette:findElementContent", findElementContent);
   removeMessageListenerId("Marionette:findElementsContent", findElementsContent);
   removeMessageListenerId("Marionette:getActiveElement", getActiveElement);
   removeMessageListenerId("Marionette:clickElement", clickElement);
   removeMessageListenerId("Marionette:getElementAttribute", getElementAttribute);
@@ -1227,19 +1227,19 @@ function goUrl(msg) {
   if (msg.json.pageTimeout != null){
     checkTimer.initWithCallback(timerFunc, msg.json.pageTimeout, Ci.nsITimer.TYPE_ONE_SHOT);
   }
   addEventListener("DOMContentLoaded", onDOMContentLoaded, false);
   curFrame.location = msg.json.url;
 }
 
 /**
- * Get the current URI
+ * Get URL of the top level browsing context.
  */
-function getUrl(msg) {
+function getCurrentUrl(msg) {
   sendResponse({value: curFrame.location.href}, msg.json.command_id);
 }
 
 /**
  * Get the current Title of the window
  */
 function getTitle(msg) {
   sendResponse({value: curFrame.top.document.title}, msg.json.command_id);
--- a/testing/marionette/marionette-server.js
+++ b/testing/marionette/marionette-server.js
@@ -1074,25 +1074,32 @@ MarionetteServerConnection.prototype = {
         sendError("Error loading page", 13, null, command_id);
         return;
       }
     }//end
     checkTimer.initWithCallback(checkLoad, 100, Ci.nsITimer.TYPE_ONE_SHOT);
   },
 
   /**
-   * Gets current url
+   * Get a string representing the current URL.
+   *
+   * On Desktop this returns a string representation of the URL of the
+   * current top level browsing context.  This is equivalent to
+   * document.location.href.
+   *
+   * When in the context of the chrome, this returns the canonical URL
+   * of the current resource.
    */
-  getUrl: function MDA_getUrl() {
+  getCurrentUrl: function MDA_getCurrentUrl() {
     this.command_id = this.getCommandId();
     if (this.context == "chrome") {
       this.sendResponse(this.getCurrentWindow().location.href, this.command_id);
     }
     else {
-      this.sendAsync("getUrl", {}, this.command_id);
+      this.sendAsync("getCurrentUrl", {}, this.command_id);
     }
   },
 
   /**
    * Gets the current title of the window
    */
   getTitle: function MDA_getTitle() {
     this.command_id = this.getCommandId();
@@ -2364,17 +2371,18 @@ MarionetteServerConnection.prototype.req
   "isElementSelected": MarionetteServerConnection.prototype.isElementSelected,
   "sendKeysToElement": MarionetteServerConnection.prototype.sendKeysToElement,
   "getElementPosition": MarionetteServerConnection.prototype.getElementPosition,
   "clearElement": MarionetteServerConnection.prototype.clearElement,
   "getTitle": MarionetteServerConnection.prototype.getTitle,
   "getWindowType": MarionetteServerConnection.prototype.getWindowType,
   "getPageSource": MarionetteServerConnection.prototype.getPageSource,
   "goUrl": MarionetteServerConnection.prototype.goUrl,
-  "getUrl": MarionetteServerConnection.prototype.getUrl,
+  "getCurrentUrl": MarionetteServerConnection.prototype.getCurrentUrl,
+  "getUrl": MarionetteServerConnection.prototype.getCurrentUrl,  // deprecated
   "goBack": MarionetteServerConnection.prototype.goBack,
   "goForward": MarionetteServerConnection.prototype.goForward,
   "refresh":  MarionetteServerConnection.prototype.refresh,
   "getWindow":  MarionetteServerConnection.prototype.getWindow,
   "getWindows":  MarionetteServerConnection.prototype.getWindows,
   "getActiveFrame": MarionetteServerConnection.prototype.getActiveFrame,
   "switchToFrame": MarionetteServerConnection.prototype.switchToFrame,
   "switchToWindow": MarionetteServerConnection.prototype.switchToWindow,