From a220835eeb81ca4f294682e060d46c8853720d7f Mon Sep 17 00:00:00 2001 From: Justin Halsall Date: Wed, 16 Nov 2022 14:25:36 +0100 Subject: [PATCH] Fix: Post message can break cross origin iframe recording (#1053) --- packages/rrweb/src/plugins/canvas-webrtc/record/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/rrweb/src/plugins/canvas-webrtc/record/index.ts b/packages/rrweb/src/plugins/canvas-webrtc/record/index.ts index 106fc6683d..03aad10c9c 100644 --- a/packages/rrweb/src/plugins/canvas-webrtc/record/index.ts +++ b/packages/rrweb/src/plugins/canvas-webrtc/record/index.ts @@ -262,10 +262,12 @@ export class RRWebPluginCanvasWebRTCRecord { } private isCrossOriginIframeMessageEventContent( - event: MessageEvent, + event: MessageEvent, ): event is MessageEvent { return Boolean( - 'type' in event.data && + event.data && + typeof event.data === 'object' && + 'type' in event.data && 'data' in event.data && (event.data as CrossOriginIframeMessageEventContent).type === 'rrweb-canvas-webrtc' &&