Skip to content

Commit

Permalink
Update packages/rrweb/test/record.test.ts
Browse files Browse the repository at this point in the history
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
  • Loading branch information
YunFeng0817 and Juice10 committed Jan 10, 2023
1 parent c4dc237 commit 0074c10
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions packages/rrweb/test/record.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,27 +591,30 @@ describe('record', function (this: ISuite) {

it('captures adopted stylesheets of shadow doms in checkout full snapshot', async () => {
await ctx.page.evaluate(() => {
document.body.innerHTML = `
<div id="shadow-host-1">entry</div>
`;
return new Promise((resolve) => {
document.body.innerHTML = `
<div id="shadow-host-1">entry</div>
`;

let shadowHost = document.querySelector('div')!;
shadowHost!.attachShadow({ mode: 'open' });
const sheet = new CSSStyleSheet();
sheet.replaceSync!('h1 {color: blue;}');
shadowHost.shadowRoot!.adoptedStyleSheets = [sheet];
let shadowHost = document.querySelector('div')!;
shadowHost!.attachShadow({ mode: 'open' });
const sheet = new CSSStyleSheet();
sheet.replaceSync!('h1 {color: blue;}');
shadowHost.shadowRoot!.adoptedStyleSheets = [sheet];

const { rrweb, emit } = (window as unknown) as IWindow;
rrweb.record({
emit,
});
const { rrweb, emit } = (window as unknown) as IWindow;
rrweb.record({
emit,
});

setTimeout(() => {
// When a full snapshot is checked out manually, all adoptedStylesheets should also be captured.
rrweb.record.takeFullSnapshot(true);
}, 10);
setTimeout(() => {
// When a full snapshot is checked out manually, all adoptedStylesheets should also be captured.
rrweb.record.takeFullSnapshot(true);
resolve(undefined);
}, 10);
});
});
await ctx.page.waitForTimeout(200);
await waitForRAF(page);
assertSnapshot(ctx.events);
});

Expand Down

0 comments on commit 0074c10

Please sign in to comment.