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; this.selectedChat = cb;
if (cb.collapsed) if (cb.collapsed)
this.showChat(cb); this.showChat(cb);
if (aCallback)
aCallback(cb.iframe.contentWindow);
return; return;
} }
this.chatboxForURL.delete(aURL); this.chatboxForURL.delete(aURL);

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

@ -143,6 +143,35 @@ var tests = {
} }
port.postMessage({topic: "test-init", data: { id: 1 }}); 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) { testCloseOnLogout: function(next) {
const chatUrl = "https://example.com/browser/browser/base/content/test/social_chat.html"; const chatUrl = "https://example.com/browser/browser/base/content/test/social_chat.html";
let port = Social.provider.getWorkerPort(); let port = Social.provider.getWorkerPort();

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

@ -52,6 +52,9 @@ onconnect = function(e) {
case "test-chatbox-open": case "test-chatbox-open":
sidebarPort.postMessage(event.data); sidebarPort.postMessage(event.data);
break; break;
case "chatbox-opened":
testPort.postMessage(event.data);
break;
case "chatbox-message": case "chatbox-message":
testPort.postMessage({topic:"got-chatbox-message", result: event.data.result}); testPort.postMessage({topic:"got-chatbox-message", result: event.data.result});
break; break;