Bug 796309 - callback must be invoked if same social chat url opened twice. r=mixedpuppy

This commit is contained in:
Mark Hammond 2012-10-05 14:13:11 +10:00
Родитель 5fcf9cc9ba
Коммит f33eaf3d40
3 изменённых файлов: 35 добавлений и 1 удалений

Просмотреть файл

@ -317,6 +317,8 @@
this.selectedChat = cb;
if (cb.collapsed)
this.showChat(cb);
if (aCallback)
aCallback(cb.iframe.contentWindow);
return;
}
this.chatboxForURL.delete(aURL);

Просмотреть файл

@ -143,6 +143,35 @@ var tests = {
}
port.postMessage({topic: "test-init", data: { id: 1 }});
},
testSameChatCallbacks: function(next) {
let chats = document.getElementById("pinnedchats");
let port = Social.provider.getWorkerPort();
let seen_opened = false;
port.onmessage = function (e) {
let topic = e.data.topic;
switch (topic) {
case "test-init-done":
port.postMessage({topic: "test-chatbox-open"});
break;
case "chatbox-opened":
is(e.data.result, "ok", "the sidebar says it got a chatbox");
if (seen_opened) {
// This is the second time we've seen this message - there should
// be exactly 1 chat open.
let chats = document.getElementById("pinnedchats");
chats.selectedChat.close();
is(chats.selectedChat, null, "should only have been one chat open");
next();
} else {
// first time we got the opened message, so re-request the same
// chat to be opened - we should get the message again.
seen_opened = true;
port.postMessage({topic: "test-chatbox-open"});
}
}
}
port.postMessage({topic: "test-init", data: { id: 1 }});
},
testCloseOnLogout: function(next) {
const chatUrl = "https://example.com/browser/browser/base/content/test/social_chat.html";
let port = Social.provider.getWorkerPort();

Просмотреть файл

@ -50,7 +50,10 @@ onconnect = function(e) {
testPort.postMessage({topic:"got-social-panel-visibility", result: event.data.result });
break;
case "test-chatbox-open":
sidebarPort.postMessage( event.data );
sidebarPort.postMessage(event.data);
break;
case "chatbox-opened":
testPort.postMessage(event.data);
break;
case "chatbox-message":
testPort.postMessage({topic:"got-chatbox-message", result: event.data.result});