Bug 1072477 - [e10s] Make EventTarget shim work when removeEventListener called from listener (r=mconley)

This commit is contained in:
Bill McCloskey 2014-09-29 13:05:23 -07:00
parent 39c4b562c9
commit 51c7dd31c8

View File

@ -464,17 +464,24 @@ let EventTargetParent = {
continue; continue;
} }
let forType = setDefault(listeners, type, []); let forType = setDefault(listeners, type, []);
// Make a copy in case they call removeEventListener in the listener.
let handlers = [];
for (let {listener, wantsUntrusted, useCapture} of forType) { for (let {listener, wantsUntrusted, useCapture} of forType) {
if ((wantsUntrusted || isTrusted) && useCapture == capturing) { if ((wantsUntrusted || isTrusted) && useCapture == capturing) {
try { handlers.push(listener);
if ("handleEvent" in listener) { }
listener.handleEvent(event); }
} else {
listener.call(event.target, event); for (let handler of handlers) {
} try {
} catch (e) { if ("handleEvent" in handler) {
Cu.reportError(e); handler.handleEvent(event);
} else {
handler.call(event.target, event);
} }
} catch (e) {
Cu.reportError(e);
} }
} }
} }