Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(infobar): account for infobar in headed mode (#9627)
Pavel Feldmanba57be99a95f
diff --git a/packages/playwright-core/src/server/browserContext.ts b/packages/playwright-core/src/server/browserContext.tsindex 4d79171760..ff2729a9da 100644--- a/packages/playwright-core/src/server/browserContext.ts+++ b/packages/playwright-core/src/server/browserContext.ts@@ -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;}diff --git a/packages/playwright-core/src/server/chromium/crPage.ts b/packages/playwright-core/src/server/chromium/crPage.tsindex b03a6fa290..568b8d350c 100644--- a/packages/playwright-core/src/server/chromium/crPage.ts+++ b/packages/playwright-core/src/server/chromium/crPage.ts@@ -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,diff --git a/packages/playwright-core/src/web/traceViewer/snapshotRenderer.ts b/packages/playwright-core/src/web/traceViewer/snapshotRenderer.tsindex 3f69842bdf..0803f9a1a9 100644--- a/packages/playwright-core/src/web/traceViewer/snapshotRenderer.ts+++ b/packages/playwright-core/src/web/traceViewer/snapshotRenderer.ts@@ -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());}}diff --git a/tests/headful.spec.ts b/tests/headful.spec.tsindex 9a04d98d34..fdd19505bd 100644--- a/tests/headful.spec.ts+++ b/tests/headful.spec.ts@@ -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');+ }+});