Skip to content

Commit

Permalink
test: make platform a parameter (#3910)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Sep 17, 2020
1 parent dc06f0a commit 9662930
Show file tree
Hide file tree
Showing 24 changed files with 75 additions and 59 deletions.
4 changes: 2 additions & 2 deletions test/browsercontext-cookies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ it('should properly report httpOnly cookie', async ({context, page, server}) =>
});

it('should properly report "Strict" sameSite cookie', (test, parameters) => {
test.fail(options.WEBKIT(parameters) && WIN);
test.fail(options.WEBKIT(parameters) && options.WIN(parameters));
}, async ({context, page, server}) => {
server.setRoute('/empty.html', (req, res) => {
res.setHeader('Set-Cookie', 'name=value;SameSite=Strict');
Expand All @@ -87,7 +87,7 @@ it('should properly report "Strict" sameSite cookie', (test, parameters) => {
});

it('should properly report "Lax" sameSite cookie', (test, parameters) => {
test.fail(options.WEBKIT(parameters) && WIN);
test.fail(options.WEBKIT(parameters) && options.WIN(parameters));
}, async ({context, page, server}) => {
server.setRoute('/empty.html', (req, res) => {
res.setHeader('Set-Cookie', 'name=value;SameSite=Lax');
Expand Down
4 changes: 2 additions & 2 deletions test/browsercontext-page-event.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ it('should work with Shift-clicking', (test, parameters) => {
it('should work with Ctrl-clicking', (test, parameters) => {
test.fixme(options.WEBKIT(parameters), 'Ctrl+Click does not open a new tab.');
test.fixme(options.FIREFOX(parameters), 'Reports an opener in this case.');
}, async ({browser, server}) => {
}, async ({browser, server, isMac}) => {
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'] }),
page.click('a', { modifiers: [ isMac ? 'Meta' : 'Control'] }),
]);
expect(await popup.opener()).toBe(null);
await context.close();
Expand Down
4 changes: 2 additions & 2 deletions test/capabilities.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import url from 'url';
import { it, expect, options } from './playwright.fixtures';

it('Web Assembly should work', (test, parameters) => {
test.fail(options.WEBKIT(parameters) && WIN);
test.fail(options.WEBKIT(parameters) && options.WIN(parameters));
}, async function({page, server}) {
await page.goto(server.PREFIX + '/wasm/table2.html');
expect(await page.evaluate('loadTable()')).toBe('42, 83');
Expand Down Expand Up @@ -51,7 +51,7 @@ it('should respect CSP', async ({page, server}) => {
});

it('should play video', (test, parameters) => {
test.fixme(options.WEBKIT(parameters) && (WIN || LINUX));
test.fixme(options.WEBKIT(parameters) && (options.WIN(parameters) || options.LINUX(parameters)));
}, async ({page, asset, isWebKit}) => {
// TODO: the test passes on Windows locally but fails on GitHub Action bot,
// apparently due to a Media Pack issue in the Windows Server.
Expand Down
2 changes: 1 addition & 1 deletion test/chromium/launcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ it('should not throw with remote-debugging-port argument', (test, parameters) =>
});

it('should open devtools when "devtools: true" option is given', (test, parameters) => {
test.skip(!options.CHROMIUM(parameters) || options.WIRE || WIN);
test.skip(!options.CHROMIUM(parameters) || options.WIRE || options.WIN(parameters));
}, async ({browserType, defaultBrowserOptions}) => {
let devtoolsCallback;
const devtoolsPromise = new Promise(f => devtoolsCallback = f);
Expand Down
2 changes: 1 addition & 1 deletion test/defaultbrowsercontext-2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ it('should support ignoreHTTPSErrors option', async ({httpsServer, launchPersist
});

it('should support extraHTTPHeaders option', (test, parameters) => {
test.flaky(options.FIREFOX(parameters) && !options.HEADLESS && LINUX, 'Intermittent timeout on bots');
test.flaky(options.FIREFOX(parameters) && !options.HEADLESS && options.LINUX(parameters), 'Intermittent timeout on bots');
}, async ({server, launchPersistent}) => {
const {page} = await launchPersistent({extraHTTPHeaders: { foo: 'bar' }});
const [request] = await Promise.all([
Expand Down
2 changes: 1 addition & 1 deletion test/dialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ it('should dismiss the confirm prompt', async ({page}) => {
});

it('should be able to close context with open alert', (test, parameters) => {
test.fixme(options.WEBKIT(parameters) && MAC);
test.fixme(options.WEBKIT(parameters) && options.MAC(parameters));
}, async ({browser}) => {
const context = await browser.newContext();
const page = await context.newPage();
Expand Down
2 changes: 1 addition & 1 deletion test/elementhandle-owner-frame.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ it('should work for cross-process iframes', async ({ page, server }) => {
});

it('should work for document', (test, parameters) => {
test.flaky(WIN && options.WEBKIT(parameters));
test.flaky(options.WIN(parameters) && options.WEBKIT(parameters));
}, async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE);
await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE);
Expand Down
2 changes: 1 addition & 1 deletion test/elementhandle-screenshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ describe('element screenshot', (suite, parameters) => {
});

it('should wait for element to stop moving', (test, parameters) => {
test.flaky(options.WEBKIT(parameters) && !options.HEADLESS && LINUX);
test.flaky(options.WEBKIT(parameters) && !options.HEADLESS && options.LINUX(parameters));
}, async ({ page, server, golden }) => {
await page.setViewportSize({ width: 500, height: 500 });
await page.goto(server.PREFIX + '/grid.html');
Expand Down
2 changes: 1 addition & 1 deletion test/elementhandle-wait-for-element-state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ it('should wait for disabled button', async ({page}) => {
});

it('should wait for stable position', (test, parameters) => {
test.fixme(options.FIREFOX(parameters) && LINUX);
test.fixme(options.FIREFOX(parameters) && options.LINUX(parameters));
}, async ({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
const button = await page.$('button');
Expand Down
12 changes: 6 additions & 6 deletions test/fixtures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ defineTestFixture('stallingConnectedRemoteServer', async ({browserType, stalling
await browser.close();
});

it('should close the browser when the node process closes', (test, parameters) => {
it('should close the browser when the node process closes', test => {
test.slow();
}, async ({connectedRemoteServer}) => {
if (WIN)
}, async ({connectedRemoteServer, isWindows}) => {
if (isWindows)
execSync(`taskkill /pid ${connectedRemoteServer.child().pid} /T /F`);
else
process.kill(connectedRemoteServer.child().pid);
expect(await connectedRemoteServer.childExitCode()).toBe(WIN ? 1 : 0);
expect(await connectedRemoteServer.childExitCode()).toBe(isWindows ? 1 : 0);
// We might not get browser exitCode in time when killing the parent node process,
// so we don't check it here.
});

describe('fixtures', suite => {
suite.skip(WIN || !options.HEADLESS);
describe('fixtures', (suite, parameters) => {
suite.skip(options.WIN(parameters) || !options.HEADLESS);
suite.slow();
}, () => {
// Cannot reliably send signals on Windows.
Expand Down
2 changes: 1 addition & 1 deletion test/focus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ it('should traverse focus in all directions', async function({page}) {
});

it('should traverse only form elements', (test, parameters) => {
test.skip(!MAC || !options.WEBKIT(parameters),
test.skip(!options.MAC(parameters) || !options.WEBKIT(parameters),
'Chromium and WebKit both have settings for tab traversing all links, but it is only on by default in WebKit.');
}, async function({page}) {
await page.setContent(`
Expand Down
2 changes: 1 addition & 1 deletion test/headful.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ it('should have default url when launching browser', async ({browserType, defaul
});

it('headless should be able to read cookies written by headful', (test, parameters) => {
test.fail(WIN && options.CHROMIUM(parameters));
test.fail(options.WIN(parameters) && options.CHROMIUM(parameters));
test.flaky(options.FIREFOX(parameters));
test.slow();
}, async ({browserType, defaultBrowserOptions, server}) => {
Expand Down
18 changes: 9 additions & 9 deletions test/keyboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ it('insertText should only emit input event', async ({page, server}) => {
});

it('should report shiftKey', (test, parameters) => {
test.fail(options.FIREFOX(parameters) && MAC);
test.fail(options.FIREFOX(parameters) && options.MAC(parameters));
}, async ({page, server}) => {
await page.goto(server.PREFIX + '/input/keyboard.html');
const keyboard = page.keyboard;
Expand Down Expand Up @@ -312,19 +312,19 @@ it('should type emoji into an iframe', async ({page, server}) => {
expect(await frame.$eval('textarea', textarea => textarea.value)).toBe('👹 Tokyo street Japan 🇯🇵');
});

it('should handle selectAll', async ({page, server}) => {
it('should handle selectAll', async ({page, server, isMac}) => {
await page.goto(server.PREFIX + '/input/textarea.html');
const textarea = await page.$('textarea');
await textarea.type('some text');
const modifier = MAC ? 'Meta' : 'Control';
const modifier = isMac ? 'Meta' : 'Control';
await page.keyboard.down(modifier);
await page.keyboard.press('a');
await page.keyboard.up(modifier);
await page.keyboard.press('Backspace');
expect(await page.$eval('textarea', textarea => textarea.value)).toBe('');
});

it('should be able to prevent selectAll', async ({page, server}) => {
it('should be able to prevent selectAll', async ({page, server, isMac}) => {
await page.goto(server.PREFIX + '/input/textarea.html');
const textarea = await page.$('textarea');
await textarea.type('some text');
Expand All @@ -334,7 +334,7 @@ it('should be able to prevent selectAll', async ({page, server}) => {
event.preventDefault();
}, false);
});
const modifier = MAC ? 'Meta' : 'Control';
const modifier = isMac ? 'Meta' : 'Control';
await page.keyboard.down(modifier);
await page.keyboard.press('a');
await page.keyboard.up(modifier);
Expand All @@ -343,7 +343,7 @@ it('should be able to prevent selectAll', async ({page, server}) => {
});

it('should support MacOS shortcuts', (test, parameters) => {
test.skip(!MAC);
test.skip(!options.MAC(parameters));
}, async ({page, server}) => {
await page.goto(server.PREFIX + '/input/textarea.html');
const textarea = await page.$('textarea');
Expand All @@ -354,11 +354,11 @@ it('should support MacOS shortcuts', (test, parameters) => {
expect(await page.$eval('textarea', textarea => textarea.value)).toBe('some ');
});

it('should press the meta key', async ({page, isFirefox}) => {
it('should press the meta key', async ({page, isFirefox, isMac}) => {
const lastEvent = await captureLastKeydown(page);
await page.keyboard.press('Meta');
const {key, code, metaKey} = await lastEvent.jsonValue();
if (isFirefox && !MAC)
if (isFirefox && !isMac)
expect(key).toBe('OS');
else
expect(key).toBe('Meta');
Expand All @@ -368,7 +368,7 @@ it('should press the meta key', async ({page, isFirefox}) => {
else
expect(code).toBe('MetaLeft');

if (isFirefox && !MAC)
if (isFirefox && !isMac)
expect(metaKey).toBe(false);
else
expect(metaKey).toBe(true);
Expand Down
6 changes: 3 additions & 3 deletions test/mouse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function dimensions() {
}

it('should click the document', (test, parameters) => {
test.flaky(options.FIREFOX(parameters) && WIN, 'Occasionally times out on options.FIREFOX on Windows: https://github.com/microsoft/playwright/pull/1911/checks?check_run_id=607149016');
test.flaky(options.FIREFOX(parameters) && options.WIN(parameters), 'Occasionally times out on options.FIREFOX on Windows: https://github.com/microsoft/playwright/pull/1911/checks?check_run_id=607149016');
}, async ({page, server}) => {
await page.evaluate(() => {
window['clickPromise'] = new Promise(resolve => {
Expand Down Expand Up @@ -123,12 +123,12 @@ it('should trigger hover state with removed window.Node', async ({page, server})
expect(await page.evaluate(() => document.querySelector('button:hover').id)).toBe('button-6');
});

it('should set modifier keys on click', async ({page, server, isFirefox}) => {
it('should set modifier keys on click', async ({page, server, isFirefox, isMac}) => {
await page.goto(server.PREFIX + '/input/scrollable.html');
await page.evaluate(() => document.querySelector('#button-3').addEventListener('mousedown', e => window['lastEvent'] = e, true));
const modifiers = {'Shift': 'shiftKey', 'Control': 'ctrlKey', 'Alt': 'altKey', 'Meta': 'metaKey'};
// In Firefox, the Meta modifier only exists on Mac
if (isFirefox && !MAC)
if (isFirefox && !isMac)
delete modifiers['Meta'];
for (const modifier in modifiers) {
await page.keyboard.down(modifier);
Expand Down
2 changes: 1 addition & 1 deletion test/network-request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ it('should return headers', async ({page, server, isChromium, isFirefox, isWebKi
});

it('should get the same headers as the server', (test, parameters) => {
test.fail(options.CHROMIUM(parameters) || options.WEBKIT(parameters));
test.fail(options.CHROMIUM(parameters) || options.WEBKIT(parameters), 'Provisional headers differ from those in network stack');
}, async ({page, server}) => {
await page.goto(server.PREFIX + '/empty.html');
let serverRequest;
Expand Down
4 changes: 2 additions & 2 deletions test/page-event-crash.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function crash(page, toImpl, browserName) {

describe('', (suite, parameters) => {
suite.fixme(options.WIRE);
suite.flaky(options.FIREFOX(parameters) && WIN);
suite.flaky(options.FIREFOX(parameters) && options.WIN(parameters));
}, () => {
it('should emit crash event when page crashes', async ({page, browserName, toImpl}) => {
await page.setContent(`<div>This page should crash</div>`);
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('', (suite, parameters) => {

it('should be able to close context when page crashes', (test, parameters) => {
test.fixme(options.WIRE);
test.flaky(options.FIREFOX(parameters) && WIN);
test.flaky(options.FIREFOX(parameters) && options.WIN(parameters));
}, async ({page, browserName, toImpl}) => {
await page.setContent(`<div>This page should crash</div>`);
crash(page, toImpl, browserName);
Expand Down
6 changes: 3 additions & 3 deletions test/page-event-network.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ it('Page.Events.Response', async ({page, server}) => {
expect(responses[0].request()).toBeTruthy();
});

it('Page.Events.RequestFailed', async ({page, server, isChromium, isWebKit}) => {
it('Page.Events.RequestFailed', async ({page, server, isChromium, isWebKit, isMac, isWindows}) => {
server.setRoute('/one-style.css', (req, res) => {
res.setHeader('Content-Type', 'text/css');
res.connection.destroy();
Expand All @@ -56,9 +56,9 @@ it('Page.Events.RequestFailed', async ({page, server, isChromium, isWebKit}) =>
if (isChromium) {
expect(failedRequests[0].failure().errorText).toBe('net::ERR_EMPTY_RESPONSE');
} else if (isWebKit) {
if (MAC)
if (isMac)
expect(failedRequests[0].failure().errorText).toBe('The network connection was lost.');
else if (WIN)
else if (isWindows)
expect(failedRequests[0].failure().errorText).toBe('Server returned nothing (no headers, no data)');
else
expect(failedRequests[0].failure().errorText).toBe('Message Corrupt');
Expand Down
4 changes: 2 additions & 2 deletions test/page-goto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ it('should throw if networkidle2 is passed as an option', async ({page, server})
expect(error.message).toContain(`waitUntil: expected one of (load|domcontentloaded|networkidle)`);
});

it('should fail when main resources failed to load', async ({page, isChromium, isWebKit}) => {
it('should fail when main resources failed to load', async ({page, isChromium, isWebKit, isWindows}) => {
let error = null;
await page.goto('http://localhost:44123/non-existing-url').catch(e => error = e);
if (isChromium)
expect(error.message).toContain('net::ERR_CONNECTION_REFUSED');
else if (isWebKit && WIN)
else if (isWebKit && isWindows)
expect(error.message).toContain(`Couldn\'t connect to server`);
else if (isWebKit)
expect(error.message).toContain('Could not connect');
Expand Down
2 changes: 1 addition & 1 deletion test/page-history.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ it('page.goBack should work with HistoryAPI', async ({page, server}) => {
});

it('page.goBack should work for file urls', (test, parameters) => {
test.fail(options.WEBKIT(parameters) && MAC);
test.fail(options.WEBKIT(parameters) && options.MAC(parameters));
}, async ({page, server, asset}) => {
// WebKit embedder fails to go back/forward to the file url.
const url1 = url.pathToFileURL(asset('empty.html')).href;
Expand Down
2 changes: 1 addition & 1 deletion test/page-screenshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ describe('page screenshot', (suite, parameters) => {

it('should work for webgl', (test, parameters) => {
test.fixme(options.FIREFOX(parameters));
test.fixme(options.WEBKIT(parameters) && LINUX);
test.fixme(options.WEBKIT(parameters) && options.LINUX(parameters));
}, async ({page, server, golden}) => {
await page.setViewportSize({width: 640, height: 480});
await page.goto(server.PREFIX + '/screenshots/webgl.html');
Expand Down
2 changes: 1 addition & 1 deletion test/permissions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('permissions', (suite, parameters) => {
it('should trigger permission onchange', (test, parameters) => {
test.fail(options.WEBKIT(parameters));
test.fail(options.CHROMIUM(parameters) && !options.HEADLESS);
test.flaky(options.FIREFOX(parameters) && LINUX);
test.flaky(options.FIREFOX(parameters) && options.LINUX(parameters));
}, async ({page, server, context}) => {
// TODO: flaky
// - Linux: https://github.com/microsoft/playwright/pull/1790/checks?check_run_id=587327883
Expand Down
Loading

0 comments on commit 9662930

Please sign in to comment.