Fixes #491 When `--start-maximized` or `--window-size` is passed as a browser arg, Playwright's default viewport (1280x720) overrides the browser's own window sizing, making those flags have no effect on the page content. This change auto-detects those args and sets `viewport: null` so Playwright defers to the browser's window size. Explicit viewport values still take priority. Also allows `viewport: null` in the launch protocol for agents that want to disable viewport emulation directly.
This commit is contained in:
@@ -598,6 +598,31 @@ describe('parseCommand', () => {
|
||||
expect(result.command.allowFileAccess).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
it('should parse launch with viewport dimensions', () => {
|
||||
const result = parseCommand(
|
||||
cmd({ id: '1', action: 'launch', viewport: { width: 1920, height: 1080 } })
|
||||
);
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.command.viewport).toEqual({ width: 1920, height: 1080 });
|
||||
}
|
||||
});
|
||||
|
||||
it('should parse launch with viewport null', () => {
|
||||
const result = parseCommand(cmd({ id: '1', action: 'launch', viewport: null }));
|
||||
expect(result.success).toBe(true);
|
||||
if (result.success) {
|
||||
expect(result.command.viewport).toBeNull();
|
||||
}
|
||||
});
|
||||
|
||||
it('should reject launch with invalid viewport', () => {
|
||||
const result = parseCommand(
|
||||
cmd({ id: '1', action: 'launch', viewport: { width: -1, height: 720 } })
|
||||
);
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('mouse actions', () => {
|
||||
|
||||
Reference in New Issue
Block a user