From 850436c656fc749a6bb27a50a04507b004b1a34a Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Thu, 22 Aug 2024 17:29:10 +0200 Subject: [PATCH 1/6] chore(ui): move TeleSuiteUpdater into testIsomorphic (#32273) Preparation for https://github.com/microsoft/playwright/issues/32076. --- .../src/isomorphic}/teleSuiteUpdater.ts | 45 ++++++++++++------- .../trace-viewer/src/ui/uiModeFiltersView.tsx | 4 +- packages/trace-viewer/src/ui/uiModeModel.ts | 33 -------------- .../src/ui/uiModeTestListView.tsx | 6 +-- packages/trace-viewer/src/ui/uiModeView.tsx | 11 +++-- 5 files changed, 39 insertions(+), 60 deletions(-) rename packages/{trace-viewer/src/ui => playwright/src/isomorphic}/teleSuiteUpdater.ts (84%) delete mode 100644 packages/trace-viewer/src/ui/uiModeModel.ts diff --git a/packages/trace-viewer/src/ui/teleSuiteUpdater.ts b/packages/playwright/src/isomorphic/teleSuiteUpdater.ts similarity index 84% rename from packages/trace-viewer/src/ui/teleSuiteUpdater.ts rename to packages/playwright/src/isomorphic/teleSuiteUpdater.ts index 0d448ea172..ef1c2dbb3e 100644 --- a/packages/trace-viewer/src/ui/teleSuiteUpdater.ts +++ b/packages/playwright/src/isomorphic/teleSuiteUpdater.ts @@ -14,11 +14,24 @@ * limitations under the License. */ -import { TeleReporterReceiver, TeleSuite } from '@testIsomorphic/teleReceiver'; -import { statusEx } from '@testIsomorphic/testTree'; -import type { ReporterV2 } from 'playwright/src/reporters/reporterV2'; -import type * as reporterTypes from 'playwright/types/testReporter'; -import type { Progress, TestModel } from './uiModeModel'; +import { TeleReporterReceiver, TeleSuite } from './teleReceiver'; +import { statusEx } from './testTree'; +import type { ReporterV2 } from '../reporters/reporterV2'; +import type * as reporterTypes from '../../types/testReporter'; + +export type TeleSuiteUpdaterProgress = { + total: number; + passed: number; + failed: number; + skipped: number; +}; + +export type TeleSuiteUpdaterTestModel = { + config: reporterTypes.FullConfig; + rootSuite: reporterTypes.Suite; + loadErrors: reporterTypes.TestError[]; + progress: TeleSuiteUpdaterProgress; +}; export type TeleSuiteUpdaterOptions = { onUpdate: (force?: boolean) => void, @@ -30,7 +43,7 @@ export class TeleSuiteUpdater { rootSuite: TeleSuite | undefined; config: reporterTypes.FullConfig | undefined; readonly loadErrors: reporterTypes.TestError[] = []; - readonly progress: Progress = { + readonly progress: TeleSuiteUpdaterProgress = { total: 0, passed: 0, failed: 0, @@ -118,11 +131,11 @@ export class TeleSuiteUpdater { return false; }, - onStdOut: () => {}, - onStdErr: () => {}, - onExit: () => {}, - onStepBegin: () => {}, - onStepEnd: () => {}, + onStdOut: () => { }, + onStdErr: () => { }, + onExit: () => { }, + onStepBegin: () => { }, + onStepEnd: () => { }, }; } @@ -134,7 +147,7 @@ export class TeleSuiteUpdater { onError: (error: reporterTypes.TestError) => this._handleOnError(error) }); for (const message of report) - receiver.dispatch(message); + void receiver.dispatch(message); } processListReport(report: any[]) { @@ -144,14 +157,14 @@ export class TeleSuiteUpdater { this._testResultsSnapshot = new Map(tests.map(test => [test.id, test.results])); this._receiver.reset(); for (const message of report) - this._receiver.dispatch(message); + void this._receiver.dispatch(message); } processTestReportEvent(message: any) { // The order of receiver dispatches matters here, we want to assign `lastRunTestCount` // before we use it. - this._lastRunReceiver?.dispatch(message)?.catch(() => {}); - this._receiver.dispatch(message)?.catch(() => {}); + this._lastRunReceiver?.dispatch(message)?.catch(() => { }); + this._receiver.dispatch(message)?.catch(() => { }); } private _handleOnError(error: reporterTypes.TestError) { @@ -160,7 +173,7 @@ export class TeleSuiteUpdater { this._options.onUpdate(); } - asModel(): TestModel { + asModel(): TeleSuiteUpdaterTestModel { return { rootSuite: this.rootSuite || new TeleSuite('', 'root'), config: this.config!, diff --git a/packages/trace-viewer/src/ui/uiModeFiltersView.tsx b/packages/trace-viewer/src/ui/uiModeFiltersView.tsx index 1c1be674f7..7671c2e9ba 100644 --- a/packages/trace-viewer/src/ui/uiModeFiltersView.tsx +++ b/packages/trace-viewer/src/ui/uiModeFiltersView.tsx @@ -20,7 +20,7 @@ import '@web/third_party/vscode/codicon.css'; import { settings } from '@web/uiUtils'; import React from 'react'; import './uiModeFiltersView.css'; -import type { TestModel } from './uiModeModel'; +import type { TeleSuiteUpdaterTestModel } from '@testIsomorphic/teleSuiteUpdater'; export const FiltersView: React.FC<{ filterText: string; @@ -29,7 +29,7 @@ export const FiltersView: React.FC<{ setStatusFilters: (filters: Map) => void; projectFilters: Map; setProjectFilters: (filters: Map) => void; - testModel: TestModel | undefined, + testModel: TeleSuiteUpdaterTestModel | undefined, runTests: () => void; }> = ({ filterText, setFilterText, statusFilters, setStatusFilters, projectFilters, setProjectFilters, testModel, runTests }) => { const [expanded, setExpanded] = React.useState(false); diff --git a/packages/trace-viewer/src/ui/uiModeModel.ts b/packages/trace-viewer/src/ui/uiModeModel.ts deleted file mode 100644 index 97952cfbfd..0000000000 --- a/packages/trace-viewer/src/ui/uiModeModel.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (c) Microsoft Corporation. - - 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 type * as reporterTypes from 'playwright/types/testReporter'; - -export type Progress = { - total: number; - passed: number; - failed: number; - skipped: number; -}; - -export type TestModel = { - config: reporterTypes.FullConfig; - rootSuite: reporterTypes.Suite; - loadErrors: reporterTypes.TestError[]; - progress: Progress; -}; - -export const pathSeparator = navigator.userAgent.toLowerCase().includes('windows') ? '\\' : '/'; diff --git a/packages/trace-viewer/src/ui/uiModeTestListView.tsx b/packages/trace-viewer/src/ui/uiModeTestListView.tsx index b7a9d8e1d1..99a5f22dfa 100644 --- a/packages/trace-viewer/src/ui/uiModeTestListView.tsx +++ b/packages/trace-viewer/src/ui/uiModeTestListView.tsx @@ -27,10 +27,10 @@ import type * as reporterTypes from 'playwright/types/testReporter'; import React from 'react'; import type { SourceLocation } from './modelUtil'; import { testStatusIcon } from './testUtils'; -import type { TestModel } from './uiModeModel'; import './uiModeTestListView.css'; import type { TestServerConnection } from '@testIsomorphic/testServerConnection'; import { TagView } from './tag'; +import type { TeleSuiteUpdaterTestModel } from '@testIsomorphic/teleSuiteUpdater'; const TestTreeView = TreeView; @@ -38,7 +38,7 @@ export const TestListView: React.FC<{ filterText: string, testTree: TestTree, testServerConnection: TestServerConnection | undefined, - testModel?: TestModel, + testModel?: TeleSuiteUpdaterTestModel, runTests: (mode: 'bounce-if-busy' | 'queue-if-busy', testIds: Set) => void, runningState?: { testIds: Set, itemSelectedByUser?: boolean, completed?: boolean }, watchAll: boolean, @@ -179,7 +179,7 @@ export const TestListView: React.FC<{ noItemsMessage={isLoading ? 'Loading\u2026' : 'No tests'} />; }; -function itemLocation(item: TreeItem | undefined, model: TestModel | undefined): SourceLocation | undefined { +function itemLocation(item: TreeItem | undefined, model: TeleSuiteUpdaterTestModel | undefined): SourceLocation | undefined { if (!item || !model) return; return { diff --git a/packages/trace-viewer/src/ui/uiModeView.tsx b/packages/trace-viewer/src/ui/uiModeView.tsx index b12617c300..4a73575a11 100644 --- a/packages/trace-viewer/src/ui/uiModeView.tsx +++ b/packages/trace-viewer/src/ui/uiModeView.tsx @@ -18,8 +18,7 @@ import '@web/third_party/vscode/codicon.css'; import '@web/common.css'; import React from 'react'; import { TeleSuite } from '@testIsomorphic/teleReceiver'; -import { TeleSuiteUpdater } from './teleSuiteUpdater'; -import type { Progress } from './uiModeModel'; +import { TeleSuiteUpdater, type TeleSuiteUpdaterProgress, type TeleSuiteUpdaterTestModel } from '@testIsomorphic/teleSuiteUpdater'; import type { TeleTestCase } from '@testIsomorphic/teleReceiver'; import type * as reporterTypes from 'playwright/types/testReporter'; import { SplitView } from '@web/components/splitView'; @@ -34,13 +33,13 @@ import { clsx, settings, useSetting } from '@web/uiUtils'; import { statusEx, TestTree } from '@testIsomorphic/testTree'; import type { TreeItem } from '@testIsomorphic/testTree'; import { TestServerConnection } from '@testIsomorphic/testServerConnection'; -import { pathSeparator } from './uiModeModel'; -import type { TestModel } from './uiModeModel'; import { FiltersView } from './uiModeFiltersView'; import { TestListView } from './uiModeTestListView'; import { TraceView } from './uiModeTraceView'; import { SettingsView } from './settingsView'; +const pathSeparator = navigator.userAgent.toLowerCase().includes('windows') ? '\\' : '/'; + let xtermSize = { cols: 80, rows: 24 }; const xtermDataSource: XtermDataSource = { pending: [], @@ -80,8 +79,8 @@ export const UIModeView: React.FC<{}> = ({ ['skipped', false], ])); const [projectFilters, setProjectFilters] = React.useState>(new Map()); - const [testModel, setTestModel] = React.useState(); - const [progress, setProgress] = React.useState(); + const [testModel, setTestModel] = React.useState(); + const [progress, setProgress] = React.useState(); const [selectedItem, setSelectedItem] = React.useState<{ treeItem?: TreeItem, testFile?: SourceLocation, testCase?: reporterTypes.TestCase }>({}); const [visibleTestIds, setVisibleTestIds] = React.useState>(new Set()); const [isLoading, setIsLoading] = React.useState(false); From 947fbc859000423f7e6b80eba79725ad073f47f2 Mon Sep 17 00:00:00 2001 From: Playwright Service <89237858+playwrightmachine@users.noreply.github.com> Date: Thu, 22 Aug 2024 08:43:39 -0700 Subject: [PATCH 2/6] feat(chromium-tip-of-tree): roll to r1253 (#32266) Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- packages/playwright-core/browsers.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/playwright-core/browsers.json b/packages/playwright-core/browsers.json index dd9fd60588..576b81035d 100644 --- a/packages/playwright-core/browsers.json +++ b/packages/playwright-core/browsers.json @@ -9,9 +9,9 @@ }, { "name": "chromium-tip-of-tree", - "revision": "1250", + "revision": "1253", "installByDefault": false, - "browserVersion": "129.0.6658.0" + "browserVersion": "130.0.6670.0" }, { "name": "firefox", From 0b9c036505b7c2d00f6bec4d58d49cd63bb6a9db Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Thu, 22 Aug 2024 17:56:07 +0200 Subject: [PATCH 3/6] chore(ui): add test for font preview (#32225) Adds a test for the font preview feature. --- tests/library/trace-viewer.spec.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.ts index 3af586d67f..4ebffc1f42 100644 --- a/tests/library/trace-viewer.spec.ts +++ b/tests/library/trace-viewer.spec.ts @@ -289,6 +289,20 @@ test('should filter network requests by resource type', async ({ page, runAndTra await expect(traceViewer.networkRequests.getByText('font.woff2')).toBeVisible(); }); +test('should show font preview', async ({ page, runAndTrace, server }) => { + const traceViewer = await runAndTrace(async () => { + await page.goto(`${server.PREFIX}/network-tab/network.html`); + }); + await traceViewer.selectAction('http://localhost'); + await traceViewer.showNetworkTab(); + + await traceViewer.page.getByText('Font', { exact: true }).click(); + await expect(traceViewer.networkRequests).toHaveCount(1); + await traceViewer.networkRequests.getByText('font.woff2').click(); + await traceViewer.page.getByTestId('network-request-details').getByTitle('Body').click(); + await expect(traceViewer.page.locator('.network-request-details-tab')).toContainText('ABCDEF'); +}); + test('should filter network requests by url', async ({ page, runAndTrace, server }) => { const traceViewer = await runAndTrace(async () => { await page.goto(`${server.PREFIX}/network-tab/network.html`); From 3a75f23ea1d116a57f6a9d6bf758cf8d693eb7c3 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Fri, 23 Aug 2024 02:48:56 -0700 Subject: [PATCH 4/6] fix(addInitScript): require non-undefined arg to trigger commonjs module (#32282) --- docs/src/api/class-browsercontext.md | 4 ++-- docs/src/api/class-page.md | 4 ++-- packages/playwright-core/src/client/browserContext.ts | 2 +- packages/playwright-core/src/client/clientHelper.ts | 4 ++-- packages/playwright-core/src/client/page.ts | 2 +- packages/playwright-core/src/client/selectors.ts | 2 +- packages/playwright-core/types/types.d.ts | 8 ++++---- tests/page/page-add-init-script.spec.ts | 6 ------ 8 files changed, 13 insertions(+), 19 deletions(-) diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.md index 7b6c6aab1d..eed27fc1c1 100644 --- a/docs/src/api/class-browsercontext.md +++ b/docs/src/api/class-browsercontext.md @@ -439,9 +439,9 @@ const mockPath = { path: path.resolve(__dirname, '../mocks/mockRandom.js') }; // Passing 42 as an argument to the default export function. await context.addInitScript({ path: mockPath }, 42); -// Make sure to pass undefined even if you do not need to pass an argument. +// Make sure to pass something even if you do not need to pass an argument. // This instructs Playwright to treat the file as a commonjs module. -await context.addInitScript({ path: mockPath }, undefined); +await context.addInitScript({ path: mockPath }, ''); ``` ### param: BrowserContext.addInitScript.script diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md index 11d7cbdd74..78d38a6f7a 100644 --- a/docs/src/api/class-page.md +++ b/docs/src/api/class-page.md @@ -643,9 +643,9 @@ const mockPath = { path: path.resolve(__dirname, '../mocks/mockRandom.js') }; // Passing 42 as an argument to the default export function. await page.addInitScript({ path: mockPath }, 42); -// Make sure to pass undefined even if you do not need to pass an argument. +// Make sure to pass something even if you do not need to pass an argument. // This instructs Playwright to treat the file as a commonjs module. -await page.addInitScript({ path: mockPath }, undefined); +await page.addInitScript({ path: mockPath }, ''); ``` ### param: Page.addInitScript.script diff --git a/packages/playwright-core/src/client/browserContext.ts b/packages/playwright-core/src/client/browserContext.ts index b0b72917cf..c4f7827840 100644 --- a/packages/playwright-core/src/client/browserContext.ts +++ b/packages/playwright-core/src/client/browserContext.ts @@ -308,7 +308,7 @@ export class BrowserContext extends ChannelOwner } async addInitScript(script: Function | string | { path?: string, content?: string }, arg?: any): Promise { - const source = await evaluationScript(script, arg, arguments.length > 1); + const source = await evaluationScript(script, arg); await this._channel.addInitScript({ source }); } diff --git a/packages/playwright-core/src/client/clientHelper.ts b/packages/playwright-core/src/client/clientHelper.ts index fcc785b71b..793219f10b 100644 --- a/packages/playwright-core/src/client/clientHelper.ts +++ b/packages/playwright-core/src/client/clientHelper.ts @@ -28,7 +28,7 @@ export function envObjectToArray(env: types.Env): { name: string, value: string return result; } -export async function evaluationScript(fun: Function | string | { path?: string, content?: string }, arg: any, hasArg: boolean, addSourceUrl: boolean = true): Promise { +export async function evaluationScript(fun: Function | string | { path?: string, content?: string }, arg: any, addSourceUrl: boolean = true): Promise { if (typeof fun === 'function') { const source = fun.toString(); const argString = Object.is(arg, undefined) ? 'undefined' : JSON.stringify(arg); @@ -46,7 +46,7 @@ export async function evaluationScript(fun: Function | string | { path?: string, } if (fun.path !== undefined) { let source = await fs.promises.readFile(fun.path, 'utf8'); - if (hasArg) { + if (arg !== undefined) { // Assume a CJS module that has a function default export. source = `(() => { var exports = {}; var module = { exports }; diff --git a/packages/playwright-core/src/client/page.ts b/packages/playwright-core/src/client/page.ts index 5ff6d6178d..a10286fa9a 100644 --- a/packages/playwright-core/src/client/page.ts +++ b/packages/playwright-core/src/client/page.ts @@ -492,7 +492,7 @@ export class Page extends ChannelOwner implements api.Page } async addInitScript(script: Function | string | { path?: string, content?: string }, arg?: any) { - const source = await evaluationScript(script, arg, arguments.length > 1); + const source = await evaluationScript(script, arg); await this._channel.addInitScript({ source }); } diff --git a/packages/playwright-core/src/client/selectors.ts b/packages/playwright-core/src/client/selectors.ts index c7a7967559..2739be0e8d 100644 --- a/packages/playwright-core/src/client/selectors.ts +++ b/packages/playwright-core/src/client/selectors.ts @@ -26,7 +26,7 @@ export class Selectors implements api.Selectors { private _registrations: channels.SelectorsRegisterParams[] = []; async register(name: string, script: string | (() => SelectorEngine) | { path?: string, content?: string }, options: { contentScript?: boolean } = {}): Promise { - const source = await evaluationScript(script, undefined, false, false); + const source = await evaluationScript(script, undefined, false); const params = { ...options, name, source }; for (const channel of this._channels) await channel._channel.register(params); diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts index 0d018dcfd3..f4baa9a352 100644 --- a/packages/playwright-core/types/types.d.ts +++ b/packages/playwright-core/types/types.d.ts @@ -312,9 +312,9 @@ export interface Page { * // Passing 42 as an argument to the default export function. * await page.addInitScript({ path: mockPath }, 42); * - * // Make sure to pass undefined even if you do not need to pass an argument. + * // Make sure to pass something even if you do not need to pass an argument. * // This instructs Playwright to treat the file as a commonjs module. - * await page.addInitScript({ path: mockPath }, undefined); + * await page.addInitScript({ path: mockPath }, ''); * ``` * * @param script Script to be evaluated in the page. @@ -7723,9 +7723,9 @@ export interface BrowserContext { * // Passing 42 as an argument to the default export function. * await context.addInitScript({ path: mockPath }, 42); * - * // Make sure to pass undefined even if you do not need to pass an argument. + * // Make sure to pass something even if you do not need to pass an argument. * // This instructs Playwright to treat the file as a commonjs module. - * await context.addInitScript({ path: mockPath }, undefined); + * await context.addInitScript({ path: mockPath }, ''); * ``` * * @param script Script to be evaluated in all pages in the browser context. diff --git a/tests/page/page-add-init-script.spec.ts b/tests/page/page-add-init-script.spec.ts index 2b12f00251..2c8234a550 100644 --- a/tests/page/page-add-init-script.spec.ts +++ b/tests/page/page-add-init-script.spec.ts @@ -37,12 +37,6 @@ it('should assume CJS module with a path and arg', async ({ page, server, asset expect(await page.evaluate(() => window['injected'])).toBe(17); }); -it('should assume CJS module with a path and undefined arg', async ({ page, server, asset }) => { - await page.addInitScript({ path: asset('injectedmodule.js') }, undefined); - await page.goto(server.EMPTY_PAGE); - expect(await page.evaluate(() => window['injected'])).toBe(42); -}); - it('should work with content @smoke', async ({ page, server }) => { await page.addInitScript({ content: 'window["injected"] = 123' }); await page.goto(server.PREFIX + '/tamperable.html'); From 8c0e173d6c7d157d95f03a1aa6e64ba9f9704503 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 23 Aug 2024 12:51:49 +0200 Subject: [PATCH 5/6] test: rebase modernizer Linux tests (#32268) --- tests/assets/modernizr/mobile-safari-14-1.json | 4 ++-- tests/assets/modernizr/safari-14-1.json | 4 ++-- tests/library/modernizr.spec.ts | 16 +++++----------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/tests/assets/modernizr/mobile-safari-14-1.json b/tests/assets/modernizr/mobile-safari-14-1.json index a67ccfb232..4e959333fa 100644 --- a/tests/assets/modernizr/mobile-safari-14-1.json +++ b/tests/assets/modernizr/mobile-safari-14-1.json @@ -29,7 +29,7 @@ "htmlimports": false, "history": true, "ie8compat": false, - "applicationcache": true, + "applicationcache": false, "blobconstructor": true, "blob-constructor": true, "cookies": true, @@ -166,7 +166,7 @@ "srcdoc": true, "imgcrossorigin": true, "hashchange": true, - "inputsearchevent": true, + "inputsearchevent": false, "ambientlight": false, "datalistelem": true, "videoloop": true, diff --git a/tests/assets/modernizr/safari-14-1.json b/tests/assets/modernizr/safari-14-1.json index 5be7c70bcc..5d39648297 100644 --- a/tests/assets/modernizr/safari-14-1.json +++ b/tests/assets/modernizr/safari-14-1.json @@ -29,7 +29,7 @@ "htmlimports": false, "history": true, "ie8compat": false, - "applicationcache": true, + "applicationcache": false, "blobconstructor": true, "blob-constructor": true, "cookies": true, @@ -166,7 +166,7 @@ "srcdoc": true, "imgcrossorigin": true, "hashchange": true, - "inputsearchevent": true, + "inputsearchevent": false, "ambientlight": false, "datalistelem": true, "videoloop": true, diff --git a/tests/library/modernizr.spec.ts b/tests/library/modernizr.spec.ts index 327a3c4169..9db5b24aa5 100644 --- a/tests/library/modernizr.spec.ts +++ b/tests/library/modernizr.spec.ts @@ -32,7 +32,6 @@ async function checkFeatures(name: string, context: any, server: any) { it('safari-14-1', async ({ browser, browserName, platform, server, headless, isMac }) => { it.skip(browserName !== 'webkit'); - it.skip(browserName === 'webkit' && platform === 'darwin', 'WebKit for macOS 10.15 is frozen.'); it.skip(browserName === 'webkit' && platform === 'darwin' && parseInt(os.release(), 10) === 22, 'Modernizr uses WebGL which is not available in macOS-13 - https://bugs.webkit.org/show_bug.cgi?id=278277'); const context = await browser.newContext({ deviceScaleFactor: 2 @@ -41,6 +40,7 @@ it('safari-14-1', async ({ browser, browserName, platform, server, headless, isM if (platform === 'linux') { expected.subpixelfont = false; + expected.speechrecognition = false; if (headless) expected.todataurljpeg = false; @@ -56,7 +56,6 @@ it('safari-14-1', async ({ browser, browserName, platform, server, headless, isM if (platform === 'win32') { expected.datalistelem = false; - expected.fileinputdirectory = false; expected.getusermedia = false; expected.peerconnection = false; expected.speechrecognition = false; @@ -64,6 +63,7 @@ it('safari-14-1', async ({ browser, browserName, platform, server, headless, isM expected.todataurljpeg = false; expected.unicode = false; expected.webaudio = false; + expected.gamepads = false; expected.input.list = false; expected.inputtypes.color = false; @@ -72,10 +72,8 @@ it('safari-14-1', async ({ browser, browserName, platform, server, headless, isM expected.inputtypes.time = false; } - if (isMac && parseInt(os.release(), 10) > 20) { + if (isMac && parseInt(os.release(), 10) > 20) expected.applicationcache = false; - expected.inputsearchevent = false; - } expect(actual).toEqual(expected); }); @@ -99,6 +97,7 @@ it('mobile-safari-14-1', async ({ playwright, browser, browserName, platform, is if (platform === 'linux') { expected.subpixelfont = false; + expected.speechrecognition = false; if (headless) expected.todataurljpeg = false; @@ -114,7 +113,6 @@ it('mobile-safari-14-1', async ({ playwright, browser, browserName, platform, is if (platform === 'win32') { expected.datalistelem = false; - expected.fileinputdirectory = false; expected.getusermedia = false; expected.peerconnection = false; expected.speechrecognition = false; @@ -122,6 +120,7 @@ it('mobile-safari-14-1', async ({ playwright, browser, browserName, platform, is expected.todataurljpeg = false; expected.unicode = false; expected.webaudio = false; + expected.gamepads = false; expected.input.list = false; expected.inputtypes.color = false; @@ -133,11 +132,6 @@ it('mobile-safari-14-1', async ({ playwright, browser, browserName, platform, is expected.inputtypes.time = false; } - if (isMac && parseInt(os.release(), 10) > 20) { - expected.applicationcache = false; - expected.inputsearchevent = false; - } - expect(actual).toEqual(expected); }); From 785ca19e5188c9dab16ce5f526b9d074e5627233 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Fri, 23 Aug 2024 03:52:27 -0700 Subject: [PATCH 6/6] fix(webserver): prefix each line of webserver output (#32286) This unflakes various `web-server.spec.ts` tests and makes the output more consistent. --- .../playwright/src/plugins/webServerPlugin.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/playwright/src/plugins/webServerPlugin.ts b/packages/playwright/src/plugins/webServerPlugin.ts index 96a369bddb..e2474f35f2 100644 --- a/packages/playwright/src/plugins/webServerPlugin.ts +++ b/packages/playwright/src/plugins/webServerPlugin.ts @@ -113,13 +113,13 @@ export class WebServerPlugin implements TestRunnerPlugin { debugWebServer(`Process started`); - launchedProcess.stderr!.on('data', line => { + launchedProcess.stderr!.on('data', data => { if (debugWebServer.enabled || (this._options.stderr === 'pipe' || !this._options.stderr)) - this._reporter!.onStdErr?.(colors.dim('[WebServer] ') + line.toString()); + this._reporter!.onStdErr?.(prefixOutputLines(data.toString())); }); - launchedProcess.stdout!.on('data', line => { + launchedProcess.stdout!.on('data', data => { if (debugWebServer.enabled || this._options.stdout === 'pipe') - this._reporter!.onStdOut?.(colors.dim('[WebServer] ') + line.toString()); + this._reporter!.onStdOut?.(prefixOutputLines(data.toString())); }); } @@ -201,3 +201,14 @@ export const webServerPluginsForConfig = (config: FullConfigInternal): TestRunne return webServerPlugins; }; + +function prefixOutputLines(output: string) { + const lastIsNewLine = output[output.length - 1] === '\n'; + let lines = output.split('\n'); + if (lastIsNewLine) + lines.pop(); + lines = lines.map(line => colors.dim('[WebServer] ') + line); + if (lastIsNewLine) + lines.push(''); + return lines.join('\n'); +}