Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(bidi): use the browser-supplied text for console.timeLog/timeEnd messages (#40082)

Holger Benl0cc7c009bde7
diff --git a/packages/playwright-core/src/server/bidi/bidiPage.ts b/packages/playwright-core/src/server/bidi/bidiPage.ts
index 0050576f55..90cb5b3320 100644
--- a/packages/playwright-core/src/server/bidi/bidiPage.ts
+++ b/packages/playwright-core/src/server/bidi/bidiPage.ts
@@ -294,7 +294,8 @@ export class BidiPage implements PageDelegate {
const callFrame = params.stackTrace?.callFrames[0];
const location = callFrame ?? { url: '', lineNumber: 1, columnNumber: 1 };
const type = entry.method === 'warn' ? 'warning' : entry.method;
- this._page.addConsoleMessage(null, type, entry.args.map(arg => createHandle(context, arg)), location, undefined, params.timestamp);
+ const text = (entry.method === 'timeLog' || entry.method === 'timeEnd') && entry.text ? entry.text : undefined;
+ this._page.addConsoleMessage(null, type, entry.args.map(arg => createHandle(context, arg)), location, text, params.timestamp);
}
private async _onFileDialogOpened(params: bidi.Input.FileDialogInfo) {
diff --git a/tests/page/page-event-console.spec.ts b/tests/page/page-event-console.spec.ts
index 014d9a547a..e5e4a1d8b6 100644
--- a/tests/page/page-event-console.spec.ts
+++ b/tests/page/page-event-console.spec.ts
@@ -91,8 +91,8 @@ it('should work for different console API calls', async ({ page }) => {
]);
});
-it('should format the message correctly with time/timeLog/timeEnd', async ({ page, browserName }) => {
- it.fixme(browserName === 'firefox', 'https://github.com/microsoft/playwright/issues/10580');
+it('should format the message correctly with time/timeLog/timeEnd', async ({ page, browserName, isBidi }) => {
+ it.fixme(browserName === 'firefox' && !isBidi, 'https://github.com/microsoft/playwright/issues/10580');
const messages = [];
page.on('console', msg => messages.push(msg));
await page.evaluate(async () => {
@@ -107,6 +107,8 @@ it('should format the message correctly with time/timeLog/timeEnd', async ({ pag
expect(messages[0].type()).toBe('timeEnd');
else if (browserName === 'chromium')
expect(messages[0].type()).toBe('log');
+ else if (browserName === 'firefox')
+ expect(messages[0].type()).toBe('timeLog');
expect(messages[1].type()).toBe('timeEnd');
// WebKit has a space before the unit: https://bugs.webkit.org/show_bug.cgi?id=233556