跳到主要内容

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.
参数必填标记类型描述原文
colorDOM.RGBA默认背景色的 RGBA 值。若未指定,将清除任何现有的覆盖设置。
ENRGBA of the default background color. If not specified, any existing override will be cleared.

🔨Emulation.setDeviceMetricsOverride

覆盖设备屏幕尺寸的值(window.screen.widthwindow.screen.heightwindow.innerWidthwindow.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.
screenOrientationScreenOrientation屏幕方向覆盖。
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
允许的值:overlaydefault
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.
参数必填标记类型描述原文
mediastring模拟的媒体类型。空字符串会禁用覆盖。
ENMedia type to emulate. Empty string disables the override.
featuresarray[MediaFeature]要模拟的媒体特性。
ENMedia features to emulate.

🔨Emulation.setEmulatedOSTextScale

模拟给定的操作系统文本缩放比例。

EN
Emulates the given OS text scale.
参数必填标记类型描述原文
scalenumber

🔨Emulation.setEmulatedVisionDeficiency

模拟给定的视觉缺陷。

EN
Emulates the given vision deficiency.
参数必填标记类型描述原文
type✔️string要模拟的视觉缺陷。顺序:优先采用尽力模拟方式,其次针对医学认可的色彩视觉缺陷提供生理学精确模拟。
允许值:noneblurredVisionreducedContrastachromatopsiadeuteranopiaprotanopiatritanopia
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.
参数必填标记类型描述原文
latitudenumber模拟纬度
ENMock latitude
longitudenumber模拟经度
ENMock longitude
accuracynumber模拟准确度
ENMock accuracy
altitudenumber模拟海拔高度
ENMock altitude
altitudeAccuracynumber模拟海拔精度
ENMock altitudeAccuracy
headingnumber模拟标题
ENMock heading
speednumber模拟速度
ENMock speed

🔨Emulation.setIdleOverride

覆盖空闲状态。

EN
Overrides the Idle state.
参数必填标记类型描述原文
isUserActive✔️booleanMock isUserActive
ENMock isUserActive
isScreenUnlocked✔️booleanMock isScreenUnlocked
ENMock isScreenUnlocked

🔨Emulation.setScriptExecutionDisabled

在页面中切换脚本执行。

EN
Switches script execution in the page.
参数必填标记类型描述原文
value✔️boolean是否应在页面中禁用脚本执行。
ENWhether script execution should be disabled in the page.

🔨Emulation.setTimezoneOverride

使用指定的时区覆盖默认主机系统时区。

EN
Overrides default host system timezone with the specified one.
参数必填标记类型描述原文
timezoneId✔️string时区标识符。支持的时区列表:https://source.chromium.org/chromium/chromium/deps/icu.git/+/faee8bc70570192d82d2978a71e2a615788597d1:source/data/misc/metaZones.txt 若为空,则禁用覆盖并恢复默认主机系统时区。
ENThe timezone identifier. List of supported timezones: https://source.chromium.org/chromium/chromium/deps/icu.git/+/faee8bc70570192d82d2978a71e2a615788597d1:source/data/misc/metaZones.txt If empty, disables the override and restores default host system timezone.

🔨Emulation.setTouchEmulationEnabled

在不支持触摸功能的平台上启用触摸操作。

EN
Enables touch on platforms which do not support them.
参数必填标记类型描述原文
enabled✔️boolean是否应启用触摸事件模拟。
ENWhether the touch event emulation should be enabled.
maxTouchPointsinteger支持的最大触摸点数。默认为一个。
ENMaximum touch points supported. Defaults to one.

🔨Emulation.setUserAgentOverride

允许使用给定字符串覆盖用户代理。必须设置 userAgentMetadata 才能发送 Client Hint 标头。

EN
Allows overriding user agent with the given string. userAgentMetadata must be set for Client Hint headers to be sent.
参数必填标记类型描述原文
userAgent✔️string要使用的用户代理。
ENUser agent to use.
acceptLanguagestring要模拟的浏览器语言。
ENBrowser language to emulate.
platformstring平台 navigator.platform 应当返回。
ENThe platform navigator.platform should return.
userAgentMetadata🧪UserAgentMetadata在Sec-CH-UA-*头部中发送,并在navigator.userAgentData中返回
ENTo be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData

🔨Emulation.canEmulate❌️

判断是否支持模拟功能。

EN
Tells whether emulation is supported.
返回对象类型描述原文
resultboolean如果支持模拟,则为True。
ENTrue if emulation is supported.

🔨Emulation.addScreen🧪

向设备添加一个新屏幕。仅在无头模式下受支持。

EN
Add a new screen to the device. Only supported in headless mode.
参数必填标记类型描述原文
left✔️integer屏幕左边缘的偏移量,以像素为单位。
ENOffset of the left edge of the screen in pixels.
top✔️integer屏幕顶边的偏移量(以像素为单位)。
ENOffset of the top edge of the screen in pixels.
width✔️integer屏幕的宽度,单位为像素。
ENThe width of the screen in pixels.
height✔️integer屏幕的高度,单位为像素。
ENThe height of the screen in pixels.
workAreaInsetsWorkAreaInsets指定屏幕的工作区域。默认值为整个屏幕。
ENSpecifies the screen's work area. Default is entire screen.
devicePixelRationumber指定屏幕的设备像素比。默认值为1。
ENSpecifies the screen's device pixel ratio. Default is 1.
rotationinteger指定屏幕的旋转角度。可用值为0、90、180和270。默认值为0。
ENSpecifies the screen's rotation angle. Available values are 0, 90, 180 and 270. Default is 0.
colorDepthinteger指定屏幕的颜色深度,单位为比特。默认值为24。
ENSpecifies the screen's color depth in bits. Default is 24.
labelstring指定屏幕的描述性标签。默认值为无。
ENSpecifies the descriptive label for the screen. Default is none.
isInternalboolean指示屏幕是否为设备内置或外接于设备。默认值为 false。
ENIndicates whether the screen is internal to the device or external, attached to the device. Default is false.
返回对象类型描述原文
screenInfoScreenInfo

🔨Emulation.clearDevicePostureOverride🧪

清除通过 setDeviceMetricsOverride()setDevicePostureOverride() 设置的设备姿态覆盖,并重新开始使用来自平台的姿态信息。如果未设置任何覆盖,则不执行任何操作。

EN
Clears a device posture override set with either setDeviceMetricsOverride() or setDevicePostureOverride() and starts using posture information from the platform again. Does nothing if no override is set.

🔨Emulation.clearDisplayFeaturesOverride🧪

清除通过 setDeviceMetricsOverride()setDisplayFeaturesOverride() 设置的显示特性覆盖,并重新开始使用平台的显示特性。如果未设置覆盖,则不执行任何操作。

EN
Clears the display features override set with either setDeviceMetricsOverride() or setDisplayFeaturesOverride() and starts using display features from the platform again. Does nothing if no override is set.

🔨Emulation.getOverriddenSensorInformation🧪

参数必填标记类型描述原文
type✔️SensorType
返回对象类型描述原文
requestedSamplingFrequencynumber

🔨Emulation.getScreenInfos🧪

返回设备的屏幕配置。在''headful''模式下,返回物理屏幕配置;而在''headless''模式下,则提供虚拟的无头屏幕配置。

EN
Returns device's screen configuration. In headful mode, the physical screens configuration is returned, whereas in headless mode, a virtual headless screen configuration is provided instead.
返回对象类型描述原文
screenInfosarray[ScreenInfo]

🔨Emulation.removeScreen🧪

从设备移除屏幕。仅在无头模式下支持。

EN
Remove screen from the device. Only supported in headless mode.
参数必填标记类型描述原文
screenId✔️ScreenId

🔨Emulation.resetPageScaleFactor🧪

请求将页面缩放比例重置为初始值。

EN
Requests that page scale factor is reset to initial values.

🔨Emulation.setAutoDarkModeOverride🧪

自动使用深色主题渲染所有网页内容。

EN
Automatically render all web contents using a dark theme.
参数必填标记类型描述原文
enabledboolean是否启用或禁用自动深色模式。如果未指定,将清除任何现有的覆盖设置。
ENWhether to enable or disable automatic dark mode. If not specified, any existing override will be cleared.

🔨Emulation.setAutomationOverride🧪

允许覆盖自动化标志。

EN
Allows overriding the automation flag.
参数必填标记类型描述原文
enabled✔️boolean覆盖是否应启用。
ENWhether the override should be enabled.

🔨Emulation.setDataSaverOverride🧪

覆盖 navigator.connection.saveData 的值

EN
Override the value of navigator.connection.saveData
参数必填标记类型描述原文
dataSaverEnabledboolean覆盖值。省略参数将禁用覆盖。
ENOverride value. Omitting the parameter disables the override.

🔨Emulation.setDevicePostureOverride🧪

开始向设备姿态API报告给定的姿态值。此覆盖设置也可以在setDeviceMetricsOverride()中完成。

EN
Start reporting the given posture value to the Device Posture API. This override can also be set in setDeviceMetricsOverride().
参数必填标记类型描述原文
posture✔️DevicePosture

🔨Emulation.setDisabledImageTypes🧪

参数必填标记类型描述原文
imageTypes✔️array[DisabledImageType]要禁用的图像类型。
ENImage types to disable.

🔨Emulation.setDisplayFeaturesOverride🧪

开始使用给定的显示特性来填充视口分段API。此覆盖也可以在setDeviceMetricsOverride()中设置。

EN
Start using the given display features to pupulate the Viewport Segments API. This override can also be set in setDeviceMetricsOverride().
参数必填标记类型描述原文
features✔️array[DisplayFeature]

🔨Emulation.setDocumentCookieDisabled🧪

参数必填标记类型描述原文
disabled✔️boolean是否应禁用 document.coookie API。
ENWhether document.coookie API should be disabled.

🔨Emulation.setEmitTouchEventsForMouse🧪

参数必填标记类型描述原文
enabled✔️boolean是否应启用基于鼠标输入的触摸模拟。
ENWhether touch emulation based on mouse input should be enabled.
configurationstring触摸/手势事件配置。默认值:当前平台。
允许的值:mobiledesktop
ENTouch/gesture events configuration. Default: current platform.
Allowed Values: mobile, desktop

🔨Emulation.setFocusEmulationEnabled🧪

启用或禁用模拟页面处于聚焦和活动状态。

EN
Enables or disables simulating a focused and active page.
参数必填标记类型描述原文
enabled✔️boolean是否启用或禁用焦点模拟。
ENWhether to enable to disable focus emulation.

🔨Emulation.setHardwareConcurrencyOverride🧪

参数必填标记类型描述原文
hardwareConcurrency✔️integer报告硬件并发数
ENHardware concurrency to report

🔨Emulation.setLocaleOverride🧪

使用指定的区域设置覆盖默认主机系统区域设置。

EN
Overrides default host system locale with the specified one.
参数必填标记类型描述原文
localestringICU 风格的 C 语言区域设置(例如 "en_US")。如果未指定或为空,则禁用覆盖并恢复默认主机系统区域设置。
ENICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale.

🔨Emulation.setPageScaleFactor🧪

设置指定的页面缩放比例。

EN
Sets a specified page scale factor.
参数必填标记类型描述原文
pageScaleFactor✔️number页面缩放比例。
ENPage scale factor.

🔨Emulation.setPressureDataOverride🧪

提供一个给定的压力数据集,该数据集将被处理并最终传递给PressureObserver用户。|source|必须事先通过setPressureSourceOverrideEnabled进行覆盖。

EN
Provides a given pressure data set that will be processed and eventually be delivered to PressureObserver users. |source| must have been previously overridden by setPressureSourceOverrideEnabled.
参数必填标记类型描述原文
source✔️PressureSource
state✔️PressureState
ownContributionEstimatenumber

🔨Emulation.setPressureSourceOverrideEnabled🧪

覆盖指定类型的压力源,如Compute Pressure API所使用的,以便通过setPressureStateOverride提供对PressureObserver.observe()的更新,而不是从平台提供的遥测数据中获取。

EN
Overrides a pressure source of a given type, as used by the Compute Pressure API, so that updates to PressureObserver.observe() are provided via setPressureStateOverride instead of being retrieved from platform-provided telemetry data.
参数必填标记类型描述原文
enabled✔️boolean
source✔️PressureSource
metadataPressureMetadata

🔨Emulation.setPressureStateOverride🧪

TODO: OBSOLETE: 当 setPressureDataOverride 合并后移除。提供一个给定的压力状态,该状态将被处理并最终传递给 PressureObserver 用户。|source| 必须事先已通过 setPressureSourceOverrideEnabled 进行覆盖。

EN
TODO: OBSOLETE: To remove when setPressureDataOverride is merged. Provides a given pressure state that will be processed and eventually be delivered to PressureObserver users. |source| must have been previously overridden by setPressureSourceOverrideEnabled.
参数必填标记类型描述原文
source✔️PressureSource
state✔️PressureState

🔨Emulation.setPrimaryScreen🧪

设置主屏幕。仅在无头模式下支持。请注意,此操作会将坐标系原点更改为新主屏幕的左上角,并相应更新所有现有屏幕的边界和工作区域。

EN
Set primary screen. Only supported in headless mode. Note that this changes the coordinate system origin to the top-left of the new primary screen, updating the bounds and work areas of all existing screens accordingly.
参数必填标记类型描述原文
screenId✔️ScreenId

🔨Emulation.setSafeAreaInsetsOverride🧪

覆盖 env(safe-area-inset-)env(safe-area-max-inset-) 的值。未设置的值将导致相应的变量变为未定义状态,即使之前已被覆盖。

EN
Overrides the values for env(safe-area-inset-) and env(safe-area-max-inset-). Unset values will cause the respective variables to be undefined, even if previously overridden.
参数必填标记类型描述原文
insets✔️SafeAreaInsets

🔨Emulation.setScrollbarsHidden🧪

参数必填标记类型描述原文
hidden✔️boolean滚动条是否应始终隐藏。
ENWhether scrollbars should be always hidden.

🔨Emulation.setSensorOverrideEnabled🧪

覆盖指定类型的平台传感器。如果|enabled|为true,调用Sensor.start()时将使用虚拟传感器作为后端,而非从真实硬件传感器获取数据。若为false,则现有虚拟传感器后端的Sensor对象将触发错误事件,且新的Sensor.start()调用将尝试使用真实传感器。

EN
Overrides a platform sensor of a given type. If |enabled| is true, calls to Sensor.start() will use a virtual sensor as backend rather than fetching data from a real hardware sensor. Otherwise, existing virtual sensor-backend Sensor objects will fire an error event and new calls to Sensor.start() will attempt to use a real sensor instead.
参数必填标记类型描述原文
enabled✔️boolean
type✔️SensorType
metadataSensorMetadata

🔨Emulation.setSensorOverrideReadings🧪

更新由先前通过 setSensorOverrideEnabled 覆盖的传感器类型所报告的传感器读数。

EN
Updates the sensor readings reported by a sensor type previously overridden by setSensorOverrideEnabled.
参数必填标记类型描述原文
type✔️SensorType
reading✔️SensorReading

🔨Emulation.setSmallViewportHeightDifferenceOverride🧪

允许覆盖小视口和大视口尺寸之间的差异,这分别决定了svhlvh单位的值。仅支持顶级框架。

EN
Allows overriding the difference between the small and large viewport sizes, which determine the value of the svh and lvh unit, respectively. Only supported for top-level frames.
参数必填标记类型描述原文
difference✔️integer这将导致一个大小为100svh的元素比一个大小为100lvh的元素小difference像素。
ENThis will cause an element of size 100svh to be difference pixels smaller than an element of size 100lvh.

🔨Emulation.setVirtualTimePolicy🧪

为所有帧启用虚拟时间(用合成时间源替换实时时间)并设置当前的虚拟时间策略。注意这会覆盖之前任何的时间预算。

EN
Turns on virtual time for all frames (replacing real-time with a synthetic time source) and sets the current virtual time policy. Note this supersedes any previous time budget.
参数必填标记类型描述原文
policy✔️VirtualTimePolicy
budgetnumber如果设置,当经过这么多虚拟毫秒后,虚拟时间将暂停,并发送一个virtualTimeBudgetExpired事件。
ENIf set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.
maxVirtualTimeTaskStarvationCountinteger如果设置此项,它指定了在强制虚拟向前推进以防止死锁之前可以运行的最大任务数。
ENIf set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock.
initialVirtualTimeNetwork.TimeSinceEpoch如果设置了此项,base::Time::Now 将被覆盖,初始返回该值。
ENIf set, base::Time::Now will be overridden to initially return this value.
返回对象类型描述原文
virtualTimeTicksBasenumber虚拟时间首次启用时的绝对时间戳(以毫秒为单位的运行时间)。
ENAbsolute timestamp at which virtual time was first enabled (up time in milliseconds).

🔨Emulation.updateScreen🧪

更新指定的屏幕参数。仅支持在无头模式下使用。

EN
Updates specified screen parameters. Only supported in headless mode.
参数必填标记类型描述原文
screenId✔️ScreenId目标屏幕标识符。
ENTarget screen identifier.
leftinteger屏幕左侧边缘的偏移量(以像素为单位)。
ENOffset of the left edge of the screen in pixels.
topinteger屏幕顶边的偏移量(以像素为单位)。
ENOffset of the top edge of the screen in pixels.
widthinteger屏幕的宽度,单位为像素。
ENThe width of the screen in pixels.
heightinteger屏幕的高度,单位为像素。
ENThe height of the screen in pixels.
workAreaInsetsWorkAreaInsets指定屏幕的工作区域。
ENSpecifies the screen's work area.
devicePixelRationumber指定屏幕的设备像素比。
ENSpecifies the screen's device pixel ratio.
rotationinteger指定屏幕的旋转角度。可用值为0、90、180和270。
ENSpecifies the screen's rotation angle. Available values are 0, 90, 180 and 270.
colorDepthinteger指定屏幕的颜色深度,单位为比特。
ENSpecifies the screen's color depth in bits.
labelstring指定屏幕的描述性标签。
ENSpecifies the descriptive label for the screen.
isInternalboolean指示屏幕是否为设备内置,还是外部连接至设备。默认值为 false。
ENIndicates whether the screen is internal to the device or external, attached to the device. Default is false.
返回对象类型描述原文
screenInfoScreenInfo

🔨Emulation.setNavigatorOverrides🧪❌️

覆盖由javascript navigator对象返回的值。

EN
Overrides value returned by the javascript navigator object.
参数必填标记类型描述原文
platform✔️string平台 navigator.platform 应该返回。
ENThe platform navigator.platform should return.

🔨Emulation.setVisibleSize🧪❌️

调整页面框架/视口的尺寸。请注意,这不会影响框架的容器(例如浏览器窗口)。可用于生成指定尺寸的截图。在Android上不受支持。

EN
Resizes the frame/viewport of the page. Note that this does not affect the frame's container (e.g. browser window). Can be used to produce screenshots of the specified size. Not supported on Android.
参数必填标记类型描述原文
width✔️integer帧宽度(DIP)。
ENFrame width (DIP).
height✔️integer帧高度(DIP)。
ENFrame height (DIP).

✅️️ Events

👋Emulation.screenOrientationLockChanged🧪

当页面在启用设备模拟时调用 screen.orientation.lock()screen.orientation.unlock() 时触发。这允许 DevTools 前端相应地更新模拟的设备方向。

EN
Fired when a page calls screen.orientation.lock() or screen.orientation.unlock() while device emulation is enabled. This allows the DevTools frontend to update the emulated device orientation accordingly.
参数必填标记类型描述原文
locked✔️boolean屏幕方向当前是否被锁定。
ENWhether the screen orientation is currently locked.
orientationScreenOrientation页面请求的屏幕方向锁定类型。仅在锁定状态为真时设置。
ENThe orientation lock type requested by the page. Only set when locked is true.

👋Emulation.virtualTimeBudgetExpired🧪

在当前VirtualTimePolicy的虚拟时间预算耗尽后发送的通知。

EN
Notification sent after the virtual time budget for the current VirtualTimePolicy has run out.

✅️️ Types

📌Emulation.DevicePosture

返回类型:object

属性必填标记类型描述原文
type✔️string设备的当前姿态
允许的取值:continuousfolded
ENCurrent posture of the device
Allowed Values: continuous, folded

📌Emulation.DisplayFeature

返回类型:object

属性必填标记类型描述原文
orientation✔️string显示特征相对于屏幕的方向
允许的值:verticalhorizontal
ENOrientation of a display feature in relation to screen
Allowed Values: vertical, horizontal
offset✔️integer从屏幕原点沿x轴(垂直方向)或y轴(水平方向)的偏移量。
ENThe offset from the screen origin in either the x (for vertical orientation) or y (for horizontal orientation) direction.
maskLength✔️integer一个显示特性可能会遮盖内容,使其在物理上不可见——此长度与偏移量共同描述了该区域。仅用于分割内容的显示特性其遮盖长度将为0。
ENA display feature may mask content such that it is not physically displayed - this length along with the offset describes this area. A display feature that only splits content will have a 0 mask_length.

📌Emulation.MediaFeature

返回类型:object

属性必填标记类型描述原文
name✔️string
value✔️string

📌Emulation.ScreenOrientation

屏幕方向。

EN
Screen orientation.

返回类型:object

属性必填标记类型描述原文
type✔️string屏幕方向类型。
允许的取值:portraitPrimaryportraitSecondarylandscapePrimarylandscapeSecondary
ENOrientation type.
Allowed Values: portraitPrimary, portraitSecondary, landscapePrimary, landscapeSecondary
angle✔️integer方向角度。
ENOrientation angle.

📌Emulation.DisabledImageType🧪

可禁用图像类型的枚举。
允许的值:avifjxlwebp

EN
Enum of image types that can be disabled.
Allowed Values: avif, jxl, webp

返回类型:string


📌Emulation.PressureMetadata🧪

返回类型:object

属性必填标记类型描述原文
availableboolean

📌Emulation.PressureSource🧪

允许的值:cpu

EN
Allowed Values: cpu

返回类型:string


📌Emulation.PressureState🧪

允许的值:nominalfairseriouscritical

EN
Allowed Values: nominal, fair, serious, critical

返回类型:string


📌Emulation.SafeAreaInsets🧪

返回类型:object

属性必填标记类型描述原文
topinteger覆盖安全区域顶部插入值。
ENOverrides safe-area-inset-top.
topMaxinteger覆盖安全区域最大顶部内边距。
ENOverrides safe-area-max-inset-top.
leftinteger覆盖安全区域左侧插入边距。
ENOverrides safe-area-inset-left.
leftMaxinteger覆盖安全区域左侧最大内边距。
ENOverrides safe-area-max-inset-left.
bottominteger覆盖安全区域底部内边距。
ENOverrides safe-area-inset-bottom.
bottomMaxinteger覆盖安全区域最大底部内边距。
ENOverrides safe-area-max-inset-bottom.
rightinteger覆盖安全区域右侧内边距。
ENOverrides safe-area-inset-right.
rightMaxinteger覆盖安全区域右侧最大内边距。
ENOverrides safe-area-max-inset-right.

📌Emulation.ScreenId🧪

返回类型:string


📌Emulation.ScreenInfo🧪

类似于window.getScreenDetails()方法返回的屏幕信息,参见https://w3c.github.io/window-management/#screendetailed

EN
Screen information similar to the one returned by window.getScreenDetails() method, see https://w3c.github.io/window-management/#screendetailed.

返回类型:object

属性必填标记类型描述原文
left✔️integer屏幕左侧边缘的偏移量。
ENOffset of the left edge of the screen.
top✔️integer屏幕顶边的偏移量。
ENOffset of the top edge of the screen.
width✔️integer屏幕宽度。
ENWidth of the screen.
height✔️integer屏幕的高度。
ENHeight of the screen.
availLeft✔️integer可用屏幕区域的左边缘偏移量。
ENOffset of the left edge of the available screen area.
availTop✔️integer可用屏幕区域顶边的偏移量。
ENOffset of the top edge of the available screen area.
availWidth✔️integer可用屏幕区域的宽度。
ENWidth of the available screen area.
availHeight✔️integer可用屏幕区域的高度。
ENHeight of the available screen area.
devicePixelRatio✔️number指定屏幕的设备像素比。
ENSpecifies the screen's device pixel ratio.
orientation✔️ScreenOrientation指定屏幕的方向。
ENSpecifies the screen's orientation.
colorDepth✔️integer指定屏幕的颜色深度,单位为比特。
ENSpecifies the screen's color depth in bits.
isExtended✔️boolean表示设备是否拥有多个屏幕。
ENIndicates whether the device has multiple screens.
isInternal✔️boolean表示屏幕是设备内置的还是外部连接到设备的。
ENIndicates whether the screen is internal to the device or external, attached to the device.
isPrimary✔️boolean指示屏幕是否被设置为操作系统的主屏幕。
ENIndicates whether the screen is set as the the operating system primary screen.
label✔️string指定屏幕的描述性标签。
ENSpecifies the descriptive label for the screen.
id✔️ScreenId指定屏幕的唯一标识符。
ENSpecifies the unique identifier of the screen.

📌Emulation.SensorMetadata🧪

返回类型:object

属性必填标记类型描述原文
availableboolean
minimumFrequencynumber
maximumFrequencynumber

📌Emulation.SensorReading🧪

返回类型:object

属性必填标记类型描述原文
singleSensorReadingSingle
xyzSensorReadingXYZ
quaternionSensorReadingQuaternion

📌Emulation.SensorReadingQuaternion🧪

返回类型:object

属性必填标记类型描述原文
x✔️number
y✔️number
z✔️number
w✔️number

📌Emulation.SensorReadingSingle🧪

返回类型:object

属性必填标记类型描述原文
value✔️number

📌Emulation.SensorReadingXYZ🧪

返回类型:object

属性必填标记类型描述原文
x✔️number
y✔️number
z✔️number

📌Emulation.SensorType🧪

用于指定要模拟的传感器类型。更多信息请参阅 https://w3c.github.io/sensors/#automation
允许的取值:absolute-orientation, accelerometer, ambient-light, gravity, gyroscope, linear-acceleration, magnetometer, relative-orientation

EN
Used to specify sensor types to emulate. See https://w3c.github.io/sensors/#automation for more information.
Allowed Values: absolute-orientation, accelerometer, ambient-light, gravity, gyroscope, linear-acceleration, magnetometer, relative-orientation

返回类型:string


📌Emulation.UserAgentBrandVersion🧪

用于指定要模拟的用户代理客户端提示。参见https://wicg.github.io/ua-client-hints

EN
Used to specify User Agent Client Hints to emulate. See https://wicg.github.io/ua-client-hints

返回类型:object

属性必填标记类型描述原文
brand✔️string
version✔️string

📌Emulation.UserAgentMetadata🧪

用于指定要模拟的用户代理客户端提示。参见 https://wicg.github.io/ua-client-hints。缺失的可选值将由目标对象使用其常规值自动填充。

EN
Used to specify User Agent Client Hints to emulate. See https://wicg.github.io/ua-client-hints Missing optional values will be filled in by the target with what it would normally use.

返回类型:object

属性必填标记类型描述原文
brandsarray[UserAgentBrandVersion]Sec-CH-UA中出现的品牌。
ENBrands appearing in Sec-CH-UA.
fullVersionListarray[UserAgentBrandVersion]出现在Sec-CH-UA-Full-Version-List中的品牌。
ENBrands appearing in Sec-CH-UA-Full-Version-List.
fullVersion❌️string
platform✔️string
platformVersion✔️string
architecture✔️string
model✔️string
mobile✔️boolean
bitnessstring
wow64boolean
formFactorsarray[string]用于指定用户代理设备形态值。参见 https://wicg.github.io/ua-client-hints/#sec-ch-ua-form-factors
ENUsed to specify User Agent form-factor values. See https://wicg.github.io/ua-client-hints/#sec-ch-ua-form-factors

📌Emulation.VirtualTimePolicy🧪

advance:如果调度器没有即时任务可执行,虚拟时间基准可能会快进以允许执行下一个延迟任务(如果有的话);pause:虚拟时间基准可能不会前进;pauseIfNetworkFetchesPending:如果有任何待处理的资源获取,虚拟时间基准可能不会前进。
允许的值:advancepausepauseIfNetworkFetchesPending

EN
advance: If the scheduler runs out of immediate work, the virtual time base may fast forward to allow the next delayed task (if any) to run; pause: The virtual time base may not advance; pauseIfNetworkFetchesPending: The virtual time base may not advance if there are any pending resource fetches.
Allowed Values: advance, pause, pauseIfNetworkFetchesPending

返回类型:string


📌Emulation.WorkAreaInsets🧪

返回类型:object

属性必填标记类型描述原文
topinteger工作区域顶部内边距,单位为像素。默认值为0;
ENWork area top inset in pixels. Default is 0;
leftinteger工作区域左侧内边距,以像素为单位。默认值为0;
ENWork area left inset in pixels. Default is 0;
bottominteger工作区域底部内边距,以像素为单位。默认值为0;
ENWork area bottom inset in pixels. Default is 0;
rightinteger工作区域右侧内边距(以像素为单位)。默认值为0;
ENWork area right inset in pixels. Default is 0;