Interface IEmulation
This domain emulates different environments for the page.
public interface IEmulation
Properties
ScreenOrientationLockChanged
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.
[Experimental("BIDICDP001")]
IEventSource<ScreenOrientationLockChangedEventArgs> ScreenOrientationLockChanged { get; }
Property Value
- IEventSource<ScreenOrientationLockChangedEventArgs>
Remarks
Event args (ScreenOrientationLockChangedEventArgs):
- Locked - Whether the screen orientation is currently locked.
- Orientation - The orientation lock type requested by the page. Only set when locked is true.
VirtualTimeBudgetExpired
Notification sent after the virtual time budget for the current VirtualTimePolicy has run out.
[Experimental("BIDICDP001")]
IEventSource<VirtualTimeBudgetExpiredEventArgs> VirtualTimeBudgetExpired { get; }
Property Value
- IEventSource<VirtualTimeBudgetExpiredEventArgs>
Methods
AddScreenAsync(long, long, long, long, WorkAreaInsets?, double?, long?, long?, string?, bool?, string?, CancellationToken)
Add a new screen to the device. Only supported in headless mode.
[Experimental("BIDICDP001")]
Task<AddScreenResult> AddScreenAsync(long left, long top, long width, long height, WorkAreaInsets? workAreaInsets = null, double? devicePixelRatio = null, long? rotation = null, long? colorDepth = null, string? label = null, bool? isInternal = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
leftlongOffset of the left edge of the screen in pixels.
toplongOffset of the top edge of the screen in pixels.
widthlongThe width of the screen in pixels.
heightlongThe height of the screen in pixels.
workAreaInsetsWorkAreaInsetsSpecifies the screen's work area. Default is entire screen.
devicePixelRatiodouble?Specifies the screen's device pixel ratio. Default is 1.
rotationlong?Specifies the screen's rotation angle. Available values are 0, 90, 180 and 270. Default is 0.
colorDepthlong?Specifies the screen's color depth in bits. Default is 24.
labelstringSpecifies the descriptive label for the screen. Default is none.
isInternalbool?Indicates whether the screen is internal to the device or external, attached to the device. Default is false.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<AddScreenResult>
A task representing the asynchronous operation, containing a AddScreenResult.
CanEmulateAsync(string?, CancellationToken)
Tells whether emulation is supported.
[Obsolete]
Task<CanEmulateResult> CanEmulateAsync(string? session = null, CancellationToken cancellationToken = default)
Parameters
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<CanEmulateResult>
A task representing the asynchronous operation, containing a CanEmulateResult.
ClearDeviceMetricsOverrideAsync(string?, CancellationToken)
Clears the overridden device metrics.
Task<ClearDeviceMetricsOverrideResult> ClearDeviceMetricsOverrideAsync(string? session = null, CancellationToken cancellationToken = default)
Parameters
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<ClearDeviceMetricsOverrideResult>
A task representing the asynchronous operation, containing a ClearDeviceMetricsOverrideResult.
ClearDevicePostureOverrideAsync(string?, CancellationToken)
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.
[Experimental("BIDICDP001")]
Task<ClearDevicePostureOverrideResult> ClearDevicePostureOverrideAsync(string? session = null, CancellationToken cancellationToken = default)
Parameters
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<ClearDevicePostureOverrideResult>
A task representing the asynchronous operation, containing a ClearDevicePostureOverrideResult.
ClearDisplayFeaturesOverrideAsync(string?, CancellationToken)
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.
[Experimental("BIDICDP001")]
Task<ClearDisplayFeaturesOverrideResult> ClearDisplayFeaturesOverrideAsync(string? session = null, CancellationToken cancellationToken = default)
Parameters
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<ClearDisplayFeaturesOverrideResult>
A task representing the asynchronous operation, containing a ClearDisplayFeaturesOverrideResult.
ClearGeolocationOverrideAsync(string?, CancellationToken)
Clears the overridden Geolocation Position and Error.
Task<ClearGeolocationOverrideResult> ClearGeolocationOverrideAsync(string? session = null, CancellationToken cancellationToken = default)
Parameters
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<ClearGeolocationOverrideResult>
A task representing the asynchronous operation, containing a ClearGeolocationOverrideResult.
ClearIdleOverrideAsync(string?, CancellationToken)
Clears Idle state overrides.
Task<ClearIdleOverrideResult> ClearIdleOverrideAsync(string? session = null, CancellationToken cancellationToken = default)
Parameters
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<ClearIdleOverrideResult>
A task representing the asynchronous operation, containing a ClearIdleOverrideResult.
GetOverriddenSensorInformationAsync(SensorType, string?, CancellationToken)
[Experimental("BIDICDP001")]
Task<GetOverriddenSensorInformationResult> GetOverriddenSensorInformationAsync(SensorType type, string? session = null, CancellationToken cancellationToken = default)
Parameters
typeSensorTypesessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<GetOverriddenSensorInformationResult>
A task representing the asynchronous operation, containing a GetOverriddenSensorInformationResult.
GetScreenInfosAsync(string?, CancellationToken)
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.
[Experimental("BIDICDP001")]
Task<GetScreenInfosResult> GetScreenInfosAsync(string? session = null, CancellationToken cancellationToken = default)
Parameters
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<GetScreenInfosResult>
A task representing the asynchronous operation, containing a GetScreenInfosResult.
RemoveScreenAsync(ScreenId, string?, CancellationToken)
Remove screen from the device. Only supported in headless mode.
[Experimental("BIDICDP001")]
Task<RemoveScreenResult> RemoveScreenAsync(ScreenId screenId, string? session = null, CancellationToken cancellationToken = default)
Parameters
screenIdScreenIdsessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<RemoveScreenResult>
A task representing the asynchronous operation, containing a RemoveScreenResult.
ResetPageScaleFactorAsync(string?, CancellationToken)
Requests that page scale factor is reset to initial values.
[Experimental("BIDICDP001")]
Task<ResetPageScaleFactorResult> ResetPageScaleFactorAsync(string? session = null, CancellationToken cancellationToken = default)
Parameters
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<ResetPageScaleFactorResult>
A task representing the asynchronous operation, containing a ResetPageScaleFactorResult.
SetAutoDarkModeOverrideAsync(bool?, string?, CancellationToken)
Automatically render all web contents using a dark theme.
[Experimental("BIDICDP001")]
Task<SetAutoDarkModeOverrideResult> SetAutoDarkModeOverrideAsync(bool? enabled = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
enabledbool?Whether to enable or disable automatic dark mode. If not specified, any existing override will be cleared.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetAutoDarkModeOverrideResult>
A task representing the asynchronous operation, containing a SetAutoDarkModeOverrideResult.
SetAutomationOverrideAsync(bool, string?, CancellationToken)
Allows overriding the automation flag.
[Experimental("BIDICDP001")]
Task<SetAutomationOverrideResult> SetAutomationOverrideAsync(bool enabled, string? session = null, CancellationToken cancellationToken = default)
Parameters
enabledboolWhether the override should be enabled.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetAutomationOverrideResult>
A task representing the asynchronous operation, containing a SetAutomationOverrideResult.
SetCPUPerformanceOverrideAsync(string?, string?, CancellationToken)
Overrides the value of navigator.cpuPerformance
[Experimental("BIDICDP001")]
Task<SetCPUPerformanceOverrideResult> SetCPUPerformanceOverrideAsync(string? performanceTier = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
performanceTierstringOverride value. Omitting the parameter disables the override.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetCPUPerformanceOverrideResult>
A task representing the asynchronous operation, containing a SetCPUPerformanceOverrideResult.
SetCPUThrottlingRateAsync(double, string?, CancellationToken)
Enables CPU throttling to emulate slow CPUs.
Task<SetCPUThrottlingRateResult> SetCPUThrottlingRateAsync(double rate, string? session = null, CancellationToken cancellationToken = default)
Parameters
ratedoubleThrottling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetCPUThrottlingRateResult>
A task representing the asynchronous operation, containing a SetCPUThrottlingRateResult.
SetDataSaverOverrideAsync(bool?, string?, CancellationToken)
Override the value of navigator.connection.saveData
[Experimental("BIDICDP001")]
Task<SetDataSaverOverrideResult> SetDataSaverOverrideAsync(bool? dataSaverEnabled = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
dataSaverEnabledbool?Override value. Omitting the parameter disables the override.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetDataSaverOverrideResult>
A task representing the asynchronous operation, containing a SetDataSaverOverrideResult.
SetDefaultBackgroundColorOverrideAsync(RGBA?, string?, CancellationToken)
Sets or clears an override of the default background color of the frame. This override is used if the content does not specify one.
Task<SetDefaultBackgroundColorOverrideResult> SetDefaultBackgroundColorOverrideAsync(RGBA? color = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
colorRGBARGBA of the default background color. If not specified, any existing override will be cleared.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetDefaultBackgroundColorOverrideResult>
A task representing the asynchronous operation, containing a SetDefaultBackgroundColorOverrideResult.
SetDeviceMetricsOverrideAsync(long, long, double, bool, double?, long?, long?, long?, long?, bool?, ScreenOrientation?, Viewport?, DisplayFeature?, DevicePosture?, string?, bool?, string?, string?, CancellationToken)
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).
Task<SetDeviceMetricsOverrideResult> SetDeviceMetricsOverrideAsync(long width, long height, double deviceScaleFactor, bool mobile, double? scale = null, long? screenWidth = null, long? screenHeight = null, long? positionX = null, long? positionY = null, bool? dontSetVisibleSize = null, ScreenOrientation? screenOrientation = null, Viewport? viewport = null, DisplayFeature? displayFeature = null, DevicePosture? devicePosture = null, string? scrollbarType = null, bool? screenOrientationLockEmulation = null, string? viewportMeta = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
widthlongOverriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
heightlongOverriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
deviceScaleFactordoubleOverriding device scale factor value. 0 disables the override.
mobileboolWhether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
scaledouble?Scale to apply to resulting view image.
screenWidthlong?Overriding screen width value in pixels (minimum 0, maximum 10000000).
screenHeightlong?Overriding screen height value in pixels (minimum 0, maximum 10000000).
positionXlong?Overriding view X position on screen in pixels (minimum 0, maximum 10000000).
positionYlong?Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
dontSetVisibleSizebool?Do not set visible view size, rely upon explicit setVisibleSize call.
screenOrientationScreenOrientationScreen orientation override.
viewportViewportIf 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.
displayFeatureDisplayFeatureIf set, the display feature of a multi-segment screen. If not set, multi-segment support is turned-off. Deprecated, use Emulation.setDisplayFeaturesOverride.
devicePostureDevicePostureIf set, the posture of a foldable device. If not set the posture is set to continuous. Deprecated, use Emulation.setDevicePostureOverride.
scrollbarTypestringScrollbar type. Default: default.
screenOrientationLockEmulationbool?If 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.
viewportMetastringViewport meta tag behavior. Default: default. Note: if mobile is true, the viewport meta tag is always enabled.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetDeviceMetricsOverrideResult>
A task representing the asynchronous operation, containing a SetDeviceMetricsOverrideResult.
SetDevicePostureOverrideAsync(DevicePosture, string?, CancellationToken)
Start reporting the given posture value to the Device Posture API. This override can also be set in setDeviceMetricsOverride().
[Experimental("BIDICDP001")]
Task<SetDevicePostureOverrideResult> SetDevicePostureOverrideAsync(DevicePosture posture, string? session = null, CancellationToken cancellationToken = default)
Parameters
postureDevicePosturesessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetDevicePostureOverrideResult>
A task representing the asynchronous operation, containing a SetDevicePostureOverrideResult.
SetDisabledImageTypesAsync(ImmutableArray<DisabledImageType>, string?, CancellationToken)
[Experimental("BIDICDP001")]
Task<SetDisabledImageTypesResult> SetDisabledImageTypesAsync(ImmutableArray<DisabledImageType> imageTypes, string? session = null, CancellationToken cancellationToken = default)
Parameters
imageTypesImmutableArray<DisabledImageType>Image types to disable.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetDisabledImageTypesResult>
A task representing the asynchronous operation, containing a SetDisabledImageTypesResult.
SetDisplayFeaturesOverrideAsync(ImmutableArray<DisplayFeature>, string?, CancellationToken)
Start using the given display features to pupulate the Viewport Segments API. This override can also be set in setDeviceMetricsOverride().
[Experimental("BIDICDP001")]
Task<SetDisplayFeaturesOverrideResult> SetDisplayFeaturesOverrideAsync(ImmutableArray<DisplayFeature> features, string? session = null, CancellationToken cancellationToken = default)
Parameters
featuresImmutableArray<DisplayFeature>sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetDisplayFeaturesOverrideResult>
A task representing the asynchronous operation, containing a SetDisplayFeaturesOverrideResult.
SetDocumentCookieDisabledAsync(bool, string?, CancellationToken)
[Experimental("BIDICDP001")]
Task<SetDocumentCookieDisabledResult> SetDocumentCookieDisabledAsync(bool disabled, string? session = null, CancellationToken cancellationToken = default)
Parameters
disabledboolWhether document.coookie API should be disabled.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetDocumentCookieDisabledResult>
A task representing the asynchronous operation, containing a SetDocumentCookieDisabledResult.
SetEmitTouchEventsForMouseAsync(bool, string?, string?, CancellationToken)
[Experimental("BIDICDP001")]
Task<SetEmitTouchEventsForMouseResult> SetEmitTouchEventsForMouseAsync(bool enabled, string? configuration = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
enabledboolWhether touch emulation based on mouse input should be enabled.
configurationstringTouch/gesture events configuration. Default: current platform.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetEmitTouchEventsForMouseResult>
A task representing the asynchronous operation, containing a SetEmitTouchEventsForMouseResult.
SetEmulatedMediaAsync(string?, ImmutableArray<MediaFeature>?, string?, CancellationToken)
Emulates the given media type or media feature for CSS media queries.
Task<SetEmulatedMediaResult> SetEmulatedMediaAsync(string? media = null, ImmutableArray<MediaFeature>? features = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
mediastringMedia type to emulate. Empty string disables the override.
featuresImmutableArray<MediaFeature>?Media features to emulate.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetEmulatedMediaResult>
A task representing the asynchronous operation, containing a SetEmulatedMediaResult.
SetEmulatedOSTextScaleAsync(double?, string?, CancellationToken)
Emulates the given OS text scale.
Task<SetEmulatedOSTextScaleResult> SetEmulatedOSTextScaleAsync(double? scale = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
scaledouble?sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetEmulatedOSTextScaleResult>
A task representing the asynchronous operation, containing a SetEmulatedOSTextScaleResult.
SetEmulatedVisionDeficiencyAsync(string, string?, CancellationToken)
Emulates the given vision deficiency.
Task<SetEmulatedVisionDeficiencyResult> SetEmulatedVisionDeficiencyAsync(string type, string? session = null, CancellationToken cancellationToken = default)
Parameters
typestringVision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetEmulatedVisionDeficiencyResult>
A task representing the asynchronous operation, containing a SetEmulatedVisionDeficiencyResult.
SetFocusEmulationEnabledAsync(bool, string?, CancellationToken)
Enables or disables simulating a focused and active page.
[Experimental("BIDICDP001")]
Task<SetFocusEmulationEnabledResult> SetFocusEmulationEnabledAsync(bool enabled, string? session = null, CancellationToken cancellationToken = default)
Parameters
enabledboolWhether to enable to disable focus emulation.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetFocusEmulationEnabledResult>
A task representing the asynchronous operation, containing a SetFocusEmulationEnabledResult.
SetGeolocationOverrideAsync(double?, double?, double?, double?, double?, double?, double?, string?, CancellationToken)
Overrides the Geolocation Position or Error. Omitting latitude, longitude or accuracy emulates position unavailable.
Task<SetGeolocationOverrideResult> SetGeolocationOverrideAsync(double? latitude = null, double? longitude = null, double? accuracy = null, double? altitude = null, double? altitudeAccuracy = null, double? heading = null, double? speed = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
latitudedouble?Mock latitude
longitudedouble?Mock longitude
accuracydouble?Mock accuracy
altitudedouble?Mock altitude
altitudeAccuracydouble?Mock altitudeAccuracy
headingdouble?Mock heading
speeddouble?Mock speed
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetGeolocationOverrideResult>
A task representing the asynchronous operation, containing a SetGeolocationOverrideResult.
SetHardwareConcurrencyOverrideAsync(long, string?, CancellationToken)
[Experimental("BIDICDP001")]
Task<SetHardwareConcurrencyOverrideResult> SetHardwareConcurrencyOverrideAsync(long hardwareConcurrency, string? session = null, CancellationToken cancellationToken = default)
Parameters
hardwareConcurrencylongHardware concurrency to report
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetHardwareConcurrencyOverrideResult>
A task representing the asynchronous operation, containing a SetHardwareConcurrencyOverrideResult.
SetIdleOverrideAsync(bool, bool, string?, CancellationToken)
Overrides the Idle state.
Task<SetIdleOverrideResult> SetIdleOverrideAsync(bool isUserActive, bool isScreenUnlocked, string? session = null, CancellationToken cancellationToken = default)
Parameters
isUserActiveboolMock isUserActive
isScreenUnlockedboolMock isScreenUnlocked
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetIdleOverrideResult>
A task representing the asynchronous operation, containing a SetIdleOverrideResult.
SetLocaleOverrideAsync(string?, string?, CancellationToken)
Overrides default host system locale with the specified one.
[Experimental("BIDICDP001")]
Task<SetLocaleOverrideResult> SetLocaleOverrideAsync(string? locale = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
localestringICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetLocaleOverrideResult>
A task representing the asynchronous operation, containing a SetLocaleOverrideResult.
SetNavigatorOverridesAsync(string, string?, CancellationToken)
Overrides value returned by the javascript navigator object.
[Experimental("BIDICDP001")]
[Obsolete]
Task<SetNavigatorOverridesResult> SetNavigatorOverridesAsync(string platform, string? session = null, CancellationToken cancellationToken = default)
Parameters
platformstringThe platform navigator.platform should return.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetNavigatorOverridesResult>
A task representing the asynchronous operation, containing a SetNavigatorOverridesResult.
SetPageScaleFactorAsync(double, string?, CancellationToken)
Sets a specified page scale factor.
[Experimental("BIDICDP001")]
Task<SetPageScaleFactorResult> SetPageScaleFactorAsync(double pageScaleFactor, string? session = null, CancellationToken cancellationToken = default)
Parameters
pageScaleFactordoublePage scale factor.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetPageScaleFactorResult>
A task representing the asynchronous operation, containing a SetPageScaleFactorResult.
SetPressureSourceOverrideEnabledAsync(bool, PressureSource, PressureMetadata?, string?, CancellationToken)
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.
[Experimental("BIDICDP001")]
Task<SetPressureSourceOverrideEnabledResult> SetPressureSourceOverrideEnabledAsync(bool enabled, PressureSource source, PressureMetadata? metadata = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
enabledboolsourcePressureSourcemetadataPressureMetadatasessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetPressureSourceOverrideEnabledResult>
A task representing the asynchronous operation, containing a SetPressureSourceOverrideEnabledResult.
SetPressureStateOverrideAsync(PressureSource, PressureState, string?, CancellationToken)
Provides a given pressure state that will be processed and eventually be delivered to PressureObserver users. |source| must have been previously overridden by setPressureSourceOverrideEnabled.
[Experimental("BIDICDP001")]
Task<SetPressureStateOverrideResult> SetPressureStateOverrideAsync(PressureSource source, PressureState state, string? session = null, CancellationToken cancellationToken = default)
Parameters
sourcePressureSourcestatePressureStatesessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetPressureStateOverrideResult>
A task representing the asynchronous operation, containing a SetPressureStateOverrideResult.
SetPrimaryScreenAsync(ScreenId, string?, CancellationToken)
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.
[Experimental("BIDICDP001")]
Task<SetPrimaryScreenResult> SetPrimaryScreenAsync(ScreenId screenId, string? session = null, CancellationToken cancellationToken = default)
Parameters
screenIdScreenIdsessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetPrimaryScreenResult>
A task representing the asynchronous operation, containing a SetPrimaryScreenResult.
SetSafeAreaInsetsOverrideAsync(SafeAreaInsets, string?, CancellationToken)
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.
[Experimental("BIDICDP001")]
Task<SetSafeAreaInsetsOverrideResult> SetSafeAreaInsetsOverrideAsync(SafeAreaInsets insets, string? session = null, CancellationToken cancellationToken = default)
Parameters
insetsSafeAreaInsetssessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetSafeAreaInsetsOverrideResult>
A task representing the asynchronous operation, containing a SetSafeAreaInsetsOverrideResult.
SetScriptExecutionDisabledAsync(bool, string?, CancellationToken)
Switches script execution in the page.
Task<SetScriptExecutionDisabledResult> SetScriptExecutionDisabledAsync(bool value, string? session = null, CancellationToken cancellationToken = default)
Parameters
valueboolWhether script execution should be disabled in the page.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetScriptExecutionDisabledResult>
A task representing the asynchronous operation, containing a SetScriptExecutionDisabledResult.
SetScrollbarsHiddenAsync(bool, string?, CancellationToken)
[Experimental("BIDICDP001")]
Task<SetScrollbarsHiddenResult> SetScrollbarsHiddenAsync(bool hidden, string? session = null, CancellationToken cancellationToken = default)
Parameters
hiddenboolWhether scrollbars should be always hidden.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetScrollbarsHiddenResult>
A task representing the asynchronous operation, containing a SetScrollbarsHiddenResult.
SetSensorOverrideEnabledAsync(bool, SensorType, SensorMetadata?, string?, CancellationToken)
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.
[Experimental("BIDICDP001")]
Task<SetSensorOverrideEnabledResult> SetSensorOverrideEnabledAsync(bool enabled, SensorType type, SensorMetadata? metadata = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
enabledbooltypeSensorTypemetadataSensorMetadatasessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetSensorOverrideEnabledResult>
A task representing the asynchronous operation, containing a SetSensorOverrideEnabledResult.
SetSensorOverrideReadingsAsync(SensorType, SensorReading, string?, CancellationToken)
Updates the sensor readings reported by a sensor type previously overridden by setSensorOverrideEnabled.
[Experimental("BIDICDP001")]
Task<SetSensorOverrideReadingsResult> SetSensorOverrideReadingsAsync(SensorType type, SensorReading reading, string? session = null, CancellationToken cancellationToken = default)
Parameters
typeSensorTypereadingSensorReadingsessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetSensorOverrideReadingsResult>
A task representing the asynchronous operation, containing a SetSensorOverrideReadingsResult.
SetSmallViewportHeightDifferenceOverrideAsync(long, string?, CancellationToken)
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.
[Experimental("BIDICDP001")]
Task<SetSmallViewportHeightDifferenceOverrideResult> SetSmallViewportHeightDifferenceOverrideAsync(long difference, string? session = null, CancellationToken cancellationToken = default)
Parameters
differencelongThis will cause an element of size 100svh to be difference pixels smaller than an element of size 100lvh.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetSmallViewportHeightDifferenceOverrideResult>
A task representing the asynchronous operation, containing a SetSmallViewportHeightDifferenceOverrideResult.
SetTimezoneOverrideAsync(string, string?, CancellationToken)
Overrides default host system timezone with the specified one.
Task<SetTimezoneOverrideResult> SetTimezoneOverrideAsync(string timezoneId, string? session = null, CancellationToken cancellationToken = default)
Parameters
timezoneIdstringThe 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.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetTimezoneOverrideResult>
A task representing the asynchronous operation, containing a SetTimezoneOverrideResult.
SetTouchEmulationEnabledAsync(bool, long?, string?, CancellationToken)
Enables touch on platforms which do not support them.
Task<SetTouchEmulationEnabledResult> SetTouchEmulationEnabledAsync(bool enabled, long? maxTouchPoints = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
enabledboolWhether the touch event emulation should be enabled.
maxTouchPointslong?Maximum touch points supported. Defaults to one.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetTouchEmulationEnabledResult>
A task representing the asynchronous operation, containing a SetTouchEmulationEnabledResult.
SetUserAgentOverrideAsync(string, string?, string?, UserAgentMetadata?, string?, CancellationToken)
Allows overriding user agent with the given string. userAgentMetadata must be set for Client Hint headers to be sent.
Task<SetUserAgentOverrideResult> SetUserAgentOverrideAsync(string userAgent, string? acceptLanguage = null, string? platform = null, UserAgentMetadata? userAgentMetadata = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
userAgentstringUser agent to use.
acceptLanguagestringBrowser language to emulate.
platformstringThe platform navigator.platform should return.
userAgentMetadataUserAgentMetadataTo be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetUserAgentOverrideResult>
A task representing the asynchronous operation, containing a SetUserAgentOverrideResult.
SetVirtualKeyboardGeometryOverrideAsync(Rect?, string?, CancellationToken)
Overrides virtual keyboard geometry in CSS pixels, relative to the top-level viewport. The provided rect is used for navigator.virtualKeyboard.boundingRect, geometrychange events, and env(keyboard-inset-*) values on the inspected frame. The override applies independently of navigator.virtualKeyboard.overlaysContent so clients can preview overlay geometry without mutating page state. Values are rounded to the nearest CSS pixel. Omitting the rect clears the override.
[Experimental("BIDICDP001")]
Task<SetVirtualKeyboardGeometryOverrideResult> SetVirtualKeyboardGeometryOverrideAsync(Rect? keyboardRect = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
keyboardRectRectsessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetVirtualKeyboardGeometryOverrideResult>
A task representing the asynchronous operation, containing a SetVirtualKeyboardGeometryOverrideResult.
SetVirtualTimePolicyAsync(VirtualTimePolicy, double?, long?, TimeSinceEpoch?, string?, CancellationToken)
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.
[Experimental("BIDICDP001")]
Task<SetVirtualTimePolicyResult> SetVirtualTimePolicyAsync(VirtualTimePolicy policy, double? budget = null, long? maxVirtualTimeTaskStarvationCount = null, TimeSinceEpoch? initialVirtualTime = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
policyVirtualTimePolicybudgetdouble?If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.
maxVirtualTimeTaskStarvationCountlong?If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock.
initialVirtualTimeTimeSinceEpochIf set, base::Time::Now will be overridden to initially return this value.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetVirtualTimePolicyResult>
A task representing the asynchronous operation, containing a SetVirtualTimePolicyResult.
SetVisibleSizeAsync(long, long, string?, CancellationToken)
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.
[Experimental("BIDICDP001")]
[Obsolete]
Task<SetVisibleSizeResult> SetVisibleSizeAsync(long width, long height, string? session = null, CancellationToken cancellationToken = default)
Parameters
widthlongFrame width (DIP).
heightlongFrame height (DIP).
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<SetVisibleSizeResult>
A task representing the asynchronous operation, containing a SetVisibleSizeResult.
UpdateScreenAsync(ScreenId, long?, long?, long?, long?, WorkAreaInsets?, double?, long?, long?, string?, bool?, string?, CancellationToken)
Updates specified screen parameters. Only supported in headless mode.
[Experimental("BIDICDP001")]
Task<UpdateScreenResult> UpdateScreenAsync(ScreenId screenId, long? left = null, long? top = null, long? width = null, long? height = null, WorkAreaInsets? workAreaInsets = null, double? devicePixelRatio = null, long? rotation = null, long? colorDepth = null, string? label = null, bool? isInternal = null, string? session = null, CancellationToken cancellationToken = default)
Parameters
screenIdScreenIdTarget screen identifier.
leftlong?Offset of the left edge of the screen in pixels.
toplong?Offset of the top edge of the screen in pixels.
widthlong?The width of the screen in pixels.
heightlong?The height of the screen in pixels.
workAreaInsetsWorkAreaInsetsSpecifies the screen's work area.
devicePixelRatiodouble?Specifies the screen's device pixel ratio.
rotationlong?Specifies the screen's rotation angle. Available values are 0, 90, 180 and 270.
colorDepthlong?Specifies the screen's color depth in bits.
labelstringSpecifies the descriptive label for the screen.
isInternalbool?Indicates whether the screen is internal to the device or external, attached to the device. Default is false.
sessionstringOptional CDP session override.
cancellationTokenCancellationTokenA token to cancel the asynchronous operation.
Returns
- Task<UpdateScreenResult>
A task representing the asynchronous operation, containing a UpdateScreenResult.