项目文件夹

文件
Alex Rudenko a8169676f9 feat: support device viewport and user agent emulation (#798)
This PR adds two emulation attributes `viewport` and `userAgent` that
allow emulating a mobile or a different desktop device.

Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/pull/272
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/619
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/410
Closes https://github.com/ChromeDevTools/chrome-devtools-mcp/issues/280
(the recommended way is to emulate via the MCP server instead of a
parallel DevTools session)
2026-01-20 14:07:57 +00:00

32 行
794 B
TypeScript

/**
* @license
* Copyright 2026 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import assert from 'node:assert';
import {KnownDevices} from 'puppeteer';
import type {TestScenario} from '../eval_gemini.ts';
export const scenario: TestScenario = {
prompt: 'Emulate iPhone 14 viewport',
maxTurns: 2,
expectations: calls => {
assert.strictEqual(calls.length, 1);
assert.strictEqual(calls[0].name, 'emulate');
assert.deepStrictEqual(
{
...(calls[0].args.viewport as object),
// models might not send defaults.
isLandscape: KnownDevices['iPhone 14'].viewport.isLandscape ?? false,
},
{
...KnownDevices['iPhone 14'].viewport,
height: 844, // Puppeteer is wrong about the expected height.
},
);
},
};