test: adjust unsafe headers test for electron, channels (#35237)

This commit is contained in:
Yury Semikhatsky 2025-03-17 11:41:55 -07:00 committed by GitHub
parent 16468e65bd
commit f49f52248d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 3 deletions

View File

@ -40,7 +40,8 @@ it('should amend HTTP headers', async ({ page, server }) => {
expect(request.headers['foo']).toBe('bar');
});
it('should not allow to override unsafe HTTP headers', async ({ page, server, browserName }) => {
it('should not allow to override unsafe HTTP headers', async ({ page, server, browserName, isAndroid, isElectron }) => {
it.skip(isAndroid);
let resolve;
const routePromise = new Promise<Route>(f => resolve = f);
await page.route('**/*', route => resolve(route));
@ -53,8 +54,12 @@ it('should not allow to override unsafe HTTP headers', async ({ page, server, br
host: 'bar'
}
}).catch(e => e);
if (browserName === 'chromium') {
expect(error.message).toContain('Unsafe header: host');
if (isElectron) {
// Electron doesn't send the request if the host header is overridden,
// but doesn't throw an error either.
expect(error).toBeFalsy();
} else if (browserName === 'chromium') {
expect(error.message).toContain('Unsafe header');
} else {
expect(error).toBeFalsy();
// These lines just document current behavior in FF and WK,