Update JugglerFrameChild.jsm

Signed-off-by: Radeonares32 <56337258+Radeonares32@users.noreply.github.com>
This commit is contained in:
Radeonares32 2024-08-31 23:24:27 +03:00 committed by GitHub
parent a6b320e362
commit 6e875b51ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,32 +7,32 @@ const Ci = Components.interfaces;
const helper = new Helper();
let sameProcessInstanceNumber = 0;
const topBrowingContextToAgents = new Map();
class JugglerFrameChild extends JSWindowActorChild {
constructor() {
super();
this._eventListeners = [];
}
handleEvent(aEvent) {
const agents = this._agents();
if (!agents)
return;
if (aEvent.type === 'DOMWillOpenModalDialog') {
if (!agents) return;
switch (aEvent.type) {
case 'DOMWillOpenModalDialog':
agents.channel.pause();
return;
}
if (aEvent.type === 'DOMModalDialogClosed') {
break;
case 'DOMModalDialogClosed':
agents.channel.resumeSoon();
return;
}
break;
default:
if (aEvent.target === this.document) {
agents.pageAgent.onWindowEvent(aEvent);
agents.frameTree.onWindowEvent(aEvent);
}
break;
}
}
_agents() {
@ -46,13 +46,9 @@ class JugglerFrameChild extends JSWindowActorChild {
this._agents()?.pageAgent.onWindowEvent(event);
}));
if (this.document.documentURI.startsWith('moz-extension://'))
return;
// Child frame events will be forwarded to related top-level agents.
if (this.browsingContext.parent)
return;
if (this._isMozExtension()) return;
if (!this.browsingContext.parent) {
let agents = topBrowingContextToAgents.get(this.browsingContext);
if (!agents) {
agents = initialize(this.browsingContext, this.docShell);
@ -61,25 +57,26 @@ class JugglerFrameChild extends JSWindowActorChild {
agents.channel.bindToActor(this);
agents.actor = this;
}
}
didDestroy() {
helper.removeListeners(this._eventListeners);
if (this.browsingContext.parent)
return;
if (this.browsingContext.parent) return;
const agents = topBrowingContextToAgents.get(this.browsingContext);
// The agents are already re-bound to a new actor.
if (agents.actor !== this)
return;
if (agents.actor !== this) return;
topBrowingContextToAgents.delete(this.browsingContext);
agents.channel.resetTransport();
agents.pageAgent.dispose();
agents.frameTree.dispose();
}
_isMozExtension() {
return this.document.documentURI.startsWith('moz-extension://');
}
receiveMessage() {}
}