Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add failing popup tests #1849

Merged
merged 1 commit into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion test/browsercontext.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand Down Expand Up @@ -651,4 +651,36 @@ describe('Events.BrowserContext.Page', function() {
]);
await context.close();
});
it.fail(CHROMIUM || WEBKIT)('should work with Shift-clicking', async({browser, server}) => {
dgozman marked this conversation as resolved.
Show resolved Hide resolved
// 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();
});
});
39 changes: 38 additions & 1 deletion test/popup.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}) {
Expand Down Expand Up @@ -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.
dgozman marked this conversation as resolved.
Show resolved Hide resolved
// 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();
Expand Down