Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window.history change testing #1466

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
};
24 changes: 24 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,30 @@ 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
Loading