From 3f032619b47afd2a8beebe79ed2d071aaca4e436 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Fri, 3 Apr 2026 13:26:01 +0200 Subject: [PATCH] Fix firefox errors in cross-iframe communiccation --- src/ext/module/EventBus.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/ext/module/EventBus.ts b/src/ext/module/EventBus.ts index db83bf2..ebe1b3a 100644 --- a/src/ext/module/EventBus.ts +++ b/src/ext/module/EventBus.ts @@ -90,7 +90,24 @@ export default class EventBus { } } + private cloneContext(context: EventBusContext = {}): EventBusContext { + return { + stopPropagation: context.stopPropagation, + origin: context.origin, + frameUrl: context.frameUrl, + visitedBusses: context.visitedBusses ? [...context.visitedBusses] : undefined, + commandId: context.commandId, + comms: context.comms ? { + forwardTo: context.comms.forwardTo, + sourceFrame: context.comms.sourceFrame ? { ...context.comms.sourceFrame } : undefined + } : undefined, + borderCrossings: context.borderCrossings ? { ...context.borderCrossings } : undefined + }; + } + send(command: string, commandData: any, context: EventBusContext = {}) { + context = this.cloneContext(context); // Firefox throws an error if we don't clone the context. + if (context.visitedBusses?.includes(this.uuid)) { console.warn('this bus was already visited before. Doing nothing.'); return;