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 cce12ee77d
commit 272f91b26c

View File

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