Bug 760424, browser_tab_dragdrop.js tries to remove wrong eventlistener, r=mats

--HG--
extra : rebase_source : 2bed8e2633d8a9e87db40a7096310dbe1c98c47c
This commit is contained in:
Olli Pettay 2012-06-01 18:14:10 +03:00
parent f12c7e0f8f
commit be507afbb9

View File

@ -90,8 +90,12 @@ function test()
} }
var loads = 0; var loads = 0;
function waitForLoad(tab) { function waitForLoad(event, tab, listenerContainer) {
gBrowser.getBrowserForTab(gBrowser.tabs[tab]).removeEventListener("load", arguments.callee, true); var b = gBrowser.getBrowserForTab(gBrowser.tabs[tab]);
if (b.contentDocument != event.target) {
return;
}
gBrowser.getBrowserForTab(gBrowser.tabs[tab]).removeEventListener("load", listenerContainer.listener, true);
++loads; ++loads;
if (loads == tabs.length - 1) { if (loads == tabs.length - 1) {
executeSoon(test1); executeSoon(test1);
@ -99,7 +103,9 @@ function test()
} }
function fn(f, arg) { 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) { for (var i = 1; i < tabs.length; ++i) {
gBrowser.getBrowserForTab(tabs[i]).addEventListener("load", fn(waitForLoad,i), true); gBrowser.getBrowserForTab(tabs[i]).addEventListener("load", fn(waitForLoad,i), true);