improve robustness of inlineImages feature (#812)

* fix: add inlineImages option to rrrweb recorder and try to make the code more robust

* Improve robustness
This commit is contained in:
Yun Feng
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 269b8bb216
commit 0153270680
3 changed files with 33 additions and 33 deletions

View File

@@ -194,22 +194,20 @@ iframe.contentDocument.querySelector('center').clientHeight
it('correctly saves images offline', async () => {
const page: puppeteer.Page = await browser.newPage();
// console for debug
// tslint:disable-next-line: no-console
page.on('console', (msg) => console.log(msg.text()));
await page.goto('http://localhost:3030/html/picture.html', { waitUntil: 'load' });
await page.goto('http://localhost:3030/html/picture.html', {
waitUntil: 'load',
});
await page.waitForSelector('img', { timeout: 1000 });
const snapshot = await page.evaluate(`${code}
const [snap] = rrweb.snapshot(document, {inlineImages: true, inlineStylesheet: false});
JSON.stringify(snap, null, 2);
await page.evaluate(`${code}var snapshot = rrweb.snapshot(document, {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,'));
});
});
describe('iframe integration tests', function (this: ISuite) {