@@ -21,6 +21,7 @@ export class IframeManager {
21
21
private mirror : Mirror ;
22
22
private mutationCb : mutationCallBack ;
23
23
private wrappedEmit : ( e : eventWithoutTime , isCheckout ?: boolean ) => void ;
24
+ private takeFullSnapshot : ( isCheckout ?: boolean ) => void ;
24
25
private loadListener ?: ( iframeEl : HTMLIFrameElement ) => unknown ;
25
26
private stylesheetManager : StylesheetManager ;
26
27
private recordCrossOriginIframes : boolean ;
@@ -31,9 +32,11 @@ export class IframeManager {
31
32
stylesheetManager : StylesheetManager ;
32
33
recordCrossOriginIframes : boolean ;
33
34
wrappedEmit : ( e : eventWithoutTime , isCheckout ?: boolean ) => void ;
35
+ takeFullSnapshot : ( isCheckout ?: boolean ) => void ;
34
36
} ) {
35
37
this . mutationCb = options . mutationCb ;
36
38
this . wrappedEmit = options . wrappedEmit ;
39
+ this . takeFullSnapshot = options . takeFullSnapshot ;
37
40
this . stylesheetManager = options . stylesheetManager ;
38
41
this . recordCrossOriginIframes = options . recordCrossOriginIframes ;
39
42
this . crossOriginIframeStyleMirror = new CrossOriginIframeMirror (
@@ -51,6 +54,16 @@ export class IframeManager {
51
54
this . iframes . set ( iframeEl , true ) ;
52
55
if ( iframeEl . contentWindow )
53
56
this . crossOriginIframeMap . set ( iframeEl . contentWindow , iframeEl ) ;
57
+
58
+ if ( ! iframeEl . contentDocument && iframeEl . contentWindow )
59
+ iframeEl . contentWindow . postMessage (
60
+ {
61
+ type : 'rrweb' ,
62
+ origin : window . location . origin ,
63
+ snapshot : true ,
64
+ } ,
65
+ '*' ,
66
+ ) ;
54
67
}
55
68
56
69
public addLoadListener ( cb : ( iframeEl : HTMLIFrameElement ) => unknown ) {
@@ -95,10 +108,21 @@ export class IframeManager {
95
108
)
96
109
return ;
97
110
98
- const iframeSourceWindow = message . source ;
111
+ const iframeSourceWindow = crossOriginMessageEvent . source ;
99
112
if ( ! iframeSourceWindow ) return ;
100
113
101
- const iframeEl = this . crossOriginIframeMap . get ( message . source ) ;
114
+ if (
115
+ iframeSourceWindow == window . parent &&
116
+ window != window . parent &&
117
+ crossOriginMessageEvent . data . snapshot
118
+ ) {
119
+ this . takeFullSnapshot ( ) ;
120
+ return ;
121
+ }
122
+
123
+ const iframeEl = this . crossOriginIframeMap . get (
124
+ crossOriginMessageEvent . source ,
125
+ ) ;
102
126
if ( ! iframeEl ) return ;
103
127
104
128
const transformedEvent = this . transformCrossOriginEvent (
0 commit comments