Bug 1100284: also support detached chat windows in duplicate chat window handling. r=mixedpuppy

This commit is contained in:
Mike de Boer 2014-11-21 15:47:56 +01:00
parent 0989447476
commit d8e222083a

View File

@ -193,6 +193,9 @@
() => { () => {
this.swapDocShells(cb); this.swapDocShells(cb);
chatbar.focus();
this.close();
// chatboxForURL is a map of URL -> chatbox used to avoid opening // chatboxForURL is a map of URL -> chatbox used to avoid opening
// duplicate chat windows. Ensure reattached chat windows aren't // duplicate chat windows. Ensure reattached chat windows aren't
// registered with about:blank as their URL, otherwise reattaching // registered with about:blank as their URL, otherwise reattaching
@ -200,8 +203,6 @@
chatbar.chatboxForURL.delete("about:blank"); chatbar.chatboxForURL.delete("about:blank");
chatbar.chatboxForURL.set(this.src, Cu.getWeakReference(cb)); chatbar.chatboxForURL.set(this.src, Cu.getWeakReference(cb));
chatbar.focus();
this.close();
deferred.resolve(cb); deferred.resolve(cb);
} }
); );
@ -527,7 +528,9 @@
let cb = this.chatboxForURL.get(aURL); let cb = this.chatboxForURL.get(aURL);
if (cb) { if (cb) {
cb = cb.get(); 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); this.showChat(cb, aMode);
if (aCallback) { if (aCallback) {
if (cb._callbacks == null) { if (cb._callbacks == null) {
@ -646,6 +649,7 @@
<parameter name="aOptions"/> <parameter name="aOptions"/>
<body><![CDATA[ <body><![CDATA[
let deferred = Promise.defer(); let deferred = Promise.defer();
let chatbar = this;
let options = ""; let options = "";
for (let name in aOptions) for (let name in aOptions)
options += "," + name + "=" + aOptions[name]; options += "," + name + "=" + aOptions[name];
@ -661,6 +665,8 @@
let otherChatbox = otherWin.document.getElementById("chatter"); let otherChatbox = otherWin.document.getElementById("chatter");
aChatbox.swapDocShells(otherChatbox); aChatbox.swapDocShells(otherChatbox);
aChatbox.close(); aChatbox.close();
chatbar.chatboxForURL.set(aChatbox.src, Cu.getWeakReference(otherChatbox));
deferred.resolve(otherChatbox); deferred.resolve(otherChatbox);
}, true); }, true);
return deferred.promise; return deferred.promise;