Emulation
此域为页面模拟不同的环境。
EN
This domain emulates different environments for the page.
✅️️ Methods
🔨Emulation.clearDeviceMetricsOverride
清除被覆盖的设备指标。
EN
Clears the overridden device metrics.
🔨Emulation.clearGeolocationOverride
清除被覆盖的地理位置定位和错误信息。
EN
Clears the overridden Geolocation Position and Error.
🔨Emulation.clearIdleOverride
清除空闲状态覆盖。
EN
Clears Idle state overrides.
🔨Emulation.setCPUThrottlingRate
启用CPU节流以模拟慢速CPU。
EN
Enables CPU throttling to emulate slow CPUs.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| rate | ✔️ | number | 节流速率作为减速因子(1表示无节流,2表示2倍减速,依此类推)。 | ENThrottling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc). |
🔨Emulation.setDefaultBackgroundColorOverride
设置或清除框架默认背景颜色的覆盖。如果内容未指定背景颜色,则使用此覆盖。
EN
Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| color | DOM.RGBA | 默认背景色的 RGBA 值。若未指定,将清除任何现有的覆盖设置。 | ENRGBA of the default background color. If not specified, any existing override will be cleared. |
🔨Emulation.setDeviceMetricsOverride
覆盖设备屏幕尺寸的值(window.screen.width、window.screen.height、window.innerWidth、window.innerHeight,以及与"device-width"/"device-height"相关的CSS媒体查询结果)。
EN
Overrides the values of device screen dimensions (window.screen.width, window.screen.height, window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media query results).
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| width | ✔️ | integer | 覆盖宽度值(以像素为单位,最小值为0,最大值为10000000)。0表示禁用覆盖。 | ENOverriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override. | |
| height | ✔️ | integer | 覆盖高度值(以像素为单位,最小值为0,最大值为10000000)。0表示禁用覆盖。 | ENOverriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override. | |
| deviceScaleFactor | ✔️ | number | 覆盖设备缩放因子值。0表示禁用覆盖。 | ENOverriding device scale factor value. 0 disables the override. | |
| mobile | ✔️ | boolean | 是否模拟移动设备。这包括 viewport meta 标签、覆盖滚动条、文本自动调整大小等。 | ENWhether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more. | |
| scale | 🧪 | number | 应用于结果视图图像的缩放比例。 | ENScale to apply to resulting view image. | |
| screenWidth | 🧪 | integer | 覆盖屏幕宽度值(以像素为单位,最小值为0,最大值为10000000)。 | ENOverriding screen width value in pixels (minimum 0, maximum 10000000). | |
| screenHeight | 🧪 | integer | 覆盖屏幕高度值,单位为像素(最小值为0,最大值为10000000)。 | ENOverriding screen height value in pixels (minimum 0, maximum 10000000). | |
| positionX | 🧪 | integer | 覆盖屏幕上视图X轴位置,单位为像素(最小值为0,最大值为10000000)。 | ENOverriding view X position on screen in pixels (minimum 0, maximum 10000000). | |
| positionY | 🧪 | integer | 覆盖屏幕上视图的Y轴位置(以像素为单位,最小值为0,最大值为10000000)。 | ENOverriding view Y position on screen in pixels (minimum 0, maximum 10000000). | |
| dontSetVisibleSize | 🧪 | boolean | 不要设置可见视图大小,依赖显式的setVisibleSize调用。 | ENDo not set visible view size, rely upon explicit setVisibleSize call. | |
| screenOrientation | ScreenOrientation | 屏幕方向覆盖。 | ENScreen orientation override. | ||
| viewport | 🧪 | Page.Viewport | 如果设置,页面的可见区域将被覆盖为此视口。此视口更改不会被页面观察到,例如,视口相对元素不会改变位置。 | ENIf set, the visible area of the page will be overridden to this viewport. This viewport change is not observed by the page, e.g. viewport-relative elements do not change positions. | |
| displayFeature | 🧪 | DisplayFeature | 如果设置,则启用多段屏幕的显示功能。如果未设置,则关闭多段支持。已弃用,请使用 Emulation.setDisplayFeaturesOverride。 | ENIf set, the display feature of a multi-segment screen. If not set, multi-segment support is turned-off. Deprecated, use Emulation.setDisplayFeaturesOverride. | |
| devicePosture | 🧪 | DevicePosture | 如果设置,表示可折叠设备的姿态。如果未设置,姿态将默认为连续。已弃用,请使用 Emulation.setDevicePostureOverride。 | ENIf set, the posture of a foldable device. If not set the posture is set to continuous. Deprecated, use Emulation.setDevicePostureOverride. | |
| scrollbarType | 🧪 | string | 滚动条类型。默认值:default。允许的值: overlay、default | ENScrollbar type. Default:default.Allowed Values: overlay, default | |
| screenOrientationLockEmulation | 🧪 | boolean | 如果设置为true,将启用屏幕方向锁定模拟功能,该功能会拦截页面中的screen.orientation.lock()调用,并通过screenOrientationLockChanged事件报告方向变化。这在响应式设计模式下模拟移动设备方向锁定行为时非常有用。 | ENIf set to true, enables screen orientation lock emulation, which intercepts screen.orientation.lock() calls from the page and reports orientation changes via screenOrientationLockChanged events. This is useful for emulating mobile device orientation lock behavior in responsive design mode. |
🔨Emulation.setEmulatedMedia
模拟给定的CSS媒体查询的媒体类型或媒体特性。
EN
Emulates the given media type or media feature for CSS media queries.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| media | string | 模拟的媒体类型。空字符串会禁用覆盖。 | ENMedia type to emulate. Empty string disables the override. | ||
| features | array[MediaFeature] | 要模拟的媒体特性。 | ENMedia features to emulate. |
🔨Emulation.setEmulatedOSTextScale
模拟给定的操作系统文本缩放比例。
EN
Emulates the given OS text scale.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| scale | number |
🔨Emulation.setEmulatedVisionDeficiency
模拟给定的视觉缺陷。
EN
Emulates the given vision deficiency.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| type | ✔️ | string | 要模拟的视觉缺陷。顺序:优先采用尽力模拟方式,其次针对医学认可的色彩视觉缺陷提供生理学精确模拟。 允许值: none、blurredVision、reducedContrast、achromatopsia、deuteranopia、protanopia、tritanopia | ENVision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies.Allowed Values: none, blurredVision, reducedContrast, achromatopsia, deuteranopia, protanopia, tritanopia |
🔨Emulation.setGeolocationOverride
覆盖地理位置定位或错误。省略纬度、经度或精确度将模拟位置不可用。
EN
Overrides the Geolocation Position or Error. Omitting latitude, longitude or accuracy emulates position unavailable.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| latitude | number | 模拟纬度 | ENMock latitude | ||
| longitude | number | 模拟经度 | ENMock longitude | ||
| accuracy | number | 模拟准确度 | ENMock accuracy | ||
| altitude | number | 模拟海拔高度 | ENMock altitude | ||
| altitudeAccuracy | number | 模拟海拔精度 | ENMock altitudeAccuracy | ||
| heading | number | 模拟标题 | ENMock heading | ||
| speed | number | 模拟速度 | ENMock speed |