author | Mark Hammond <mhammond@skippinet.com.au> |
Wed, 14 Nov 2012 15:27:34 +1100 | |
changeset 113344 | 216ad89546aba4254298e9ee231c2b79fed7b15e |
parent 113343 | 6ec27ac9edac53ec819ee8c92aab709af237c180 |
child 113345 | 8072a58a9e86b79ecd054b5e224b40966afd4235 |
push id | 23869 |
push user | emorley@mozilla.com |
push date | Thu, 15 Nov 2012 16:18:16 +0000 |
treeherder | mozilla-central@a37525d304d9 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jaws |
bugs | 804591 |
milestone | 19.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
|
browser/base/content/socialchat.xml | file | annotate | diff | comparison | revisions | |
browser/base/content/test/browser_social_chatwindow.js | file | annotate | diff | comparison | revisions |
--- a/browser/base/content/socialchat.xml +++ b/browser/base/content/socialchat.xml @@ -274,18 +274,19 @@ this.menuitemMap.set(aChatbox, menu); this.menupopup.appendChild(menu); this.nub.collapsed = false; ]]></body> </method> <method name="showChat"> <parameter name="aChatbox"/> + <parameter name="aMode"/> <body><![CDATA[ - if (aChatbox.minimized) + if ((aMode != "minimized") && aChatbox.minimized) aChatbox.minimized = false; if (this.selectedChat != aChatbox) this.selectedChat = aChatbox; if (!aChatbox.collapsed) return; // already showing - no more to do. this._showChat(aChatbox); // showing a collapsed chat might mean another needs to be collapsed // to make room... @@ -348,17 +349,17 @@ <parameter name="aURL"/> <parameter name="aCallback"/> <parameter name="aMode"/> <body><![CDATA[ let cb = this.chatboxForURL.get(aURL); if (cb) { cb = cb.get(); if (cb.parentNode) { - this.showChat(cb); + this.showChat(cb, aMode); if (aCallback) aCallback(cb.iframe.contentWindow); return; } this.chatboxForURL.delete(aURL); } cb = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "chatbox"); if (aMode == "minimized")
--- a/browser/base/content/test/browser_social_chatwindow.js +++ b/browser/base/content/test/browser_social_chatwindow.js @@ -55,16 +55,95 @@ var tests = { ok(true, "got chatbox message"); ok(e.data.result == "ok", "got chatbox windowRef result: "+e.data.result); chats.selectedChat.toggle(); break; } } port.postMessage({topic: "test-init", data: { id: 1 }}); }, + testOpenMinimized: function(next) { + // In this case the sidebar opens a chat (without specifying minimized). + // We then minimize it and have the sidebar reopen the chat (again without + // minimized). On that second call the chat should open and no longer + // be minimized. + 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) { + // first time we got the opened message, so minimize the chat then + // re-request the same chat to be opened - we should get the + // message again and the chat should be restored. + ok(!chats.selectedChat.minimized, "chat not initially minimized") + chats.selectedChat.minimized = true + seen_opened = true; + port.postMessage({topic: "test-chatbox-open"}); + } else { + // This is the second time we've seen this message - there should + // be exactly 1 chat open and it should no longer be minimized. + let chats = document.getElementById("pinnedchats"); + ok(!chats.selectedChat.minimized, "chat no longer minimized") + chats.selectedChat.close(); + is(chats.selectedChat, null, "should only have been one chat open"); + port.close(); + next(); + } + } + } + port.postMessage({topic: "test-init", data: { id: 1 }}); + }, + // In this case the *worker* opens a chat (so minimized is specified). + // The worker then makes the same call again - as that second call also + // specifies "minimized" the chat should *not* be restored. + testWorkerChatWindowMinimized: function(next) { + const chatUrl = "https://example.com/browser/browser/base/content/test/social_chat.html"; + let port = Social.provider.getWorkerPort(); + let seen_opened = false; + ok(port, "provider has a port"); + port.postMessage({topic: "test-init"}); + port.onmessage = function (e) { + let topic = e.data.topic; + switch (topic) { + case "got-chatbox-message": + ok(true, "got a chat window opened"); + let chats = document.getElementById("pinnedchats"); + if (!seen_opened) { + // first time we got the opened message, so minimize the chat then + // re-request the same chat to be opened - we should get the + // message again and the chat should be restored. + ok(chats.selectedChat.minimized, "chatbox from worker opened as minimized"); + seen_opened = true; + port.postMessage({topic: "test-worker-chat", data: chatUrl}); + // Sadly there is no notification we can use to know the chat was + // re-opened :( So we ask the chat window to "ping" us - by then + // the second request should have made it. + chats.selectedChat.iframe.contentWindow.wrappedJSObject.pingWorker(); + } else { + // This is the second time we've seen this message - there should + // be exactly 1 chat open and it should still be minimized. + let chats = document.getElementById("pinnedchats"); + ok(chats.selectedChat.minimized, "chat still minimized") + chats.selectedChat.close(); + is(chats.selectedChat, null, "should only have been one chat open"); + port.close(); + next(); + } + break; + } + } + port.postMessage({topic: "test-worker-chat", data: chatUrl}); + }, testManyChats: function(next) { // open enough chats to overflow the window, then check // if the menupopup is visible let port = Social.provider.getWorkerPort(); ok(port, "provider has a port"); port.postMessage({topic: "test-init"}); let width = document.documentElement.boxObject.width; let numToOpen = (width / 200) + 1;