Bug 1229195: resolve the promise when the chat window has actually finished loading, not right away. r=Standard8
authorMike de Boer <mdeboer@mozilla.com>
Tue, 15 Mar 2016 17:24:52 +0100
changeset 288732 c1516ee3efd8a0329fccf93ba0398c69ed296ea4
parent 288731 a3c038ea446c2e1d6e559f27bce75a6038ee582c
child 288733 3cb1c3284e5fb5e737769a0d54c072709ffa822b
push id18184
push usermdeboer@mozilla.com
push dateTue, 15 Mar 2016 16:26:18 +0000
treeherderfx-team@c1516ee3efd8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs1229195
milestone48.0a1
Bug 1229195: resolve the promise when the chat window has actually finished loading, not right away. r=Standard8
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.
    *