try to inline linked stylesheet when in same origin

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent 7fadc986ec
commit 51737d9b53
6 changed files with 110 additions and 33 deletions

View File

@@ -64,7 +64,7 @@ describe('integration tests', () => {
before(async () => {
this.server = await server();
this.browser = await puppeteer.launch({
headless: false,
// headless: false,
executablePath: '/home/yanzhen/Desktop/chrome-linux/chrome',
});
@@ -79,33 +79,35 @@ describe('integration tests', () => {
this.code = code;
});
after(() => {
this.browser.close();
this.server.close();
after(async () => {
await this.browser.close();
await this.server.close();
});
for (const html of htmls) {
for (const html of htmls.slice(0, 10)) {
it('[html file]: ' + html.filePath, async () => {
const page: puppeteer.Page = await this.browser.newPage();
await page.goto(`http://localhost:3030/html/${html.filePath}`);
// 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(html.src);
page.once('load', async () => {
await page.evaluate(() => {
const x = new XMLSerializer();
return x.serializeToString(document);
});
const rebuildHtml = (await page.evaluate(`${this.code}
const x = new XMLSerializer();
const snap = rrweb.snapshot(document);
x.serializeToString(rrweb.rebuild(snap));
`)).replace(/\n\n/g, '');
await page.goto(`data:text/html,${html.dest}`);
const destHtml = (await page.evaluate(() => {
const x = new XMLSerializer();
return x.serializeToString(document);
})).replace(/\n\n/g, '');
expect(rebuildHtml).to.equal(destHtml);
await page.evaluate(() => {
const x = new XMLSerializer();
return x.serializeToString(document);
});
const rebuildHtml = (await page.evaluate(`${this.code}
const x = new XMLSerializer();
const snap = rrweb.snapshot(document);
x.serializeToString(rrweb.rebuild(snap));
`)).replace(/\n\n/g, '');
await page.goto(`http://localhost:3030/html`);
await page.setContent(html.dest);
const destHtml = (await page.evaluate(() => {
const x = new XMLSerializer();
return x.serializeToString(document);
})).replace(/\n\n/g, '');
expect(rebuildHtml).to.equal(destHtml);
}).timeout(5000);
}
});