bug 589961: fix test-hidden-frame.testFrame failure on Firefox 3.6; r=atul
authorMyk Melez <myk@mozilla.org>
Tue, 24 Aug 2010 11:51:23 -0700
changeset 762 37288479d249168668abd60a907620fa7f593128
parent 761 91db3981a6eb3722c72f95cb51d04a3d2c995747
child 763 db0eabc310619d00ce47372ecaafba7d2539b601
push id286
push usermyk@mozilla.com
push dateTue, 24 Aug 2010 18:52:23 +0000
reviewersatul
bugs589961
bug 589961: fix test-hidden-frame.testFrame failure on Firefox 3.6; r=atul
packages/jetpack-core/lib/hidden-frame.js
--- a/packages/jetpack-core/lib/hidden-frame.js
+++ b/packages/jetpack-core/lib/hidden-frame.js
@@ -144,18 +144,24 @@ exports.add = function JP_SDK_Frame_add(
 
     element.setAttribute("type", "content");
     hostDocument.documentElement.appendChild(element);
 
     /* Public API: hiddenFrame.element */
     frame.__defineGetter__("element", function () element);
 
     // Notify consumers that the frame is ready.
-    for (let handler in frame.onReady)
-      errors.catchAndLog(function () handler.call(frame))();
+    function onReadyListener(event) {
+      element.removeEventListener("DOMContentLoaded", onReadyListener, false);
+      if (event.target == element.contentDocument) {
+        for (let handler in frame.onReady)
+          errors.catchAndLog(function () handler.call(frame))();
+      }
+    }
+    element.addEventListener("DOMContentLoaded", onReadyListener, false);
 
     cache.push({
       frame: frame,
       element: element,
       unload: function unload() {
         hostDocument.documentElement.removeChild(element);
       }
     });