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(chromium): do not wait forever for navigations that target another tab/download (#2068)
Dmitry Gozmand7a1e013c696
diff --git a/package-lock.json b/package-lock.jsonindex d46a31549c..27fedbc5a0 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,6 +1,6 @@{"name": "playwright-core",- "version": "0.15.0-post",+ "version": "0.16.0-post","lockfileVersion": 1,"requires": true,"dependencies": {diff --git a/src/chromium/crPage.ts b/src/chromium/crPage.tsindex 47de9e6ebe..871dfa5949 100644--- a/src/chromium/crPage.ts+++ b/src/chromium/crPage.ts@@ -502,7 +502,8 @@ class FrameSession {}_onFrameRequestedNavigation(payload: Protocol.Page.frameRequestedNavigationPayload) {- this._page._frameManager.frameRequestedNavigation(payload.frameId, '');+ if (payload.disposition === 'currentTab')+ this._page._frameManager.frameRequestedNavigation(payload.frameId, '');}_onFrameNavigatedWithinDocument(frameId: string, url: string) {diff --git a/test/browsercontext.spec.js b/test/browsercontext.spec.jsindex 78a264b204..31a526a9c8 100644--- a/test/browsercontext.spec.js+++ b/test/browsercontext.spec.js@@ -651,9 +651,7 @@ describe('Events.BrowserContext.Page', function() {]);await context.close();});- it.fail(CHROMIUM || WEBKIT)('should work with Shift-clicking', async({browser, server}) => {- // Chromium: Shift+Click fires frameRequestedNavigation that never materializes- // because it actually opens a new window.+ it.fail(WEBKIT)('should work with Shift-clicking', async({browser, server}) => {// WebKit: Shift+Click does not open a new window.const context = await browser.newContext();const page = await context.newPage();@@ -663,13 +661,11 @@ describe('Events.BrowserContext.Page', function() {context.waitForEvent('page'),page.click('a', { modifiers: ['Shift'] }),]);- expect(await page.evaluate(() => !!window.opener)).toBe(false);- expect(await popup.evaluate(() => !!window.opener)).toBe(false);+ expect(await popup.opener()).toBe(null);await context.close();});- it.fail(CHROMIUM || WEBKIT)('should work with Ctrl-clicking', async({browser, server}) => {- // Chromium: Ctrl+Click fires frameRequestedNavigation that never materializes- // because it actually opens a new tab.+ it.fail(WEBKIT || FFOX)('should work with Ctrl-clicking', async({browser, server}) => {+ // Firefox: reports an opener in this case.// WebKit: Ctrl+Click does not open a new tab.const context = await browser.newContext();const page = await context.newPage();@@ -679,8 +675,7 @@ describe('Events.BrowserContext.Page', function() {context.waitForEvent('page'),page.click('a', { modifiers: [ MAC ? 'Meta' : 'Control'] }),]);- expect(await page.evaluate(() => !!window.opener)).toBe(false);- expect(await popup.evaluate(() => !!window.opener)).toBe(false);+ expect(await popup.opener()).toBe(null);await context.close();});});diff --git a/test/download.spec.js b/test/download.spec.jsindex bac21e72a3..1daf73ecdf 100644--- a/test/download.spec.js+++ b/test/download.spec.js@@ -96,10 +96,9 @@ describe('Download', function() {expect(fs.readFileSync(path).toString()).toBe('Hello world');await page.close();})- it.skip(FFOX).fail(CHROMIUM || WEBKIT)('should report alt-click downloads', async({browser, server}) => {+ it.skip(FFOX).fail(WEBKIT)('should report alt-click downloads', async({browser, server}) => {// Firefox does not download on alt-click by default.// Our WebKit embedder does not download on alt-click, although Safari does.- // Chromium hangs waiting for navigation because of Page.frameRequestedNavigation.server.setRoute('/download', (req, res) => {res.setHeader('Content-Type', 'application/octet-stream');res.end(`Hello world`);diff --git a/test/popup.spec.js b/test/popup.spec.jsindex a5c3400151..9f798ea060 100644--- a/test/popup.spec.js+++ b/test/popup.spec.js@@ -304,43 +304,6 @@ describe('Page.Events.Popup', function() {expect(await popup.evaluate(() => !!window.opener)).toBe(true);await context.close();});- it.fail(true)('should work with Shift-clicking', async({browser, server}) => {- // Chromium:- // - Shift+Click fires frameRequestedNavigation that never materializes- // because it actually opens a new window.- // - New window does not report an opener.- // WebKit: Shift+Click does not open a new window.- // Firefox: new window does not report an opener.- const context = await browser.newContext();- const page = await context.newPage();- await page.goto(server.EMPTY_PAGE);- await page.setContent('<a href="/one-style.html">yo</a>');- const [popup] = await Promise.all([- page.waitForEvent('popup'),- page.click('a', { modifiers: ['Shift'] }),- ]);- expect(await page.evaluate(() => !!window.opener)).toBe(false);- expect(await popup.evaluate(() => !!window.opener)).toBe(true);- await context.close();- });- it.fail(CHROMIUM || WEBKIT)('should work with Control-clicking', async({browser, server}) => {- // Chromium:- // - Shift+Click fires frameRequestedNavigation that never materializes- // because it actually opens a new tab.- // - New tab does not report an opener.- // WebKit: Shift+Click does not open a new tab.- const context = await browser.newContext();- const page = await context.newPage();- await page.goto(server.EMPTY_PAGE);- await page.setContent('<a href="/one-style.html">yo</a>');- const [popup] = await Promise.all([- page.waitForEvent('popup'),- page.click('a', { modifiers: [MAC ? 'Meta' : 'Control'] }),- ]);- expect(await page.evaluate(() => !!window.opener)).toBe(false);- expect(await popup.evaluate(() => !!window.opener)).toBe(false);- await context.close();- });it('should work with fake-clicking target=_blank and rel=noopener', async({browser, server}) => {const context = await browser.newContext();const page = await context.newPage();