Setting of the `crossorigin` attribute is not necessary for same-origin images, and causes an immediate image reload (albeit from cache) necessitating the use of a load event listener which subsequently mutates the snapshot. This change allows us to avoid the mutation of the snapshot for the same-origin case. * Modify inlineImages test to remove delay and show that we can inline images without mutation * Add an explicit test for when the `image.crossOrigin = 'anonymous';` method is necessary. Uses a combination of about:blank and our test server to simulate a cross-origin context * Other test changes: there were some spurious rrweb mutations being generated by the addition of the crossorigin attribute that are now elimnated from the rrweb/__snapshots__/integration.test.ts.snap after this PR - this is good
22 lines
539 B
TypeScript
22 lines
539 B
TypeScript
import * as puppeteer from 'puppeteer';
|
|
import * as http from 'http';
|
|
|
|
export async function waitForRAF(page: puppeteer.Page) {
|
|
return await page.evaluate(() => {
|
|
return new Promise((resolve) => {
|
|
requestAnimationFrame(() => {
|
|
requestAnimationFrame(resolve);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
export function getServerURL(server: http.Server): string {
|
|
const address = server.address();
|
|
if (address && typeof address !== 'string') {
|
|
return `http://localhost:${address.port}`;
|
|
} else {
|
|
return `${address}`;
|
|
}
|
|
}
|