Bug 1051995 - Removed 'mozdocommand' event listener when browser destroyed. r=fabrice

This commit is contained in:
Morris Tseng 2014-08-25 23:02:00 +02:00
parent 927916753d
commit c47690098b

View File

@ -168,11 +168,14 @@ function BrowserElementParent(frameLoader, hasRemoteFrame, isPendingFrame) {
/* wantsUntrusted = */ false);
}
this._doCommandHandlerBinder = this._doCommandHandler.bind(this);
this._frameElement.addEventListener('mozdocommand',
this._doCommandHandler.bind(this),
this._doCommandHandlerBinder,
/* useCapture = */ false,
/* wantsUntrusted = */ false);
Services.obs.addObserver(this, 'ipc:browser-destroyed', /* ownsWeak = */ true);
this._window._browserElementParents.set(this, null);
// Insert ourself into the prompt service.
@ -919,6 +922,13 @@ BrowserElementParent.prototype = {
}
Services.obs.removeObserver(this, 'remote-browser-frame-shown');
}
case 'ipc:browser-destroyed':
if (this._isAlive() && subject == this._frameLoader) {
Services.obs.removeObserver(this, 'ipc:browser-destroyed');
this._frameElement.removeEventListener('mozdocommand',
this._doCommandHandlerBinder)
}
break;
default:
debug('Unknown topic: ' + topic);
break;