Bug 760424, browser_tab_dragdrop.js tries to remove wrong eventlistener, r=mats
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Fri, 01 Jun 2012 18:14:10 +0300
changeset 97729 def37b64a7581fdb3cb5aa5d32d33d73449bc408
parent 97728 10f674b1208917e111e9561fdc429f0dc12f598b
child 97730 8818faa56831568017f3c19179cc65dca4daa1da
push id1439
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 20:19:22 +0000
treeherdermozilla-aurora@ea74834dccd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs760424
milestone15.0a1
Bug 760424, browser_tab_dragdrop.js tries to remove wrong eventlistener, r=mats
browser/base/content/test/browser_tab_dragdrop.js
--- a/browser/base/content/test/browser_tab_dragdrop.js
+++ b/browser/base/content/test/browser_tab_dragdrop.js
@@ -85,26 +85,32 @@ function test()
         }, true);
       });
     }, true);
     b.loadURI("about:blank");
 
   }
 
   var loads = 0;
-  function waitForLoad(tab) {
-    gBrowser.getBrowserForTab(gBrowser.tabs[tab]).removeEventListener("load", arguments.callee, true);
+  function waitForLoad(event, tab, listenerContainer) {
+    var b = gBrowser.getBrowserForTab(gBrowser.tabs[tab]);
+    if (b.contentDocument != event.target) {
+      return;
+    }
+    gBrowser.getBrowserForTab(gBrowser.tabs[tab]).removeEventListener("load", listenerContainer.listener, true);
     ++loads;
     if (loads == tabs.length - 1) {
       executeSoon(test1);
     }
   }
 
   function fn(f, arg) {
-    return function () { return f(arg); };
+    var listenerContainer = { listener: null }
+    listenerContainer.listener = function (event) { return f(event, arg, listenerContainer); };
+    return listenerContainer.listener;
   }
   for (var i = 1; i < tabs.length; ++i) {
     gBrowser.getBrowserForTab(tabs[i]).addEventListener("load", fn(waitForLoad,i), true);
   }
 
   setLocation(1, "data:text/html,<title>tab1</title><body>tab1<iframe>");
   setLocation(2, "data:text/plain,tab2");
   setLocation(3, "data:text/html,<title>tab3</title><body>tab3<iframe>");