Bug 1100284: also support detached chat windows in duplicate chat window handling. r=mixedpuppy
☠☠ backed out by 1a9ce687110d ☠ ☠
authorMike de Boer <mdeboer@mozilla.com>
Fri, 21 Nov 2014 15:47:56 +0100
changeset 241392 e8f45cf7b043d717f1b5669b9375b0efafa8356d
parent 241391 44ebd54f1b9cece005c9d9e8034c1940d727e58b
child 241393 c773c6be92708c523d2519ad584fc92af1e12b52
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1100284
milestone36.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 1100284: also support detached chat windows in duplicate chat window handling. r=mixedpuppy
browser/base/content/socialchat.xml
--- a/browser/base/content/socialchat.xml
+++ b/browser/base/content/socialchat.xml
@@ -188,25 +188,26 @@
           let win = Chat.findChromeWindowForChats();
           let chatbar = win.document.getElementById("pinnedchats");
           let origin = this.content.getAttribute("origin");
           let cb = chatbar.openChat(origin, title, "about:blank");
           cb.promiseChatLoaded.then(
             () => {
               this.swapDocShells(cb);
 
+              chatbar.focus();
+              this.close();
+
               // chatboxForURL is a map of URL -> chatbox used to avoid opening
               // duplicate chat windows. Ensure reattached chat windows aren't
               // registered with about:blank as their URL, otherwise reattaching
               // more than one chat window isn't possible.
               chatbar.chatboxForURL.delete("about:blank");
               chatbar.chatboxForURL.set(this.src, Cu.getWeakReference(cb));
 
-              chatbar.focus();
-              this.close();
               deferred.resolve(cb);
             }
           );
         }
         return deferred.promise;
         ]]></body>
       </method>
 
@@ -522,17 +523,19 @@
         <parameter name="aTitle"/>
         <parameter name="aURL"/>
         <parameter name="aMode"/>
         <parameter name="aCallback"/>
         <body><![CDATA[
           let cb = this.chatboxForURL.get(aURL);
           if (cb) {
             cb = cb.get();
-            if (cb.parentNode) {
+            // A chatbox is still alive to us when it's parented and still has
+            // content.
+            if (cb.parentNode && cb.contentWindow) {
               this.showChat(cb, aMode);
               if (aCallback) {
                 if (cb._callbacks == null) {
                   // Chatbox has already been created, so callback now.
                   aCallback(cb);
                 } else {
                   // Chatbox is yet to have bindings created...
                   cb._callbacks.push(aCallback);
@@ -641,31 +644,34 @@
       <!-- Moves a chatbox to a new window. Returns a promise that is resolved
            once the move to the other window is complete.
       -->
       <method name="detachChatbox">
         <parameter name="aChatbox"/>
         <parameter name="aOptions"/>
         <body><![CDATA[
           let deferred = Promise.defer();
+          let chatbar = this;
           let options = "";
           for (let name in aOptions)
             options += "," + name + "=" + aOptions[name];
 
           let otherWin = window.openDialog("chrome://browser/content/chatWindow.xul",
                                            "_blank", "chrome,all,dialog=no" + options);
 
           otherWin.addEventListener("load", function _chatLoad(event) {
             if (event.target != otherWin.document)
               return;
 
             otherWin.removeEventListener("load", _chatLoad, true);
             let otherChatbox = otherWin.document.getElementById("chatter");
             aChatbox.swapDocShells(otherChatbox);
             aChatbox.close();
+            chatbar.chatboxForURL.set(aChatbox.src, Cu.getWeakReference(otherChatbox));
+
             deferred.resolve(otherChatbox);
           }, true);
           return deferred.promise;
         ]]></body>
       </method>
 
     </implementation>