nested record iframe (#63)

* pick nested branch

* iframe snapshot

* temp: add bundle file to git

* revert ignore file

* refactor iframe impl
1. do callback one iframe is loaded, let rrweb handle the rest
2. handle iframe as normal element in rebuild

* rename hook function
This commit is contained in:
yz-yu
2021-02-07 14:00:22 +08:00
committed by GitHub
parent a3ff5e5ea8
commit 98aa732d17
11 changed files with 343 additions and 7 deletions

View File

@@ -119,3 +119,50 @@ describe('integration tests', function (this: ISuite) {
}).timeout(5000);
}
});
describe('iframe integration tests', function (this: ISuite) {
const iframeHtml = path.join(__dirname, 'iframe-html/main.html');
const raw = fs.readFileSync(iframeHtml, 'utf-8');
before(async () => {
this.server = await server();
this.browser = await puppeteer.launch({
// headless: false,
});
const bundle = await rollup.rollup({
input: path.resolve(__dirname, '../src/index.ts'),
plugins: [typescript()],
});
const { code } = await bundle.generate({
name: 'rrweb',
format: 'iife',
});
this.code = code;
});
after(async () => {
await this.browser.close();
await this.server.close();
});
it('snapshot async iframes', async () => {
const page: puppeteer.Page = await this.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`);
await page.setContent(raw, {
waitUntil: 'load',
});
const snapshotResult = JSON.stringify(
await page.evaluate(`${this.code};
rrweb.snapshot(document)[0];
`),
null,
2,
);
const result = matchSnapshot(snapshotResult, __filename, this.title);
assert(result.pass, result.pass ? '' : result.report());
}).timeout(5000);
});