Skip to content

Commit 71276fd

Browse files
test(firefox): cover custom user agent in route.fetch (#43724)
Co-authored-by: microsoft-playwright-automation[bot] <203992400+microsoft-playwright-automation[bot]@users.noreply.github.com>
1 parent 42bc363 commit 71276fd

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎tests/library/browsercontext-user-agent.spec.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ it('UA-001 should work', async ({ browser, server }) => {
3838
}
3939
});
4040

41+
it('UA-007 should preserve custom user agent in route.fetch', {
42+
annotation: { type: 'issue', description: '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/microsoft/playwright/issues/43597' },
43+
}, async ({ contextFactory, server }) => {
44+
const context = await contextFactory({ userAgent: 'my-custom-user-agent' });
45+
const page = await context.newPage();
46+
await page.route('**/empty.html', async route => {
47+
await route.fulfill({ response: await route.fetch() });
48+
});
49+
const [request, serverRequest] = await Promise.all([
50+
page.waitForRequest(server.EMPTY_PAGE),
51+
server.waitForRequest('/empty.html'),
52+
page.goto(server.EMPTY_PAGE),
53+
]);
54+
expect.soft(request.headers()['user-agent']).toBe('my-custom-user-agent');
55+
expect(serverRequest.headers['user-agent']).toBe('my-custom-user-agent');
56+
});
57+
4158
it('UA-002 should work for subframes', async ({ browser, server }) => {
4259
{
4360
const context = await browser.newContext();

‎tests/registry.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5270,6 +5270,7 @@ subsystem, add a row to the Subsystems table. Then update this file:
52705270
| `UA-004` | `library/browsercontext-user-agent.spec.ts` | should make a copy of default options |
52715271
| `UA-005` | `library/browsercontext-user-agent.spec.ts` | custom user agent for download |
52725272
| `UA-006` | `library/browsercontext-user-agent.spec.ts` | should work for navigator.userAgentData and sec-ch-ua headers |
5273+
| `UA-007` | `library/browsercontext-user-agent.spec.ts` | should preserve custom user agent in route.fetch |
52735274

52745275
### VI — Video
52755276

0 commit comments

Comments
 (0)