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,31 +7,31 @@ const Ci = Components.interfaces;
const helper = new Helper(); const helper = new Helper();
let sameProcessInstanceNumber = 0; let sameProcessInstanceNumber = 0;
const topBrowingContextToAgents = new Map(); const topBrowingContextToAgents = new Map();
class JugglerFrameChild extends JSWindowActorChild { class JugglerFrameChild extends JSWindowActorChild {
constructor() { constructor() {
super(); super();
this._eventListeners = []; this._eventListeners = [];
} }
handleEvent(aEvent) { handleEvent(aEvent) {
const agents = this._agents(); const agents = this._agents();
if (!agents) if (!agents) return;
return;
if (aEvent.type === 'DOMWillOpenModalDialog') { switch (aEvent.type) {
agents.channel.pause(); case 'DOMWillOpenModalDialog':
return; agents.channel.pause();
} break;
if (aEvent.type === 'DOMModalDialogClosed') { case 'DOMModalDialogClosed':
agents.channel.resumeSoon(); agents.channel.resumeSoon();
return; break;
} default:
if (aEvent.target === this.document) { if (aEvent.target === this.document) {
agents.pageAgent.onWindowEvent(aEvent); agents.pageAgent.onWindowEvent(aEvent);
agents.frameTree.onWindowEvent(aEvent); agents.frameTree.onWindowEvent(aEvent);
}
break;
} }
} }
@ -46,41 +46,38 @@ class JugglerFrameChild extends JSWindowActorChild {
this._agents()?.pageAgent.onWindowEvent(event); this._agents()?.pageAgent.onWindowEvent(event);
})); }));
if (this.document.documentURI.startsWith('moz-extension://')) if (this._isMozExtension()) return;
return;
// Child frame events will be forwarded to related top-level agents. if (!this.browsingContext.parent) {
if (this.browsingContext.parent) let agents = topBrowingContextToAgents.get(this.browsingContext);
return; if (!agents) {
agents = initialize(this.browsingContext, this.docShell);
let agents = topBrowingContextToAgents.get(this.browsingContext); topBrowingContextToAgents.set(this.browsingContext, agents);
if (!agents) { }
agents = initialize(this.browsingContext, this.docShell); agents.channel.bindToActor(this);
topBrowingContextToAgents.set(this.browsingContext, agents); agents.actor = this;
} }
agents.channel.bindToActor(this);
agents.actor = this;
} }
didDestroy() { didDestroy() {
helper.removeListeners(this._eventListeners); helper.removeListeners(this._eventListeners);
if (this.browsingContext.parent) if (this.browsingContext.parent) return;
return;
const agents = topBrowingContextToAgents.get(this.browsingContext); 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); topBrowingContextToAgents.delete(this.browsingContext);
agents.channel.resetTransport(); agents.channel.resetTransport();
agents.pageAgent.dispose(); agents.pageAgent.dispose();
agents.frameTree.dispose(); agents.frameTree.dispose();
} }
receiveMessage() { } _isMozExtension() {
return this.document.documentURI.startsWith('moz-extension://');
}
receiveMessage() {}
} }
var EXPORTED_SYMBOLS = ['JugglerFrameChild']; var EXPORTED_SYMBOLS = ['JugglerFrameChild'];