Skip to content

Commit 0cff9df

Browse files
authored
test: add failing test for clicking and oopifs (#1325)
1 parent 0077b42 commit 0cff9df

File tree

2 files changed

+61
-18
lines changed

2 files changed

+61
-18
lines changed

test/assets/button-overlay-oopif.html

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<style>
2+
* {
3+
padding: 0;
4+
margin: 0;
5+
}
6+
7+
iframe {
8+
position: absolute;
9+
top: 0;
10+
left: 0;
11+
width: 500px;
12+
height: 500px;
13+
}
14+
15+
button {
16+
position: absolute;
17+
top: 150px;
18+
left: 150px;
19+
width: 200px;
20+
height: 200px;
21+
}
22+
</style>
23+
<script>
24+
window.addEventListener('DOMContentLoaded', () => {
25+
const iframe = document.createElement('iframe');
26+
const url = new URL(location.href);
27+
url.hostname = url.hostname === 'localhost' ? '127.0.0.1' : 'localhost';
28+
url.pathname = '/grid.html';
29+
iframe.src = url.toString();
30+
document.body.append(iframe);
31+
32+
const button = document.createElement('button');
33+
button.textContent = 'CLICK ME';
34+
button.addEventListener('click', () => {
35+
window.BUTTON_CLICKED = true;
36+
}, false);
37+
document.body.append(button);
38+
}, false);
39+
</script>

test/chromium/oopif.spec.js

+22-18
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,21 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
4646
state.browser = null;
4747
});
4848
it.fail(true)('should report oopif frames', async function({browser, page, server, context}) {
49-
const browserSession = await browser.createBrowserSession();
50-
await browserSession.send('Target.setDiscoverTargets', { discover: true });
51-
const oopifs = [];
52-
browserSession.on('Target.targetCreated', async ({targetInfo}) => {
53-
if (targetInfo.type === 'iframe')
54-
oopifs.push(targetInfo);
55-
});
5649
await page.goto(server.PREFIX + '/dynamic-oopif.html');
57-
expect(oopifs.length).toBe(1);
50+
expect(await countOOPIFs(browser)).toBe(1);
5851
expect(page.frames().length).toBe(2);
5952
});
6053
it('should load oopif iframes with subresources and request interception', async function({browser, page, server, context}) {
6154
await page.route('**/*', request => request.continue());
62-
const browserSession = await browser.createBrowserSession();
63-
await browserSession.send('Target.setDiscoverTargets', { discover: true });
64-
const oopifs = [];
65-
browserSession.on('Target.targetCreated', async ({targetInfo}) => {
66-
if (targetInfo.type === 'iframe')
67-
oopifs.push(targetInfo);
68-
});
6955
await page.goto(server.PREFIX + '/dynamic-oopif.html');
70-
expect(oopifs.length).toBe(1);
71-
await browserSession.detach();
56+
expect(await countOOPIFs(browser)).toBe(1);
57+
});
58+
// @see https://github.com/microsoft/playwright/issues/1240
59+
xit('should click a button when it overlays oopif', async function({browser, page, server, context}) {
60+
await page.goto(server.PREFIX + '/button-overlay-oopif.html');
61+
expect(await countOOPIFs(browser)).toBe(1);
62+
await page.click('button');
63+
expect(await page.evaluate(() => window.BUTTON_CLICKED)).toBe(true);
7264
});
7365
it.fail(true)('should report google.com frame with headful', async({server}) => {
7466
// TODO: Support OOOPIF. @see https://github.com/GoogleChrome/puppeteer/issues/2548
@@ -94,4 +86,16 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
9486
await browser.close();
9587
});
9688
});
97-
};
89+
};
90+
91+
async function countOOPIFs(browser) {
92+
const browserSession = await browser.createBrowserSession();
93+
const oopifs = [];
94+
browserSession.on('Target.targetCreated', async ({targetInfo}) => {
95+
if (targetInfo.type === 'iframe')
96+
oopifs.push(targetInfo);
97+
});
98+
await browserSession.send('Target.setDiscoverTargets', { discover: true });
99+
await browserSession.detach();
100+
return oopifs.length;
101+
}

0 commit comments

Comments
 (0)