Bug 888336 - chat title not displayed after tearing off and reattaching a chat window, r=mixedpuppy.

This commit is contained in:
Florian Quèze 2013-07-04 12:12:24 +02:00
Родитель ae3ec48da0
Коммит 58c940ef27
3 изменённых файлов: 18 добавлений и 2 удалений

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

@ -146,8 +146,10 @@
aTarget.content.setAttribute("origin", this.content.getAttribute("origin")); aTarget.content.setAttribute("origin", this.content.getAttribute("origin"));
aTarget.content.popupnotificationanchor.className = this.content.popupnotificationanchor.className; aTarget.content.popupnotificationanchor.className = this.content.popupnotificationanchor.className;
this.content.socialErrorListener.remove(); this.content.socialErrorListener.remove();
aTarget.content.socialErrorListener.remove();
this.content.swapDocShells(aTarget.content); this.content.swapDocShells(aTarget.content);
Social.setErrorListener(this.content, function(aBrowser) { Social.setErrorListener(this.content, function(aBrowser) {}); // 'this' will be destroyed soon.
Social.setErrorListener(aTarget.content, function(aBrowser) {
aBrowser.webNavigation.loadURI("about:socialerror?mode=compactInfo", null, null, null, null); aBrowser.webNavigation.loadURI("about:socialerror?mode=compactInfo", null, null, null, null);
}); });
]]></body> ]]></body>
@ -190,7 +192,7 @@
let win = findChromeWindowForChats(); let win = findChromeWindowForChats();
let chatbar = win.SocialChatBar.chatbar; let chatbar = win.SocialChatBar.chatbar;
chatbar.openChat(provider, "about:blank", win => { chatbar.openChat(provider, "about:blank", win => {
chatbar.selectedChat.swapDocShells(this); this.swapDocShells(chatbar.selectedChat);
chatbar.focus(); chatbar.focus();
this.close(); this.close();
}); });

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

@ -29,6 +29,7 @@ function test() {
var tests = { var tests = {
testTearoffChat: function(next) { testTearoffChat: function(next) {
let chats = document.getElementById("pinnedchats"); let chats = document.getElementById("pinnedchats");
let chatTitle;
let port = Social.provider.getWorkerPort(); let port = Social.provider.getWorkerPort();
ok(port, "provider has a port"); ok(port, "provider has a port");
port.onmessage = function (e) { port.onmessage = function (e) {
@ -41,6 +42,14 @@ var tests = {
// chatbox is open, lets detach. The new chat window will be caught in // chatbox is open, lets detach. The new chat window will be caught in
// the window watcher below // the window watcher below
let doc = chats.selectedChat.contentDocument; let doc = chats.selectedChat.contentDocument;
// This message is (sometimes!) received a second time
// before we start our tests from the onCloseWindow
// callback.
if (doc.location == "about:blank")
return;
chatTitle = doc.title;
ok(chats.selectedChat.getAttribute("label") == chatTitle,
"the new chatbox should show the title of the chat window");
let div = doc.createElement("div"); let div = doc.createElement("div");
div.setAttribute("id", "testdiv"); div.setAttribute("id", "testdiv");
div.setAttribute("test", "1"); div.setAttribute("test", "1");
@ -78,6 +87,8 @@ var tests = {
chatbox.contentDocument && chatbox.contentDocument &&
chatbox.contentDocument.readyState == "complete"; chatbox.contentDocument.readyState == "complete";
},function() { },function() {
ok(chatbox.getAttribute("label") == chatTitle,
"detached window should show the title of the chat window");
let testdiv = chatbox.contentDocument.getElementById("testdiv"); let testdiv = chatbox.contentDocument.getElementById("testdiv");
is(testdiv.getAttribute("test"), "1", "docshell should have been swapped"); is(testdiv.getAttribute("test"), "1", "docshell should have been swapped");
testdiv.setAttribute("test", "2"); testdiv.setAttribute("test", "2");
@ -94,6 +105,8 @@ var tests = {
chats.selectedChat.contentDocument.readyState == "complete"; chats.selectedChat.contentDocument.readyState == "complete";
},function () { },function () {
ok(chats.selectedChat, "should have a chatbox in our window again"); ok(chats.selectedChat, "should have a chatbox in our window again");
ok(chats.selectedChat.getAttribute("label") == chatTitle,
"the new chatbox should show the title of the chat window again");
let testdiv = chats.selectedChat.contentDocument.getElementById("testdiv"); let testdiv = chats.selectedChat.contentDocument.getElementById("testdiv");
is(testdiv.getAttribute("test"), "2", "docshell should have been swapped"); is(testdiv.getAttribute("test"), "2", "docshell should have been swapped");
chats.selectedChat.close(); chats.selectedChat.close();

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

@ -18,6 +18,7 @@
window.close(); window.close();
}, false); }, false);
</script> </script>
<title>test chat window</title>
</head> </head>
<body onload="pingWorker();"> <body onload="pingWorker();">
<p>This is a test social chat window.</p> <p>This is a test social chat window.</p>