Skip to content

Commit

Permalink
fix(webdriver): make sure user agent can be set twice (#13585)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN authored Feb 5, 2025
1 parent b42c046 commit 411ff95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/puppeteer-core/src/bidi/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export class BidiPage extends Page {
const changeUserAgent = (userAgent: string) => {
Object.defineProperty(navigator, 'userAgent', {
value: userAgent,
configurable: true,
});
};

Expand All @@ -190,7 +191,7 @@ export class BidiPage extends Page {
: undefined,
// When we disable the UserAgent we want to
// evaluate the original value in all Browsing Contexts
frames.map(frame => {
...frames.map(frame => {
return frame.evaluate(changeUserAgent, userAgent);
}),
]);
Expand Down
9 changes: 9 additions & 0 deletions test/src/emulation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@ describe('Emulation', () => {
}),
).toContain('iPhone');
});

it('should work twice on about:blank', async () => {
const {page} = await getTestState();

await page.goto('about:blank');
await page.emulate(KnownDevices['iPhone 13']);
await page.emulate(KnownDevices['iPad Pro landscape']);
});

it('should support clicking', async () => {
const {page, server} = await getTestState();

Expand Down

0 comments on commit 411ff95

Please sign in to comment.