From aa046c45f3dd48f9d1758a7ba0c80a4f80a79eab Mon Sep 17 00:00:00 2001 From: Eoghan Murray Date: Wed, 8 Nov 2023 15:19:12 +0000 Subject: [PATCH] I missed the checkAncestors:true argument on needMaskingText with the text mutation - modify the test to show where this would have failed --- packages/rrweb/src/record/mutation.ts | 1 + .../test/__snapshots__/integration.test.ts.snap | 14 +++++++++----- packages/rrweb/test/integration.test.ts | 6 +++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/rrweb/src/record/mutation.ts b/packages/rrweb/src/record/mutation.ts index 7c209605d0..2f6b6550ff 100644 --- a/packages/rrweb/src/record/mutation.ts +++ b/packages/rrweb/src/record/mutation.ts @@ -515,6 +515,7 @@ export default class MutationBuffer { m.target, this.maskTextClass, this.maskTextSelector, + true, // checkAncestors ) && value ? this.maskTextFn ? this.maskTextFn(value, closestElementOfNode(m.target)) diff --git a/packages/rrweb/test/__snapshots__/integration.test.ts.snap b/packages/rrweb/test/__snapshots__/integration.test.ts.snap index 05e093633e..e3fb552c7e 100644 --- a/packages/rrweb/test/__snapshots__/integration.test.ts.snap +++ b/packages/rrweb/test/__snapshots__/integration.test.ts.snap @@ -964,6 +964,12 @@ exports[`record integration tests can mask character data mutations with regexp \\"source\\": 0, \\"texts\\": [], \\"attributes\\": [ + { + \\"id\\": 10, + \\"attributes\\": { + \\"class\\": \\"custom-mask\\" + } + }, { \\"id\\": 7, \\"attributes\\": { @@ -984,9 +990,7 @@ exports[`record integration tests can mask character data mutations with regexp \\"node\\": { \\"type\\": 2, \\"tagName\\": \\"li\\", - \\"attributes\\": { - \\"class\\": \\"custom-mask\\" - }, + \\"attributes\\": {}, \\"childNodes\\": [], \\"id\\": 20 } @@ -1018,8 +1022,8 @@ exports[`record integration tests can mask character data mutations with regexp \\"source\\": 0, \\"texts\\": [ { - \\"id\\": 22, - \\"value\\": \\"****** *******\\" + \\"id\\": 21, + \\"value\\": \\"********** ****** ** ****** *** **** ****\\" } ], \\"attributes\\": [], diff --git a/packages/rrweb/test/integration.test.ts b/packages/rrweb/test/integration.test.ts index 344f8e81b9..0d4c871854 100644 --- a/packages/rrweb/test/integration.test.ts +++ b/packages/rrweb/test/integration.test.ts @@ -1232,7 +1232,7 @@ describe('record integration tests', function (this: ISuite) { const li = document.createElement('li'); const ul = document.querySelector('ul') as HTMLUListElement; const p = document.querySelector('p') as HTMLParagraphElement; - [li, p].forEach((element) => { + [ul, p].forEach((element) => { element.className = 'custom-mask'; }); ul.appendChild(li); @@ -1242,8 +1242,8 @@ describe('record integration tests', function (this: ISuite) { await page.evaluate(() => { // generate a characterData mutation; innerText doesn't do that - const p = document.querySelector('p') as HTMLParagraphElement; - (p.childNodes[0] as Text).insertData(0, 'doubly '); + const li = document.querySelector('li:not(:empty)') as HTMLLIElement; + (li.childNodes[0] as Text).insertData(0, 'descendent should be masked '); }); const snapshots = (await page.evaluate(