diff --git a/packages/replay/src/iframe-guard.test.ts b/packages/replay/src/iframe-guard.test.ts index 6fa8f1a8..30dc8eb0 100644 --- a/packages/replay/src/iframe-guard.test.ts +++ b/packages/replay/src/iframe-guard.test.ts @@ -281,6 +281,28 @@ describe('iframe guard: a blocked iframe is a placeholder, whatever the recorder expect(guard(custom)).toBe(custom); }); + it('passes the rrweb 2.2.0 annotation (8) and asset (7) events through unchanged, whatever ids they mention', () => { + const { guard, onViolation } = make(); + const inner = el('p', {}); + const frame = el('iframe', { class: 'rr-block' }, [doc([inner])]); + guard(snapshot(doc([el('body', {}, [frame])]))); + expect(onViolation).toHaveBeenCalledTimes(1); // the snapshot's stripped content (the once-per-session report) + const shapes = [ + { annotationData: { type: 'caption', text: 'marker' } }, + { url: 'asset://x', payload: 'p' }, + // not rrweb's real shapes: id fields and an incremental `source` that would route them through the + // tainted-id / mutation checks if the guard stopped treating types 7 and 8 as node-less + { id: inner.id, source: SOURCE.Mutation }, + { id: inner.id, source: SOURCE.Scroll }, + ]; + for (const type of [8, 7]) { + for (const data of shapes) { + const e = { type, timestamp: 3, data } as unknown as eventWithTime; + expect(guard(e)).toBe(e); // the report latch is spent, so identity is the assertion that matters + } + } + }); + it('scans nodes added while recording: an added blocked iframe is stripped, its later attach dropped', () => { const { guard, onViolation } = make(); guard(snapshot(doc([el('body', {})])));