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
test: add failing popup tests (#1849)
Dmitry Gozmancf415bb45ab4
diff --git a/test/browsercontext.spec.js b/test/browsercontext.spec.jsindex 0ffcfc6ab1..78a264b204 100644--- a/test/browsercontext.spec.js+++ b/test/browsercontext.spec.js@@ -16,7 +16,7 @@*/const utils = require('./utils');-const {FFOX, CHROMIUM, WEBKIT} = utils.testOptions(browserType);+const {FFOX, CHROMIUM, WEBKIT, MAC} = utils.testOptions(browserType);describe('BrowserContext', function() {it('should create new context', async function({browser}) {@@ -651,4 +651,36 @@ 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.+ // WebKit: Shift+Click does not open a new window.+ 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([+ context.waitForEvent('page'),+ page.click('a', { modifiers: ['Shift'] }),+ ]);+ expect(await page.evaluate(() => !!window.opener)).toBe(false);+ expect(await popup.evaluate(() => !!window.opener)).toBe(false);+ 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.+ // WebKit: Ctrl+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([+ 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);+ await context.close();+ });});diff --git a/test/popup.spec.js b/test/popup.spec.jsindex e75813dc32..ab5f4e3af0 100644--- a/test/popup.spec.js+++ b/test/popup.spec.js@@ -14,7 +14,7 @@* limitations under the License.*/-const {FFOX, CHROMIUM, WEBKIT} = require('./utils').testOptions(browserType);+const {FFOX, CHROMIUM, WEBKIT, MAC} = require('./utils').testOptions(browserType);describe('Link navigation', function() {it('should inherit user agent from browser context', async function({browser, server}) {@@ -304,6 +304,43 @@ 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();