Skip to content
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
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
"devDependencies": {
"@playwright/test": "^0.9.6",
"@playwright/test-runner": "^0.9.14",
"@playwright/test-runner": "^0.9.15",
"@types/debug": "^4.1.5",
"@types/extract-zip": "^1.6.2",
"@types/mime": "^2.0.3",
Expand Down
3 changes: 2 additions & 1 deletion test/browsercontext-basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, verifyViewport } from './playwright.fixtures';
import { it, expect } from './playwright.fixtures';
import { verifyViewport } from './utils';

it('should create new context', async function({browser}) {
expect(browser.contexts().length).toBe(0);
Expand Down
3 changes: 2 additions & 1 deletion test/browsercontext-csp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { it, expect, attachFrame } from './playwright.fixtures';
import { it, expect } from './playwright.fixtures';
import { attachFrame } from './utils';

it('should bypass CSP meta tag', async ({browser, server}) => {
// Make sure CSP prohibits addScriptTag.
Expand Down
3 changes: 2 additions & 1 deletion test/browsercontext-user-agent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { it, expect, attachFrame } from './playwright.fixtures';
import { it, expect } from './playwright.fixtures';
import { attachFrame } from './utils';

it('should work', async ({browser, server}) => {
{
Expand Down
3 changes: 2 additions & 1 deletion test/browsercontext-viewport.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { it, expect, verifyViewport } from './playwright.fixtures';
import { it, expect } from './playwright.fixtures';
import { verifyViewport } from './utils';

it('should get the proper default viewport size', async ({page, server}) => {
await verifyViewport(page, 1280, 720);
Expand Down
11 changes: 9 additions & 2 deletions test/channels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
*/

import domain from 'domain';
import { it, expect, options, playwrightFixtures } from './playwright.fixtures';
import { options, fixtures as baseFixtures } from './playwright.fixtures';
import type { ChromiumBrowser } from '..';

playwrightFixtures.defineWorkerFixture('domain', async ({ }, test) => {
type DomainFixtures = {
domain: any;
};

const fixtures = baseFixtures.declareWorkerFixtures<DomainFixtures>();
fixtures.defineWorkerFixture('domain', async ({ }, test) => {
const local = domain.create();
local.run(() => { });
let err;
Expand All @@ -29,6 +34,8 @@ playwrightFixtures.defineWorkerFixture('domain', async ({ }, test) => {
throw err;
});

const { it, expect } = fixtures;

it('should work', async ({browser}) => {
expect(!!browser['_connection']).toBeTruthy();
});
Expand Down
2 changes: 1 addition & 1 deletion test/chromium/oopif.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { options, playwrightFixtures } from '../playwright.fixtures';
import { options, fixtures as playwrightFixtures } from '../playwright.fixtures';
const { it, expect, describe, overrideWorkerFixture } = playwrightFixtures;

overrideWorkerFixture('browser', async ({browserType, defaultBrowserOptions}, test) => {
Expand Down
3 changes: 1 addition & 2 deletions test/chromium/tracing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { options, playwrightFixtures } from '../playwright.fixtures';
import { options, fixtures as playwrightFixtures } from '../playwright.fixtures';
import fs from 'fs';
import path from 'path';
import type { ChromiumBrowser } from '../..';
Expand All @@ -25,7 +25,6 @@ type TestState = {
const fixtures = playwrightFixtures.declareTestFixtures<TestState>();
const { it, expect, describe, defineTestFixture } = fixtures;


defineTestFixture('outputTraceFile', async ({testOutputDir}, test) => {
await test(path.join(testOutputDir, `trace.json`));
});
Expand Down
3 changes: 2 additions & 1 deletion test/click.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, options, attachFrame } from './playwright.fixtures';
import { it, expect, options } from './playwright.fixtures';
import { attachFrame } from './utils';

async function giveItAChanceToClick(page) {
for (let i = 0; i < 5; i++)
Expand Down
3 changes: 2 additions & 1 deletion test/defaultbrowsercontext-1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, verifyViewport } from './playwright.fixtures';
import { it, expect } from './playwright.fixtures';
import { verifyViewport } from './utils';
import fs from 'fs';

it('context.cookies() should work', async ({server, launchPersistent}) => {
Expand Down
4 changes: 2 additions & 2 deletions test/downloads-path.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { playwrightFixtures } from './playwright.fixtures';
import { fixtures as baseFixtures } from './playwright.fixtures';

import fs from 'fs';
import type { Browser, BrowserContext } from '..';
Expand All @@ -23,7 +23,7 @@ type TestState = {
downloadsBrowser: Browser;
persistentDownloadsContext: BrowserContext;
};
const fixtures = playwrightFixtures.declareTestFixtures<TestState>();
const fixtures = baseFixtures.declareTestFixtures<TestState>();
const { it, expect, defineTestFixture } = fixtures;

defineTestFixture('downloadsBrowser', async ({server, browserType, defaultBrowserOptions, testOutputDir}, test) => {
Expand Down
4 changes: 2 additions & 2 deletions test/electron/electron.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { playwrightFixtures } from '../playwright.fixtures';
import { fixtures as baseFixtures } from '../playwright.fixtures';
import type {ElectronApplication, ElectronLauncher, ElectronPage} from '../../electron-types';
import path from 'path';

Expand All @@ -25,7 +25,7 @@ type TestState = {
window: ElectronPage;
};

export const electronFixtures = playwrightFixtures.declareTestFixtures<TestState>();
export const electronFixtures = baseFixtures.declareTestFixtures<TestState>();
const { defineTestFixture } = electronFixtures;

declare module '../../index' {
Expand Down
3 changes: 2 additions & 1 deletion test/elementhandle-content-frame.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, attachFrame } from './playwright.fixtures';
import { it, expect } from './playwright.fixtures';
import { attachFrame } from './utils';

it('should work', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE);
Expand Down
3 changes: 2 additions & 1 deletion test/elementhandle-owner-frame.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, options, attachFrame } from './playwright.fixtures';
import { it, expect, options } from './playwright.fixtures';
import { attachFrame } from './utils';

it('should work', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE);
Expand Down
3 changes: 2 additions & 1 deletion test/elementhandle-screenshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, describe, options, verifyViewport } from './playwright.fixtures';
import { it, expect, describe, options } from './playwright.fixtures';
import { verifyViewport } from './utils';

import {PNG} from 'pngjs';
import path from 'path';
Expand Down
3 changes: 2 additions & 1 deletion test/emulation-focus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, options, attachFrame } from './playwright.fixtures';
import { it, expect, options } from './playwright.fixtures';
import { attachFrame } from './utils';

it('should think that it is focused by default', async ({page}) => {
expect(await page.evaluate('document.hasFocus()')).toBe(true);
Expand Down
3 changes: 2 additions & 1 deletion test/frame-evaluate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, options, attachFrame, detachFrame } from './playwright.fixtures';
import { it, expect, options } from './playwright.fixtures';
import { attachFrame, detachFrame } from './utils';

import type { Frame } from '../src/client/frame';

Expand Down
3 changes: 2 additions & 1 deletion test/frame-frame-element.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, attachFrame } from './playwright.fixtures';
import { it, expect } from './playwright.fixtures';
import { attachFrame } from './utils';

it('should work', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
Expand Down
3 changes: 2 additions & 1 deletion test/frame-goto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, attachFrame } from './playwright.fixtures';
import { it, expect } from './playwright.fixtures';
import { attachFrame } from './utils';

it('should navigate subframes', async ({page, server}) => {
await page.goto(server.PREFIX + '/frames/one-frame.html');
Expand Down
3 changes: 2 additions & 1 deletion test/frame-hierarchy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, options, attachFrame, detachFrame } from './playwright.fixtures';
import { it, expect, options } from './playwright.fixtures';
import { attachFrame, detachFrame } from './utils';
import type { Frame } from '../index';

function dumpFrames(frame: Frame, indentation: string = ''): string[] {
Expand Down
2 changes: 0 additions & 2 deletions test/http.fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import { fixtures as baseFixtures } from '@playwright/test-runner';
import path from 'path';
import { TestServer } from '../utils/testserver';
export { expect } from '@playwright/test';
export { config } from '@playwright/test-runner';

type HttpWorkerFixtures = {
asset: (path: string) => string;
Expand Down
29 changes: 29 additions & 0 deletions test/impl.fixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright Microsoft Corporation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { fixtures as playwrightFixtures } from './upstream.fixtures';

type ImplWorkerFixtures = {
toImpl: (rpcObject: any) => any;
};

export const fixtures = playwrightFixtures
.declareWorkerFixtures<ImplWorkerFixtures>();
const { defineWorkerFixture } = fixtures;

defineWorkerFixture('toImpl', async ({ playwright }, test) => {
await test((playwright as any)._toImpl);
});
3 changes: 2 additions & 1 deletion test/keyboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, options, attachFrame } from './playwright.fixtures';
import { it, expect, options } from './playwright.fixtures';
import { attachFrame } from './utils';

it('should type into a textarea', async ({page}) => {
await page.evaluate(() => {
Expand Down
3 changes: 2 additions & 1 deletion test/network-request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, options, attachFrame } from './playwright.fixtures';
import { it, expect, options } from './playwright.fixtures';
import { attachFrame } from './utils';

it('should work for main frame navigation request', async ({page, server}) => {
const requests = [];
Expand Down
3 changes: 2 additions & 1 deletion test/page-emulate-media.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, attachFrame } from './playwright.fixtures';
import { it, expect } from './playwright.fixtures';
import { attachFrame } from './utils';

it('should emulate type', async ({page, server}) => {
expect(await page.evaluate(() => matchMedia('screen').matches)).toBe(true);
Expand Down
3 changes: 2 additions & 1 deletion test/page-event-request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, attachFrame } from './playwright.fixtures';
import { it, expect } from './playwright.fixtures';
import { attachFrame } from './utils';

it('should fire for navigation requests', async ({page, server}) => {
const requests = [];
Expand Down
12 changes: 6 additions & 6 deletions test/page-goto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
* limitations under the License.
*/

import { it, expect, options } from './playwright.fixtures';

import path from 'path';
import url from 'url';
import { expect, it, options } from './playwright.fixtures';
import { expectedSSLError } from './utils';

it('should work', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
Expand Down Expand Up @@ -173,23 +173,23 @@ it('should fail when navigating to bad url', async ({page, isChromium, isWebKit}
expect(error.message).toContain('Invalid url');
});

it('should fail when navigating to bad SSL', async ({page, httpsServer, expectedSSLError}) => {
it('should fail when navigating to bad SSL', async ({page, browserName, httpsServer}) => {
// Make sure that network events do not emit 'undefined'.
// @see https://crbug.com/750469
page.on('request', request => expect(request).toBeTruthy());
page.on('requestfinished', request => expect(request).toBeTruthy());
page.on('requestfailed', request => expect(request).toBeTruthy());
let error = null;
await page.goto(httpsServer.EMPTY_PAGE).catch(e => error = e);
expect(error.message).toContain(expectedSSLError);
expect(error.message).toContain(expectedSSLError(browserName));
});

it('should fail when navigating to bad SSL after redirects', async ({page, server, httpsServer, expectedSSLError}) => {
it('should fail when navigating to bad SSL after redirects', async ({page, browserName, server, httpsServer}) => {
server.setRedirect('/redirect/1.html', '/redirect/2.html');
server.setRedirect('/redirect/2.html', '/empty.html');
let error = null;
await page.goto(httpsServer.PREFIX + '/redirect/1.html').catch(e => error = e);
expect(error.message).toContain(expectedSSLError);
expect(error.message).toContain(expectedSSLError(browserName));
});

it('should not crash when navigating to bad SSL after a cross origin navigation', async ({page, server, httpsServer}) => {
Expand Down
3 changes: 2 additions & 1 deletion test/page-screenshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* limitations under the License.
*/

import { it, expect, describe, options, verifyViewport } from './playwright.fixtures';
import { it, expect, describe, options } from './playwright.fixtures';
import { verifyViewport } from './utils';
import path from 'path';
import fs from 'fs';

Expand Down
Loading