Issue 1:
System info

Playwright Version: 1.32.2

Operating System: Windows

Browser: Firefox

Source code

I provided exact source code that allows reproducing the issue locally.

Link to the GitHub repository with the repro

[https://github.com/Smrtnyk/fetch-start-pw-repro]

Steps

Clone the repo

Run npm test

Expected

Test should not fail.

Actual

After update to 1.32.2 from 1.25.2 this test started failing all the time.

fetchStart from resource timings is always negative.

If you revert to playwright version 1.25.2 it succeeds.

Happens only on firefox in playwright, webkit and chromium are fine.

Doesn't happen on real firefox.

Issue 2:
System info

Playwright Version: v1.33.0

Operating System: Windows 11

Browser: WebKit

Other info:

Source code

I provided exact source code that allows reproducing the issue locally.

Link to the GitHub repository with the repro

https://github.com/murolem/playwright-console-duplicates-on-webkit-issue

Steps

Run npm run test:webkit command to run test on WebKit with the issue.

Run npm run test:chromium or npm run test:firefox command to run test on Chromium or Firefox, respectively, which will pass successfully.

Expected

Test succeeds.

Actual

Test will fail because instead of 2 messages being printed by the tested function, it will be 8 messages.

These are the contents of tested function:

// index.ts

export function sayHello() {
debugLog('saying hello...');
debugLog('foo');
debugLog('bar');
debugLog('foo');
console.log('hello world!');

debugLog('and saying hello again...');
debugLog('faz');
debugLog('faz');
console.log('hello world, again!');
}

v

These are 2 functions that actually print something to console.

// index.ts

...
console.log('hello world!');
console.log('hello world, again!');
...

Below are the contents of the test.

In test, console events are being listened for 1 second, then checks are made:

there should be only 2 console events

their content equals to what is being logged in the tested function.

debugLog function, which is being called from the tested function, does nothing except for checking that some random property exists on window object.

// index.test.ts

import { test, expect, ConsoleMessage } from '@playwright/test';
import { sayHello } from '../src/index.ts';

test('prints a "hello world" console message', async ({ page }) => {
// expose a function `debugLog` which does nothing by itself
// check if some random property on `window` object exists
await page.exposeFunction('debugLog', (str: string) => {
// @ts-ignore
if(window['somePropertyThatDoesNotExists']) {
// do something here...
}
});

// define array of future console message and a listener which will be adding them here
const consoleMessages: string[] = [];
const consoleEventListener = (consoleMsg: ConsoleMessage) => {
consoleMessages.push(consoleMsg.text());
}
page.addListener('console', consoleEventListener);

// run `sayHello()`
await page.evaluate((scriptStr) => {
eval(scriptStr);

sayHello();
}, sayHello.toString());

// waiting 1000ms for all messages to be printed
await wait(1000);

page.removeListener('console', consoleEventListener);

// log collected messages
console.log('console messages:', JSON.stringify(consoleMessages, null, 2));

expect(consoleMessages.length).toBe(2);
expect(consoleMessages[0]).toBe('hello world!');
expect(consoleMessages[1]).toBe('hello world, again!');
});

async function wait(ms: number): Promise<void> {
await new Promise(resolve => setTimeout(resolve, ms));
}

v

Test output:

> playwright-console-duplicates-on-webkit-issue@1.0.0 test:webkit
> npm run test -- --project=webkit

> playwright-console-duplicates-on-webkit-issue@1.0.0 test
> playwright test --project=webkit

Running 1 test using 1 worker
[webkit] › index.test.ts:4:1 › prints a "hello world" console message
console messages: [
"hello world!",
"hello world, again!",
"hello world, again!",
"hello world, again!",
"hello world, again!",
"hello world, again!",
"hello world, again!",
"hello world, again!"
]
1) [webkit] › index.test.ts:4:1 › prints a "hello world" console message ─────────────────────────

Error: expect(received).toBe(expected) // Object.is equality

Expected: 2
Received: 8

34 | console.log('console messages:', JSON.stringify(consoleMessages, null, 2));
35 |
> 36 | expect(consoleMessages.length).toBe(2);
| ^
37 | expect(consoleMessages[0]).toBe('hello world!');
38 | expect(consoleMessages[1]).toBe('hello world, again!');
39 | });

at C:\Users\aliser\Desktop\repos\playwright-console-duplicates-on-webkit-issue\tests\index.test.ts:36:36

1 failed
[webkit] › index.test.ts:4:1 › prints a "hello world" console message ──────────────────────────