Bug 1254865 - Send init for AutoCompletePopup in async message from the parent. r=Felipe
authorMike Conley <mconley@mozilla.com>
Wed, 23 Mar 2016 14:47:00 -0400
changeset 290722 f2b8bb605d416b7f396295aec3b5f3703d1272ac
parent 290721 358a4096b0caec9b8f33ca9e387b12888be00b70
child 290723 2c8a3acfb48c772cfc2f0417738590bc607ce110
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe
bugs1254865
milestone48.0a1
Bug 1254865 - Send init for AutoCompletePopup in async message from the parent. r=Felipe MozReview-Commit-ID: IZ9f8pTTflF
toolkit/content/browser-child.js
toolkit/content/widgets/remote-browser.xml
--- a/toolkit/content/browser-child.js
+++ b/toolkit/content/browser-child.js
@@ -627,14 +627,15 @@ addMessageListener("PermitUnload", msg =
   sendAsyncMessage("PermitUnload", {id: msg.data.id, kind: "end", permitUnload});
 });
 
 // We may not get any responses to Browser:Init if the browser element
 // is torn down too quickly.
 var outerWindowID = content.QueryInterface(Ci.nsIInterfaceRequestor)
                            .getInterface(Ci.nsIDOMWindowUtils)
                            .outerWindowID;
-var initData = sendSyncMessage("Browser:Init", {outerWindowID: outerWindowID});
-if (initData.length && initData[0]) {
-  if (initData[0].initPopup) {
-    setTimeout(() => AutoCompletePopup.init(), 0);
+sendAsyncMessage("Browser:Init", {outerWindowID: outerWindowID});
+addMessageListener("Browser:InitReceived", function onInitReceived(msg) {
+  removeMessageListener("Browser:InitReceived", onInitReceived);
+  if (msg.data.initPopup) {
+    AutoCompletePopup.init();
   }
-}
+});
--- a/toolkit/content/widgets/remote-browser.xml
+++ b/toolkit/content/widgets/remote-browser.xml
@@ -425,19 +425,19 @@
 
       <method name="receiveMessage">
         <parameter name="aMessage"/>
         <body><![CDATA[
           let data = aMessage.data;
           switch (aMessage.name) {
             case "Browser:Init":
               this._outerWindowID = data.outerWindowID;
-              let result = {};
-              result.initPopup = this.autoCompletePopup != null;
-              return result;
+              this.messageManager.sendAsyncMessage("Browser:InitReceived", {
+                initPopup: this.autoCompletePopup != null,
+              });
               break;
             case "DOMTitleChanged":
               this._contentTitle = data.title;
               break;
             case "ImageDocumentLoaded":
               this._imageDocument = {
                 width: data.width,
                 height: data.height