Bug 847094 - fix intermittent chat test failures by waiting for content load event. r=felipe
authorMark Hammond <mhammond@skippinet.com.au>
Wed, 03 Apr 2013 12:17:44 +1100
changeset 127126 6af3167805da
parent 127125 e0d063f04ee2
child 127127 63453515a870
push id117
push usertomi.aarnio@nokia.com
push dateWed, 03 Apr 2013 12:07:07 +0000
reviewersfelipe
bugs847094
milestone23.0a1
Bug 847094 - fix intermittent chat test failures by waiting for content load event. r=felipe
browser/base/content/socialchat.xml
--- a/browser/base/content/socialchat.xml
+++ b/browser/base/content/socialchat.xml
@@ -22,18 +22,20 @@
 
     <implementation implements="nsIDOMEventListener">
       <constructor><![CDATA[
         let Social = Components.utils.import("resource:///modules/Social.jsm", {}).Social;
         Social.setErrorListener(this.iframe, function(iframe) {
           iframe.webNavigation.loadURI("about:socialerror?mode=compactInfo", null, null, null, null);
         });
         let iframeWindow = this.iframe.contentWindow;
-        this.addEventListener("DOMContentLoaded", function DOMContentLoaded() {
-          this.removeEventListener("DOMContentLoaded", DOMContentLoaded);
+        this.addEventListener("DOMContentLoaded", function DOMContentLoaded(event) {
+          if (event.target != this.iframe.contentDocument)
+            return;
+          this.removeEventListener("DOMContentLoaded", DOMContentLoaded, true);
           this.isActive = !this.minimized;
           // process this._callbacks, then set to null so the chatbox creator
           // knows to make new callbacks immediately.
           for (let callback of this._callbacks) {
             if (callback)
               callback(iframeWindow);
           }
           this._callbacks = null;
@@ -43,17 +45,17 @@
             this.setAttribute("activity", true);
             this.parentNode.updateTitlebar(this);
           }.bind(this);
           iframeWindow.addEventListener("socialChatActivity", chatActivity);
           iframeWindow.addEventListener("unload", function unload() {
             iframeWindow.removeEventListener("unload", unload);
             iframeWindow.removeEventListener("socialChatActivity", chatActivity);
           });
-        });
+        }, true);
         this.setAttribute("src", this.src);
       ]]></constructor>
 
       <field name="iframe" readonly="true">
         document.getAnonymousElementByAttribute(this, "anonid", "iframe");
       </field>
 
       <property name="minimized">