fix(snapshot): render srcdoc iframe snapshots (#21003)
This commit is contained in:
parent
0cd39cf002
commit
e28801f6ef
|
|
@ -477,7 +477,7 @@ export function frameSnapshotStreamer(snapshotStreamer: string) {
|
||||||
const name = element.attributes[i].name;
|
const name = element.attributes[i].name;
|
||||||
if (nodeName === 'LINK' && name === 'integrity')
|
if (nodeName === 'LINK' && name === 'integrity')
|
||||||
continue;
|
continue;
|
||||||
if (nodeName === 'IFRAME' && (name === 'src' || name === 'sandbox'))
|
if (nodeName === 'IFRAME' && (name === 'src' || name === 'srcdoc' || name === 'sandbox'))
|
||||||
continue;
|
continue;
|
||||||
if (nodeName === 'FRAME' && name === 'src')
|
if (nodeName === 'FRAME' && name === 'src')
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -130,9 +130,7 @@ it.describe('snapshots', () => {
|
||||||
expect((await snapshotter.resourceContentForTest(resource.response.content._sha1)).toString()).toBe('button { color: blue; }');
|
expect((await snapshotter.resourceContentForTest(resource.response.content._sha1)).toString()).toBe('button { color: blue; }');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should capture frame', async ({ page, server, toImpl, browserName, snapshotter }) => {
|
it('should capture frame', async ({ page, server, toImpl, snapshotter }) => {
|
||||||
it.skip(browserName === 'firefox');
|
|
||||||
|
|
||||||
await page.route('**/empty.html', route => {
|
await page.route('**/empty.html', route => {
|
||||||
route.fulfill({
|
route.fulfill({
|
||||||
body: '<frameset><frame src="frame.html"></frameset>',
|
body: '<frameset><frame src="frame.html"></frameset>',
|
||||||
|
|
@ -156,9 +154,7 @@ it.describe('snapshots', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should capture iframe', async ({ page, server, toImpl, browserName, snapshotter }) => {
|
it('should capture iframe', async ({ page, server, toImpl, snapshotter }) => {
|
||||||
it.skip(browserName === 'firefox');
|
|
||||||
|
|
||||||
await page.route('**/empty.html', route => {
|
await page.route('**/empty.html', route => {
|
||||||
route.fulfill({
|
route.fulfill({
|
||||||
body: '<iframe src="iframe.html"></iframe>',
|
body: '<iframe src="iframe.html"></iframe>',
|
||||||
|
|
@ -183,6 +179,26 @@ it.describe('snapshots', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('should capture iframe with srcdoc', async ({ page, server, toImpl, snapshotter }) => {
|
||||||
|
await page.route('**/empty.html', route => {
|
||||||
|
route.fulfill({
|
||||||
|
body: '<iframe srcdoc="<html><button>Hello iframe</button></html>"></iframe>',
|
||||||
|
contentType: 'text/html'
|
||||||
|
}).catch(() => {});
|
||||||
|
});
|
||||||
|
await page.goto(server.EMPTY_PAGE);
|
||||||
|
|
||||||
|
// Marking iframe hierarchy is racy, do not expect snapshot, wait for it.
|
||||||
|
for (let counter = 0; ; ++counter) {
|
||||||
|
const snapshot = await snapshotter.captureSnapshot(toImpl(page), 'snapshot' + counter);
|
||||||
|
const text = distillSnapshot(snapshot).replace(/frame@[^"]+["]/, '<id>"');
|
||||||
|
if (text === '<IFRAME __playwright_src__=\"/snapshot/<id>\"></IFRAME>')
|
||||||
|
break;
|
||||||
|
await page.waitForTimeout(250);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('should capture snapshot target', async ({ page, toImpl, snapshotter }) => {
|
it('should capture snapshot target', async ({ page, toImpl, snapshotter }) => {
|
||||||
await page.setContent('<button>Hello</button><button>World</button>');
|
await page.setContent('<button>Hello</button><button>World</button>');
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue