Skip to content

[pull] main from microsoft:main #110

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

Merged
merged 5 commits into from
Jul 29, 2025
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
7 changes: 7 additions & 0 deletions packages/html-reporter/src/testResultView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ export const TestResultView: React.FC<{
}, [result]);

const prompt = useAsyncMemo(async () => {
const stdoutAttachment = result.attachments.find(a => a.name === 'stdout');
const stderrAttachment = result.attachments.find(a => a.name === 'stderr');
const stdout = stdoutAttachment?.body && stdoutAttachment.contentType === 'text/plain' ? stdoutAttachment.body : undefined;
const stderr = stderrAttachment?.body && stderrAttachment.contentType === 'text/plain' ? stderrAttachment.body : undefined;

return await copyPrompt({
testInfo: [
`- Name: ${test.path.join(' >> ')} >> ${test.title}`,
Expand All @@ -100,6 +105,8 @@ export const TestResultView: React.FC<{
errorContext: errorContext?.path ? await fetch(errorContext.path!).then(r => r.text()) : errorContext?.body,
errors: result.errors,
buildCodeFrame: async error => error.codeframe,
stdout,
stderr,
});
}, [test, errorContext, testRunMetadata, result], undefined);

Expand Down
5 changes: 5 additions & 0 deletions packages/playwright-core/src/server/bidi/bidiPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export class BidiPage implements PageDelegate {
eventsHelper.addEventListener(bidiSession, 'browsingContext.navigationAborted', this._onNavigationAborted.bind(this)),
eventsHelper.addEventListener(bidiSession, 'browsingContext.navigationFailed', this._onNavigationFailed.bind(this)),
eventsHelper.addEventListener(bidiSession, 'browsingContext.fragmentNavigated', this._onFragmentNavigated.bind(this)),
eventsHelper.addEventListener(bidiSession, 'browsingContext.historyUpdated', this._onHistoryUpdated.bind(this)),
eventsHelper.addEventListener(bidiSession, 'browsingContext.domContentLoaded', this._onDomContentLoaded.bind(this)),
eventsHelper.addEventListener(bidiSession, 'browsingContext.load', this._onLoad.bind(this)),
eventsHelper.addEventListener(bidiSession, 'browsingContext.userPromptOpened', this._onUserPromptOpened.bind(this)),
Expand Down Expand Up @@ -219,6 +220,10 @@ export class BidiPage implements PageDelegate {
this._page.frameManager.frameCommittedSameDocumentNavigation(params.context, params.url);
}

private _onHistoryUpdated(params: bidi.BrowsingContext.HistoryUpdatedParameters) {
this._page.frameManager.frameCommittedSameDocumentNavigation(params.context, params.url);
}

private _onUserPromptOpened(event: bidi.BrowsingContext.UserPromptOpenedParameters) {
this._page.browserContext.dialogManager.dialogDidOpen(new dialog.Dialog(
this._page,
Expand Down
387 changes: 201 additions & 186 deletions packages/playwright/ThirdPartyNotices.txt

Large diffs are not rendered by default.

567 changes: 290 additions & 277 deletions packages/playwright/bundles/babel/package-lock.json

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions packages/playwright/bundles/babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
"version": "0.0.1",
"private": true,
"dependencies": {
"@babel/code-frame": "^7.26.2",
"@babel/core": "^7.26.10",
"@babel/helper-plugin-utils": "^7.26.5",
"@babel/parser": "^7.26.10",
"@babel/plugin-proposal-decorators": "^7.25.9",
"@babel/plugin-proposal-explicit-resource-management": "^7.25.9",
"@babel/code-frame": "^7.27.1",
"@babel/core": "^7.28.0",
"@babel/helper-plugin-utils": "^7.27.1",
"@babel/parser": "^7.28.0",
"@babel/plugin-proposal-decorators": "^7.28.0",
"@babel/plugin-proposal-explicit-resource-management": "^7.27.4",
"@babel/plugin-syntax-async-generators": "^7.8.4",
"@babel/plugin-syntax-import-attributes": "^7.26.0",
"@babel/plugin-syntax-import-attributes": "^7.27.1",
"@babel/plugin-syntax-json-strings": "^7.8.3",
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.3",
"@babel/plugin-transform-class-properties": "^7.25.9",
"@babel/plugin-transform-class-static-block": "^7.26.0",
"@babel/plugin-transform-export-namespace-from": "^7.25.9",
"@babel/plugin-transform-logical-assignment-operators": "^7.25.9",
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.26.6",
"@babel/plugin-transform-numeric-separator": "^7.25.9",
"@babel/plugin-transform-optional-chaining": "^7.25.9",
"@babel/plugin-transform-private-methods": "^7.25.9",
"@babel/plugin-transform-private-property-in-object": "^7.25.9",
"@babel/plugin-transform-react-jsx": "^7.25.9",
"@babel/preset-typescript": "^7.26.0"
"@babel/plugin-transform-class-properties": "^7.27.1",
"@babel/plugin-transform-class-static-block": "^7.27.1",
"@babel/plugin-transform-export-namespace-from": "^7.27.1",
"@babel/plugin-transform-logical-assignment-operators": "^7.27.1",
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
"@babel/plugin-transform-nullish-coalescing-operator": "^7.27.1",
"@babel/plugin-transform-numeric-separator": "^7.27.1",
"@babel/plugin-transform-optional-chaining": "^7.27.1",
"@babel/plugin-transform-private-methods": "^7.27.1",
"@babel/plugin-transform-private-property-in-object": "^7.27.1",
"@babel/plugin-transform-react-jsx": "^7.27.1",
"@babel/preset-typescript": "^7.27.1"
},
"devDependencies": {
"@types/babel__code-frame": "^7.0.6",
Expand Down
14 changes: 12 additions & 2 deletions packages/web/src/shared/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ export async function copyPrompt<ErrorInfo extends { message: string }>({

errors,
buildCodeFrame,
stdout,
stderr,
}: {
testInfo: string;
metadata: MetadataWithCommitInfo | undefined;
errorContext: string | undefined;

errors: ErrorInfo[];
buildCodeFrame(error: ErrorInfo): Promise<string | undefined>;
stdout?: string;
stderr?: string;
}) {
const meaningfulSingleLineErrors = new Set(errors.filter(e => e.message && !e.message.includes('\n')).map(e => e.message!));
for (const error of errors) {
Expand Down Expand Up @@ -66,10 +70,16 @@ export async function copyPrompt<ErrorInfo extends { message: string }>({
`# Test info`,
'',
testInfo,
'',
'# Error details',
];

if (stdout)
lines.push('', '# Stdout', '', '```', stripAnsiEscapes(stdout), '```');

if (stderr)
lines.push('', '# Stderr', '', '```', stripAnsiEscapes(stderr), '```');

lines.push('', '# Error details');

for (const error of meaningfulErrors) {
lines.push(
'',
Expand Down
8 changes: 6 additions & 2 deletions tests/bidi/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ const trace = !!process.env.PWTEST_TRACE;
const hasDebugOutput = process.env.DEBUG?.includes('pw:');

function firefoxUserPrefs() {
const defaultPrefs = {
'network.proxy.allow_hijacking_localhost': true,
'network.proxy.testing_localhost_is_secure_when_hijacked': true,
};
const prefsString = process.env.PWTEST_FIREFOX_USER_PREFS;
if (!prefsString)
return undefined;
return JSON.parse(prefsString);
return defaultPrefs;
return { ...defaultPrefs, ...JSON.parse(prefsString) };
}

const outputDir = path.join(__dirname, '..', '..', 'test-results');
Expand Down
15 changes: 9 additions & 6 deletions tests/library/inspector/recorder-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function normalizeCode(code: string): string {
return code.replace(/\s+/g, ' ').trim();
}

test('should click', async ({ context }) => {
test('should click', async ({ context, browserName, platform }) => {
const log = await startRecording(context);
const page = await context.newPage();
await page.setContent(`<button onclick="console.log('click')">Submit</button>`);
Expand All @@ -59,7 +59,8 @@ test('should click', async ({ context }) => {
name: 'click',
selector: 'internal:role=button[name="Submit"i]',
ref: 'e2',
ariaSnapshot: '- button "Submit" [active] [ref=e2]',
// Safari does not focus after a click: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#clicking_and_focus
ariaSnapshot: (browserName === 'webkit' && platform === 'darwin') ? '- button "Submit" [ref=e2]' : '- button "Submit" [active] [ref=e2]',
}),
startTime: expect.any(Number),
})
Expand All @@ -68,7 +69,7 @@ test('should click', async ({ context }) => {
expect(normalizeCode(clickActions[0].code)).toEqual(`await page.getByRole('button', { name: 'Submit' }).click();`);
});

test('should double click', async ({ context }) => {
test('should double click', async ({ context, browserName, platform }) => {
const log = await startRecording(context);
const page = await context.newPage();
await page.setContent(`<button onclick="console.log('click')" ondblclick="console.log('dblclick')">Submit</button>`);
Expand All @@ -82,7 +83,8 @@ test('should double click', async ({ context }) => {
clickCount: 2,
selector: 'internal:role=button[name="Submit"i]',
ref: 'e2',
ariaSnapshot: '- button "Submit" [active] [ref=e2]',
// Safari does not focus after a click: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#clicking_and_focus
ariaSnapshot: (browserName === 'webkit' && platform === 'darwin') ? '- button "Submit" [ref=e2]' : '- button "Submit" [active] [ref=e2]',
}),
startTime: expect.any(Number),
})
Expand All @@ -91,7 +93,7 @@ test('should double click', async ({ context }) => {
expect(normalizeCode(clickActions[0].code)).toEqual(`await page.getByRole('button', { name: 'Submit' }).dblclick();`);
});

test('should right click', async ({ context }) => {
test('should right click', async ({ context, browserName, platform }) => {
const log = await startRecording(context);
const page = await context.newPage();
await page.setContent(`<button oncontextmenu="console.log('contextmenu')">Submit</button>`);
Expand All @@ -105,7 +107,8 @@ test('should right click', async ({ context }) => {
button: 'right',
selector: 'internal:role=button[name="Submit"i]',
ref: 'e2',
ariaSnapshot: '- button "Submit" [active] [ref=e2]',
// Safari does not focus after a click: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#clicking_and_focus
ariaSnapshot: (browserName === 'webkit' && platform === 'darwin') ? '- button "Submit" [ref=e2]' : '- button "Submit" [active] [ref=e2]',
}),
startTime: expect.any(Number),
})
Expand Down
31 changes: 31 additions & 0 deletions tests/playwright-test/reporter-html.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,37 @@ for (const useIntermediateMergeReport of [true, false] as const) {
await expect(page.locator('.attachment-body').nth(1)).toHaveText('Third line');
});

test('should include stdout/stderr in copy prompt', async ({ runInlineTest, page, showReport }) => {
const result = await runInlineTest({
'a.test.js': `
import { test, expect } from '@playwright/test';
test('fails', async ({ page }) => {
console.log('Output line 1');
process.stdout.write('Output line 2\\n');
console.error('Error line 1');
process.stderr.write('Error line 2\\n');
await expect(true).toBeFalsy();
});
`,
}, { reporter: 'dot,html' }, { PLAYWRIGHT_HTML_OPEN: 'never' });
expect(result.exitCode).toBe(1);
expect(result.failed).toBe(1);

await showReport();
await page.context().grantPermissions(['clipboard-read', 'clipboard-write']);

await page.getByRole('link', { name: 'fails' }).click();
await page.getByRole('button', { name: 'Copy prompt' }).click();
await page.waitForFunction(() => navigator.clipboard.readText());
const prompt = await page.evaluate(() => navigator.clipboard.readText());
expect(prompt, 'should contain stdout content').toContain('Output line 1');
expect(prompt, 'should contain stdout content').toContain('Output line 2');
expect(prompt, 'should contain stderr content').toContain('Error line 1');
expect(prompt, 'should contain stderr content').toContain('Error line 2');
expect(prompt, 'should contain stdout section').toContain('# Stdout');
expect(prompt, 'should contain stderr section').toContain('# Stderr');
});

test('should highlight error', async ({ runInlineTest, page, showReport }) => {
const result = await runInlineTest({
'a.test.js': `
Expand Down
Loading