Bug 1197133: Use dispatcher for listener getTitle
authorAndreas Tolfsen <ato@mozilla.com>
Fri, 21 Aug 2015 11:04:06 +0100
changeset 258989 ab7e85b0e839f04d1472a297b1d46cd384292a64
parent 258988 1bcda7156c4d8aeeffd21853e09a9fb452c488ef
child 258990 57971eca1e298f83a6dc1f0421219da8c6c6bc61
push id29268
push userryanvm@gmail.com
push dateTue, 25 Aug 2015 00:37:23 +0000
treeherdermozilla-central@08015770c9d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1197133
milestone43.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 1197133: Use dispatcher for listener getTitle r=dburns
testing/marionette/listener.js
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -178,16 +178,17 @@ function addMessageListenerId(messageNam
 
 /**
  * Remove a message listener that's tied to our listenerId.
  */
 function removeMessageListenerId(messageName, handler) {
   removeMessageListener(messageName + listenerId, handler);
 }
 
+let getTitleFn = dispatch(getTitle);
 let getElementSizeFn = dispatch(getElementSize);
 let getActiveElementFn = dispatch(getActiveElement);
 let clickElementFn = dispatch(clickElement);
 let getElementAttributeFn = dispatch(getElementAttribute);
 let getElementTextFn = dispatch(getElementText);
 let getElementTagNameFn = dispatch(getElementTagName);
 let getElementRectFn = dispatch(getElementRect);
 let isElementEnabledFn = dispatch(isElementEnabled);
@@ -204,17 +205,17 @@ function startListeners() {
   addMessageListenerId("Marionette:executeJSScript", executeJSScript);
   addMessageListenerId("Marionette:singleTap", singleTap);
   addMessageListenerId("Marionette:actionChain", actionChain);
   addMessageListenerId("Marionette:multiAction", multiAction);
   addMessageListenerId("Marionette:get", get);
   addMessageListenerId("Marionette:pollForReadyState", pollForReadyState);
   addMessageListenerId("Marionette:cancelRequest", cancelRequest);
   addMessageListenerId("Marionette:getCurrentUrl", getCurrentUrlFn);
-  addMessageListenerId("Marionette:getTitle", getTitle);
+  addMessageListenerId("Marionette:getTitle", getTitleFn);
   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", getActiveElementFn);
   addMessageListenerId("Marionette:clickElement", clickElementFn);
@@ -308,17 +309,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:get", get);
   removeMessageListenerId("Marionette:pollForReadyState", pollForReadyState);
   removeMessageListenerId("Marionette:cancelRequest", cancelRequest);
-  removeMessageListenerId("Marionette:getTitle", getTitle);
+  removeMessageListenerId("Marionette:getTitle", getTitleFn);
   removeMessageListenerId("Marionette:getPageSource", getPageSource);
   removeMessageListenerId("Marionette:getCurrentUrl", getCurrentUrlFn);
   removeMessageListenerId("Marionette:goBack", goBack);
   removeMessageListenerId("Marionette:goForward", goForward);
   removeMessageListenerId("Marionette:refresh", refresh);
   removeMessageListenerId("Marionette:findElementContent", findElementContent);
   removeMessageListenerId("Marionette:findElementsContent", findElementsContent);
   removeMessageListenerId("Marionette:getActiveElement", getActiveElementFn);
@@ -1327,20 +1328,20 @@ function getCurrentUrl(isB2G) {
   if (isB2G) {
     return curFrame.location.href;
   } else {
     return content.location.href;
   }
 }
 
 /**
- * Get the current Title of the window
+ * Get the title of the current browsing context.
  */
-function getTitle(msg) {
-  sendResponse({value: curFrame.top.document.title}, msg.json.command_id);
+function getTitle() {
+  return curFrame.top.document.title;
 }
 
 /**
  * Get the current page source
  */
 function getPageSource(msg) {
   var XMLSerializer = curFrame.XMLSerializer;
   var pageSource = new XMLSerializer().serializeToString(curFrame.document);