Skip to content

Commit 8c6c571

Browse files
authored
test: add iframe screenshot tests (#2495)
1 parent 9aa9d6b commit 8c6c571

File tree

7 files changed

+23
-3
lines changed

7 files changed

+23
-3
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<style>
2+
body, html {
3+
margin: 0;
4+
}
5+
</style>
6+
<script>
7+
window.addEventListener('DOMContentLoaded', () => {
8+
const container = document.createElement('div');
9+
document.body.appendChild(container);
10+
const shadow = container.attachShadow({mode: 'open'});
11+
const iframe = document.createElement('iframe');
12+
iframe.src = './grid.html';
13+
iframe.style.cssText = 'width: 300px; height: 300px; margin: 0; padding: 0; border: 0;';
14+
shadow.appendChild(iframe);
15+
});
16+
</script>

test/chromium/oopif.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,12 @@ describe('OOPIF', function() {
150150
expect(await countOOPIFs(browser)).toBe(1);
151151
expect(intercepted).toBe(true);
152152
});
153-
it.fail(CHROMIUM)('should take screenshot', async({browser, page, server}) => {
154-
// Screenshot differs on the bots, needs debugging.
153+
it('should take screenshot', async({browser, page, server, golden}) => {
155154
await page.setViewportSize({width: 500, height: 500});
156155
await page.goto(server.PREFIX + '/dynamic-oopif.html');
157156
expect(page.frames().length).toBe(2);
158157
expect(await countOOPIFs(browser)).toBe(1);
159-
expect(await page.screenshot()).toBeGolden('screenshot-iframe.png');
158+
expect(await page.screenshot()).toBeGolden(golden('screenshot-oopif.png'));
160159
});
161160
it('should load oopif iframes with subresources and request interception', async function({browser, page, server, context}) {
162161
await page.route('**/*', route => route.continue());
-8.58 KB
Loading
13.8 KB
Loading
11.4 KB
Loading
17.9 KB
Loading

test/screenshot.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ describe.skip(ffheadful)('Page.screenshot', function() {
223223
expect(screenshot).toBeGolden(golden('screenshot-device-scale-factor.png'));
224224
await context.close();
225225
});
226+
it('should work with iframe in shadow', async({browser, page, server, golden}) => {
227+
await page.setViewportSize({width: 500, height: 500});
228+
await page.goto(server.PREFIX + '/grid-iframe-in-shadow.html');
229+
expect(await page.screenshot()).toBeGolden(golden('screenshot-iframe.png'));
230+
});
226231
});
227232

228233
describe.skip(ffheadful)('ElementHandle.screenshot', function() {

0 commit comments

Comments
 (0)