From c5ddfdc15dc47ef38dbc76e1013fb8aa943ba13b Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Wed, 28 Oct 2026 16:08:01 +0500 Subject: [PATCH 1/4] test(replay): pin that the rrweb 2.2.0 annotation event passes the iframe guard (#116) Co-Authored-By: Claude Sonnet 5.5 --- packages/replay/src/iframe-guard.test.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/replay/src/iframe-guard.test.ts b/packages/replay/src/iframe-guard.test.ts index 6fa8f1a8..8f795de7 100644 --- a/packages/replay/src/iframe-guard.test.ts +++ b/packages/replay/src/iframe-guard.test.ts @@ -281,6 +281,18 @@ 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 event (EventType 7) through unchanged, even with a masked-looking payload', () => { + const { guard, onViolation } = make(); + guard(snapshot(doc([el('body', {})]))); + const annotation = { + type: 7, + timestamp: 3, + data: { annotationData: { text: 'marker', id: 1 } }, + } as unknown as eventWithTime; + expect(guard(annotation)).toBe(annotation); + expect(onViolation).not.toHaveBeenCalled(); + }); + 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', {})]))); From 878f5367e5623a1b41952911756615b0fdd74e1f Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Wed, 28 Oct 2026 20:56:22 +0500 Subject: [PATCH 2/4] test(replay): annotation is EventType 8 (7 is asset); pin both pass the guard even with a blocked iframe's id (#116) Co-Authored-By: Claude Sonnet 5.5 --- packages/replay/src/iframe-guard.test.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/replay/src/iframe-guard.test.ts b/packages/replay/src/iframe-guard.test.ts index 8f795de7..513f0a03 100644 --- a/packages/replay/src/iframe-guard.test.ts +++ b/packages/replay/src/iframe-guard.test.ts @@ -281,15 +281,19 @@ 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 event (EventType 7) through unchanged, even with a masked-looking payload', () => { + it('passes the rrweb 2.2.0 annotation (8) and asset (7) events through unchanged, even when they carry the id of a blocked iframe', () => { const { guard, onViolation } = make(); - guard(snapshot(doc([el('body', {})]))); - const annotation = { - type: 7, - timestamp: 3, - data: { annotationData: { text: 'marker', id: 1 } }, - } as unknown as eventWithTime; - expect(guard(annotation)).toBe(annotation); + const frame = el('iframe', { class: 'rr-block', rr_width: '10px', rr_height: '5px' }); + guard(snapshot(doc([el('body', {}, [frame])]))); + const events = [8, 7].map( + (type) => + ({ + type, + timestamp: 3, + data: { id: frame.id, annotationData: { text: 'marker', id: frame.id } }, + }) as unknown as eventWithTime, + ); + for (const e of events) expect(guard(e)).toBe(e); expect(onViolation).not.toHaveBeenCalled(); }); From b515c1d926ae36cb1af48b9bd5aaae3e6d0e0e66 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Wed, 28 Oct 2026 21:00:39 +0500 Subject: [PATCH 3/4] test(replay): annotation/asset passthrough test uses real shapes and a tainted id, catches routing regressions (#116 review) Co-Authored-By: Claude Sonnet 5.5 --- packages/replay/src/iframe-guard.test.ts | 29 +++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/packages/replay/src/iframe-guard.test.ts b/packages/replay/src/iframe-guard.test.ts index 513f0a03..1f710f7e 100644 --- a/packages/replay/src/iframe-guard.test.ts +++ b/packages/replay/src/iframe-guard.test.ts @@ -281,19 +281,26 @@ 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, even when they carry the id of a blocked iframe', () => { + it('passes the rrweb 2.2.0 annotation (8) and asset (7) events through unchanged, whatever ids they mention', () => { const { guard, onViolation } = make(); - const frame = el('iframe', { class: 'rr-block', rr_width: '10px', rr_height: '5px' }); + const inner = el('p', {}); + const frame = el('iframe', { class: 'rr-block' }, [doc([inner])]); guard(snapshot(doc([el('body', {}, [frame])]))); - const events = [8, 7].map( - (type) => - ({ - type, - timestamp: 3, - data: { id: frame.id, annotationData: { text: 'marker', id: frame.id } }, - }) as unknown as eventWithTime, - ); - for (const e of events) expect(guard(e)).toBe(e); + onViolation.mockClear(); // the snapshot's stripped content was reported; the events below must not add more + 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); + } + } expect(onViolation).not.toHaveBeenCalled(); }); From 5d30d8417abe83c30871f730088e1871421d8291 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Wed, 28 Oct 2026 21:02:31 +0500 Subject: [PATCH 4/4] test(replay): drop the vacuous onViolation assertion in the passthrough test (#116 review) Co-Authored-By: Claude Sonnet 5.5 --- packages/replay/src/iframe-guard.test.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/replay/src/iframe-guard.test.ts b/packages/replay/src/iframe-guard.test.ts index 1f710f7e..30dc8eb0 100644 --- a/packages/replay/src/iframe-guard.test.ts +++ b/packages/replay/src/iframe-guard.test.ts @@ -286,7 +286,7 @@ describe('iframe guard: a blocked iframe is a placeholder, whatever the recorder const inner = el('p', {}); const frame = el('iframe', { class: 'rr-block' }, [doc([inner])]); guard(snapshot(doc([el('body', {}, [frame])]))); - onViolation.mockClear(); // the snapshot's stripped content was reported; the events below must not add more + 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' }, @@ -298,10 +298,9 @@ describe('iframe guard: a blocked iframe is a placeholder, whatever the recorder 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); + expect(guard(e)).toBe(e); // the report latch is spent, so identity is the assertion that matters } } - expect(onViolation).not.toHaveBeenCalled(); }); it('scans nodes added while recording: an added blocked iframe is stripped, its later attach dropped', () => {