Decrease embedded img size for inlineImages (#836)

* Decrease embedded img size for inlineImages

* Fix the test

* Use webp for image snapshots

* Implemented optional param dataURLOptions
This commit is contained in:
Cristi Constantin
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 24202d2486
commit 4c06535309
5 changed files with 33 additions and 8 deletions

View File

@@ -199,14 +199,17 @@ iframe.contentDocument.querySelector('center').clientHeight
waitUntil: 'load',
});
await page.waitForSelector('img', { timeout: 1000 });
await page.evaluate(`${code}var snapshot = rrweb.snapshot(document, {inlineImages: true, inlineStylesheet: false});
`);
await page.evaluate(`${code}var snapshot = rrweb.snapshot(document, {
dataURLOptions: { type: "image/webp", quality: 0.8 },
inlineImages: true,
inlineStylesheet: false
})`);
await page.waitFor(100);
const snapshot = await page.evaluate(
'JSON.stringify(snapshot[0], null, 2);',
);
assert(snapshot.includes('"rr_dataURL"'));
assert(snapshot.includes('data:image/png;base64,'));
assert(snapshot.includes('data:image/webp;base64,'));
});
});