test: add iframe screenshot tests (#2495)

This commit is contained in:
Dmitry Gozman 2020-06-09 12:59:49 -07:00 committed by GitHub
parent 9aa9d6bc1d
commit 8c6c571f22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 3 deletions

View File

@ -0,0 +1,16 @@
<style>
body, html {
margin: 0;
}
</style>
<script>
window.addEventListener('DOMContentLoaded', () => {
const container = document.createElement('div');
document.body.appendChild(container);
const shadow = container.attachShadow({mode: 'open'});
const iframe = document.createElement('iframe');
iframe.src = './grid.html';
iframe.style.cssText = 'width: 300px; height: 300px; margin: 0; padding: 0; border: 0;';
shadow.appendChild(iframe);
});
</script>

View File

@ -150,13 +150,12 @@ describe('OOPIF', function() {
expect(await countOOPIFs(browser)).toBe(1);
expect(intercepted).toBe(true);
});
it.fail(CHROMIUM)('should take screenshot', async({browser, page, server}) => {
// Screenshot differs on the bots, needs debugging.
it('should take screenshot', async({browser, page, server, golden}) => {
await page.setViewportSize({width: 500, height: 500});
await page.goto(server.PREFIX + '/dynamic-oopif.html');
expect(page.frames().length).toBe(2);
expect(await countOOPIFs(browser)).toBe(1);
expect(await page.screenshot()).toBeGolden('screenshot-iframe.png');
expect(await page.screenshot()).toBeGolden(golden('screenshot-oopif.png'));
});
it('should load oopif iframes with subresources and request interception', async function({browser, page, server, context}) {
await page.route('**/*', route => route.continue());

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -223,6 +223,11 @@ describe.skip(ffheadful)('Page.screenshot', function() {
expect(screenshot).toBeGolden(golden('screenshot-device-scale-factor.png'));
await context.close();
});
it('should work with iframe in shadow', async({browser, page, server, golden}) => {
await page.setViewportSize({width: 500, height: 500});
await page.goto(server.PREFIX + '/grid-iframe-in-shadow.html');
expect(await page.screenshot()).toBeGolden(golden('screenshot-iframe.png'));
});
});
describe.skip(ffheadful)('ElementHandle.screenshot', function() {