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 317483 d7acfd3f468314509dcd860295ff5117a6705ed5
parent 317482 6ba5727b6c4af5795a8b76e718c92b142029b546
child 317484 9a0e8f871937b1de6a9ee0d3658097a8ae50480f
push id5761
push usercbook@mozilla.com
push dateThu, 17 Mar 2016 15:22:44 +0000
treeherdermozilla-beta@980a7149520b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, ritu
bugs1229195
milestone46.0
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
@@ -1102,23 +1102,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.
    *