fix(calls): read the EC iframe document defensively when the widget failed to load

When the Element Call frame's navigation fails (offline, blocked) it becomes a
cross-origin error page and `iframe.contentWindow.document` throws a
SecurityError. Every DOM-driven call hook (CallControl selectors, deafen DOM
fallback, useCallSpeakers/useRemoteAllMuted observers, CallEmbed theme
injection) read it unguarded, so the moment the 25 s load watchdog fired the
page logged a burst of uncaught SecurityErrors. Reproduced headless by aborting
the EC index request. One `getCallDocument()` helper now treats "can't read" as
"not loaded yet"; the watchdog overlay itself was already correct.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
2026-09-19 00:15:37 -04:00
co-authored by Claude Opus 5
parent 4e455ae42e
commit 70620d4b43
4 changed files with 25 additions and 8 deletions
+3 -4
View File
@@ -1,5 +1,6 @@
import { useEffect, useState } from 'react';
import { CallEmbed } from '../plugins/call';
import { getCallDocument } from '../plugins/call/utils';
import { isUserId } from '../utils/matrix';
import { nextSpeakerSet } from '../utils/speakerSet';
import { useCallMembers, useCallSession } from './useCall';
@@ -38,8 +39,7 @@ export const useCallSpeakers = (callEmbed: CallEmbed): Set<string> => {
return undefined;
}
const getDoc = (): Document | undefined =>
callEmbed.iframe.contentDocument ?? callEmbed.iframe.contentWindow?.document ?? undefined;
const getDoc = (): Document | undefined => getCallDocument(callEmbed.iframe);
let tileObserver: MutationObserver | undefined;
@@ -163,8 +163,7 @@ export const useRemoteAllMuted = (callEmbed: CallEmbed | undefined): boolean =>
useEffect(() => {
if (!callEmbed) return undefined;
const getDoc = (): Document | undefined =>
callEmbed.iframe.contentDocument ?? callEmbed.iframe.contentWindow?.document ?? undefined;
const getDoc = (): Document | undefined => getCallDocument(callEmbed.iframe);
const localUserId = callEmbed.room.client?.getUserId() ?? '';