Bug 966579 - Tweaks to mutation observer usage for fix intermittent chat orange. r=mixedpuppy, a=test-only
authorMark Hammond <mhammond@skippinet.com.au>
Sat, 10 May 2014 02:02:00 -0400
changeset 192285 c3db2214834e
parent 192284 41a1653a0199
child 192286 83f031a76d0a
push id3557
push userryanvm@gmail.com
push date2014-05-14 16:23 +0000
Treeherderresults
reviewersmixedpuppy, test-only
bugs966579
milestone30.0
Bug 966579 - Tweaks to mutation observer usage for fix intermittent chat orange. r=mixedpuppy, a=test-only
browser/base/content/test/social/head.js
--- a/browser/base/content/test/social/head.js
+++ b/browser/base/content/test/social/head.js
@@ -544,27 +544,28 @@ function resizeAndCheckWidths(first, sec
     ok(sizedOk, count+": window resized correctly");
     function collapsedObserver(r, m) {
       if ([first, second, third].filter(function(item) !item.collapsed).length == numExpectedVisible) {
         if (m) {
           m.disconnect();
         }
         ok(true, count + ": " + "correct number of chats visible");
         info(">> Check " + count);
-        resizeAndCheckWidths(first, second, third, checks, cb);
-        return true;
+        executeSoon(function() {
+          resizeAndCheckWidths(first, second, third, checks, cb);
+        });
       }
-      return false;
     }
-    if (!collapsedObserver()) {
-      let m = new MutationObserver(collapsedObserver);
-      m.observe(first, {attributes: true });
-      m.observe(second, {attributes: true });
-      m.observe(third, {attributes: true });
-    }
+    let m = new MutationObserver(collapsedObserver);
+    m.observe(first, {attributes: true });
+    m.observe(second, {attributes: true });
+    m.observe(third, {attributes: true });
+    // and just in case we are already at the right size, explicitly call the
+    // observer.
+    collapsedObserver(undefined, m);
   }, count);
 }
 
 function getPopupWidth() {
   let popup = window.SocialChatBar.chatbar.menupopup;
   ok(!popup.parentNode.collapsed, "asking for popup width when it is visible");
   let cs = document.defaultView.getComputedStyle(popup.parentNode);
   let margins = parseInt(cs.marginLeft) + parseInt(cs.marginRight);