Issue 1:
System info

Playwright Version: [v1.XX]

Operating System: [All, Windows 11, Ubuntu 20, macOS 13.2, etc.]

Browser: [Chromium]

Other info:

Source code

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

Config file

// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'], },
},
]
});

No custom config but the bug is also present if you set, there is a full test below which reproduces it so no need to modify config unless you want to also try to setting the headers in the config once reproduced.

use: {
extraHTTPHeaders: {
"x-my-custom-header": "test",
}
}

Test file (self-contained)

This test uses test-cors to make a cors request to playwright.dev site for https://playwright.dev/img/playwright-logo.svg which has access-control-allow-origin: * set

When setExtraHTTPHeaders is used test fails, when it is not, test passes.

import { test, expect } from "@playwright/test";

test.describe("extraHTTPHeaders bug", () => {
test.only("cors errors", async ({ page }) => {
await page.setExtraHTTPHeaders({
"x-my-custom-header": "test",
});

page.on("request", async (r) => {
if (r.url().includes("playwright")) {
const headers = await r.allHeaders();
console.log(r.url(), "request headers", Object.keys(headers).length);
}
});
page.on("response", async (r) => {
if (r.url().includes("playwright")) {
const headers = await r.allHeaders();
console.log(r.url(), "response headers", Object.keys(headers).length);
}
});
page.on("requestfailed", async (request) => {
console.error("ERROR", request.url() + " " + request.failure().errorText);
});
await page.goto(
"https://www.test-cors.org/#?client_method=GET&client_credentials=false&server_url=https%3A%2F%2Fplaywright.dev&server_enable=true&server_status=200&server_credentials=false&server_tabs=remote"
);
await page.click("#btnSendRequest");
await expect(page.getByText("XHR status: 200")).toBeVisible();
});
});

You can comment out extraHTTPHeaders and this test will pass.

Steps

Use setExtraHTTPHeaders to set a custom header, in my case it was for setting a WAF headers

Go to a site which relies on CORS. See requests fail.

Expected

Extra header is added

Actual

Extra header is added BUT it also removes other headers such as CORS headers.

Screenshots

Sorry about terrible quality video, github wouldnt let me do more than 10 MB

https://user-images.githubusercontent.com/9056958/226429554-af9b4f5c-0c0b-4a78-a7e3-5cdb209612b2.mov

Issue 2:
System info

Playwright Version: [v1.36.1]

Source code

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

https://playwright.dev/docs/test-parameterize#create-tests-via-a-csv-file

Example with reading CSV file and generating tests out of it works perfectly fine

import { test } from "@playwright/test";
import * as fs from "fs";
import { parse } from "csv-parse/sync";

const records = parse(fs.readFileSync("input.csv"), {
columns: true,
skip_empty_lines: true,
});

for (const record of records) {
test(`foo: ${record.test_case}`, async () => {
console.log(record.test_case);
});
}

with a result

Running 4 tests using 1 worker

✓ 1 debug.spec.ts:12:7 › foo: value 1 (9ms)
value 1
✓ 2 debug.spec.ts:12:7 › foo: value 2 (6ms)
value 2
✓ 3 debug.spec.ts:12:7 › foo: value 3 (4ms)
value 3
✓ 4 debug.spec.ts:12:7 › foo: value 4 (2ms)
value 4

4 passed (184ms)

But when I do the same with sync fetch

import { test } from "@playwright/test";
import _fetch from "sync-fetch";

const json = _fetch("https://random-data-api.com/api/v2/users?size=2&is_xml=true").json();
for (const data of json) {
test(`bar: ${data.uid}`, async () => {
console.log(data.uid);
});
}

it comes to

Running 2 tests using 1 worker

✘ 1 debug.spec.ts:6:7 › bar: 440fe159-3301-4985-ad8e-a9026bcd49af (0ms)
- 2 debug.spec.ts:6:7 › bar: 81921e9c-2ef9-4999-bf9d-d1ef0f83ee31

1) debug.spec.ts:6:7 › bar: 440fe159-3301-4985-ad8e-a9026bcd49af ─────────────────────────────────

Test(s) not found in the worker process. Make sure test titles do not change:
> debug.spec.ts > bar: 440fe159-3301-4985-ad8e-a9026bcd49af
> debug.spec.ts > bar: 81921e9c-2ef9-4999-bf9d-d1ef0f83ee31

1 failed
debug.spec.ts:6:7 › bar: 440fe159-3301-4985-ad8e-a9026bcd49af ──────────────────────────────────
1 skipped

What is wrong here? Why is the test title error thrown in this case and not in the previous one?