Bug 1229195 - resolve the promise when the chat window has actually finished loading, not right away. r=Standard8, a=ritu
authorMike de Boer <mdeboer@mozilla.com>
Tue, 15 Mar 2016 17:24:52 +0100
changeset 310095 f94242ec4259e7dc64a951f491e9b294c273bd53
parent 310094 19ced35b80760ea9cbf41dde24a832d01b4d8f88
child 310096 f95f7c876b15b2855e4cc1065c39410e74d7a3d3
push id9260
push usercbook@mozilla.com
push dateThu, 17 Mar 2016 14:21:47 +0000
treeherdermozilla-aurora@5781664ff8a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, ritu
bugs1229195
milestone47.0a2
Bug 1229195 - resolve the promise when the chat window has actually finished loading, not right away. r=Standard8, a=ritu
browser/extensions/loop/chrome/content/modules/MozLoopService.jsm
--- a/browser/extensions/loop/chrome/content/modules/MozLoopService.jsm
+++ b/browser/extensions/loop/chrome/content/modules/MozLoopService.jsm
@@ -1106,23 +1106,27 @@ var MozLoopServiceInternal = {
       let chatboxInstance = Chat.open(null, {
         origin: origin,
         title: "",
         url: url,
         remote: MozLoopService.getLoopPref("remote.autostart")
       }, callback);
       if (!chatboxInstance) {
         resolve(null);
-      // It's common for unit tests to overload Chat.open.
+      // It's common for unit tests to overload Chat.open, so check if we actually
+      // got a DOM node back.
       } else if (chatboxInstance.setAttribute) {
         // Set properties that influence visual appearance of the chatbox right
         // away to circumvent glitches.
         chatboxInstance.setAttribute("customSize", "loopDefault");
         chatboxInstance.parentNode.setAttribute("customSize", "loopDefault");
         Chat.loadButtonSet(chatboxInstance, "minimize,swap," + kChatboxHangupButton.id);
+      // Final fall-through in case a unit test overloaded Chat.open. Here we can
+      // immediately resolve the promise.
+      } else {
         resolve(windowId);
       }
     });
   },
 
   /**
    * Fetch Firefox Accounts (FxA) OAuth parameters from the Loop Server.
    *