fix(infobar): account for infobar in headed mode (#9627)

This commit is contained in:
Pavel Feldman 2021-10-19 14:36:17 -08:00 committed by GitHub
parent 9d03a85c30
commit ba57be99a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 2 deletions

View file

@ -85,6 +85,10 @@ export abstract class BrowserContext extends SdkObject {
this.fetchRequest = new BrowserContextFetchRequest(this);
}
isPersistentContext(): boolean {
return this._isPersistentContext;
}
_setSelectors(selectors: Selectors) {
this._selectors = selectors;
}

View file

@ -974,6 +974,12 @@ class FrameSession {
insets = { width: 8, height: 85 };
else if (process.platform === 'darwin')
insets = { width: 2, height: 80 };
if (this._crPage._browserContext.isPersistentContext()) {
// FIXME: Chrome bug: OOPIF router is confused when hit target is
// outside browser window.
// Account for the infobar here to work around the bug.
insets.height += 46;
}
}
promises.push(this.setWindowBounds({
width: viewportSize.width + insets.width,

View file

@ -185,8 +185,10 @@ function snapshotScript() {
iframe.setAttribute('src', 'data:text/html,<body style="background: #ddd"></body>');
} else {
// Append query parameters to inherit ?name= or ?time= values from parent.
const url = new URL('/trace' + src + window.location.search, window.location.href).toString();
iframe.setAttribute('src', url);
const url = new URL('/trace' + src + window.location.search, window.location.href);
url.searchParams.delete('pointX');
url.searchParams.delete('pointY');
iframe.setAttribute('src', url.toString());
}
}

View file

@ -183,3 +183,57 @@ it('Page.bringToFront should work', async ({ browserType, browserOptions }) => {
await browser.close();
});
it('should click in OOPIF', async ({ browserName, browserType, browserOptions, createUserDataDir, server }) => {
it.fixme(browserName === 'chromium');
server.setRoute('/empty.html', (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(`<iframe src="${server.CROSS_PROCESS_PREFIX}/iframe.html"></iframe>`);
});
server.setRoute('/iframe.html', (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(`<button id="button" onclick="console.log('ok')">Submit</button>
<script>console.log('frame loaded')</script>`);
});
const context = await browserType.launchPersistentContext(await createUserDataDir(), { ...browserOptions, headless: false });
const [page] = context.pages();
const consoleLog: string[] = [];
page.on('console', m => consoleLog.push(m.text()));
await page.goto(server.EMPTY_PAGE);
await page.frames()[1].click('text=Submit');
expect(consoleLog).toContain('ok');
});
it('should click bottom row w/ infobar in OOPIF', async ({ browserType, browserOptions, createUserDataDir, server }) => {
server.setRoute('/empty.html', (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(`
<style>
html, body { margin: 0; padding: 0; width: 100%; height: 100%; }
iframe { position: absolute; bottom: 0; }
</style>
<iframe src="${server.CROSS_PROCESS_PREFIX}/iframe.html"></iframe>
`);
});
server.setRoute('/iframe.html', (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(`
<style>
html, body { margin: 0; padding: 0; width: 100%; height: 100%; }
button { position: absolute; bottom: 0; }
</style>
<button id="button" onclick="console.log('ok')">Submit</button>`);
});
const browserContext = await browserType.launchPersistentContext(await createUserDataDir(), { ...browserOptions, headless: false });
const [page] = browserContext.pages();
await page.goto(server.EMPTY_PAGE);
// Chrome bug! Investigate what's happening in the oopif router.
const consoleLog: string[] = [];
page.on('console', m => consoleLog.push(m.text()));
while (!consoleLog.includes('ok')) {
await page.waitForTimeout(100);
await page.frames()[1].click('text=Submit');
}
});