bug 836766 drop minimized requirment on chats opened from worker, r=markh
authorShane Caraveo <scaraveo@mozilla.com>
Fri, 31 May 2013 16:42:02 -0700
changeset 140824 3d1434e45bd92a1ce659f0f737e2c729acba01f3
parent 140823 df3fbbf0b7fe4316bba0b6cbdd4ea904e75cf06b
child 140825 d70b4807df13a6a55c4eed116a3e217f634bff74
push id3911
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 20:17:26 +0000
treeherdermozilla-aurora@7e26ca8db92b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs836766
milestone24.0a1
bug 836766 drop minimized requirment on chats opened from worker, r=markh
browser/base/content/test/social/browser_social_chatwindow.js
browser/base/content/test/social/browser_social_chatwindowfocus.js
toolkit/components/social/WorkerAPI.jsm
--- a/browser/base/content/test/social/browser_social_chatwindow.js
+++ b/browser/base/content/test/social/browser_social_chatwindow.js
@@ -100,57 +100,16 @@ var tests = {
             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/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();
     let chats = document.getElementById("pinnedchats");
     ok(port, "provider has a port");
     ok(chats.menupopup.parentNode.collapsed, "popup nub collapsed at start");
     port.postMessage({topic: "test-init"});
@@ -184,36 +143,37 @@ var tests = {
           next();
           break;
       }
     }
     maybeOpenAnother();
   },
   testWorkerChatWindow: function(next) {
     const chatUrl = "https://example.com/browser/browser/base/content/test/social/social_chat.html";
+    let chats = document.getElementById("pinnedchats");
     let port = Social.provider.getWorkerPort();
     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");
-          ok(chats.selectedChat.minimized, "chatbox from worker opened as minimized");
+          ok(chats.selectedChat, "chatbox from worker opened");
           while (chats.selectedChat) {
             chats.selectedChat.close();
           }
           ok(!chats.selectedChat, "chats are all closed");
           gURLsNotRemembered.push(chatUrl);
           port.close();
           next();
           break;
       }
     }
+    ok(!chats.selectedChat, "chats are all closed");
     port.postMessage({topic: "test-worker-chat", data: chatUrl});
   },
   testCloseSelf: function(next) {
     let chats = document.getElementById("pinnedchats");
     let port = Social.provider.getWorkerPort();
     ok(port, "provider has a port");
     port.onmessage = function (e) {
       let topic = e.data.topic;
--- a/browser/base/content/test/social/browser_social_chatwindowfocus.js
+++ b/browser/base/content/test/social/browser_social_chatwindowfocus.js
@@ -162,26 +162,25 @@ var tests = {
       waitForCondition(function() isChatFocused(SocialChatBar.chatbar.selectedChat),
                        function() {
         is(SocialChatBar.chatbar.selectedChat, SocialChatBar.chatbar.firstElementChild, "chat is selected");
         next();
       }, "chat should be focused");
     });
   },
 
-  // Open a chat via the worker - it will open minimized and not have focus.
+  // Open a chat via the worker - it will open and not have focus.
   // Then open the same chat via a sidebar message - it will be restored but
   // should still not have grabbed focus.
   testNoFocusOnAutoRestore: function(next) {
     const chatUrl = "https://example.com/browser/browser/base/content/test/social/social_chat.html?id=1";
     let chatbar = SocialChatBar.chatbar;
     startTestAndWaitForSidebar(function(port) {
       openChatViaWorkerMessage(port, chatUrl, function() {
         is(chatbar.childElementCount, 1, "exactly 1 chat open");
-        ok(chatbar.firstElementChild.minimized, "chat is minimized");
         // bug 865086 opening minimized still sets the window as selected
         todo(chatbar.selectedChat != chatbar.firstElementChild, "chat is not selected");
         ok(isTabFocused(), "tab should be focused");
         openChatViaSidebarMessage(port, {stealFocus: 1, id: 1}, function() {
           is(chatbar.childElementCount, 1, "still 1 chat open");
           ok(!chatbar.firstElementChild.minimized, "chat no longer minimized");
           // bug 865086 because we marked it selected on open, it still is
           todo(chatbar.selectedChat != chatbar.firstElementChild, "chat is not selected");
--- a/toolkit/components/social/WorkerAPI.jsm
+++ b/toolkit/components/social/WorkerAPI.jsm
@@ -73,17 +73,17 @@ WorkerAPI.prototype = {
         let [name, value] = aCookie.split("=");
         results.push({name: unescape(name.trim()),
                       value: value ? unescape(value.trim()) : ""});
       });
       this._port.postMessage({topic: "social.cookies-get-response",
                               data: results});
     },
     'social.request-chat': function(data) {
-      openChatWindow(null, this._provider, data, null, "minimized");
+      openChatWindow(null, this._provider, data);
     },
     'social.notification-create': function(data) {
       if (!Services.prefs.getBoolPref("social.toast-notifications.enabled"))
         return;
 
       let port = this._port;
       let provider = this._provider;
       let {id, type, icon, body, action, actionArgs} = data;