Skip to content

Commit

Permalink
Add absoluteToDoc test in the presence of a window.history change
Browse files Browse the repository at this point in the history
  • Loading branch information
eoghanmurray committed May 2, 2024
1 parent 5e7943d commit 3aaf62f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/rrweb-snapshot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import snapshot, {
classMatchesRegex,
IGNORED_NODE,
genId,
absoluteToDoc,
} from './snapshot';
import rebuild, {
buildNodeWithSN,
Expand All @@ -32,4 +33,5 @@ export {
classMatchesRegex,
IGNORED_NODE,
genId,
absoluteToDoc,
};
20 changes: 20 additions & 0 deletions packages/rrweb-snapshot/test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,26 @@ iframe.contentDocument.querySelector('center').clientHeight
assert(snapshot.includes('data:image/webp;base64,'));
});

it('correctly deals with changes in window.history', async () => {
const page: puppeteer.Page = await browser.newPage();

await page.goto('http://localhost:3030/html/basic.html', {
waitUntil: 'load',
});
await waitForRAF(page); // wait for page to render
await page.evaluate(`${code}
window.val1 = rrweb.absoluteToDoc(document, './rel');
window.history.replaceState({}, null, window.document.location.href + '/artificial/');
window.val2 = rrweb.absoluteToDoc(document, './rel');
`);
await waitForRAF(page);
const snapshot = (await page.evaluate(
'JSON.stringify(window.snapshot, null, 2);',
)) as string;
expect((await page.evaluate('window.val1')) as string).toEqual('http://localhost:3030/html/rel');
expect((await page.evaluate('window.val2')) as string).toEqual('http://localhost:3030/html/basic.html/artificial/rel');
});

it('should save background-clip: text; as the more compatible -webkit-background-clip: test;', async () => {
const page: puppeteer.Page = await browser.newPage();
await page.goto(`http://localhost:3030/html/background-clip-text.html`, {
Expand Down

0 comments on commit 3aaf62f

Please sign in to comment.