emulation.go 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  1. // Package emulation provides the Chrome DevTools Protocol
  2. // commands, types, and events for the Emulation domain.
  3. //
  4. // This domain emulates different environments for the page.
  5. //
  6. // Generated by the cdproto-gen command.
  7. package emulation
  8. // Code generated by cdproto-gen. DO NOT EDIT.
  9. import (
  10. "context"
  11. "github.com/chromedp/cdproto/cdp"
  12. "github.com/chromedp/cdproto/page"
  13. )
  14. // ClearDeviceMetricsOverrideParams clears the overridden device metrics.
  15. type ClearDeviceMetricsOverrideParams struct{}
  16. // ClearDeviceMetricsOverride clears the overridden device metrics.
  17. //
  18. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-clearDeviceMetricsOverride
  19. func ClearDeviceMetricsOverride() *ClearDeviceMetricsOverrideParams {
  20. return &ClearDeviceMetricsOverrideParams{}
  21. }
  22. // Do executes Emulation.clearDeviceMetricsOverride against the provided context.
  23. func (p *ClearDeviceMetricsOverrideParams) Do(ctx context.Context) (err error) {
  24. return cdp.Execute(ctx, CommandClearDeviceMetricsOverride, nil, nil)
  25. }
  26. // ClearGeolocationOverrideParams clears the overridden Geolocation Position
  27. // and Error.
  28. type ClearGeolocationOverrideParams struct{}
  29. // ClearGeolocationOverride clears the overridden Geolocation Position and
  30. // Error.
  31. //
  32. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-clearGeolocationOverride
  33. func ClearGeolocationOverride() *ClearGeolocationOverrideParams {
  34. return &ClearGeolocationOverrideParams{}
  35. }
  36. // Do executes Emulation.clearGeolocationOverride against the provided context.
  37. func (p *ClearGeolocationOverrideParams) Do(ctx context.Context) (err error) {
  38. return cdp.Execute(ctx, CommandClearGeolocationOverride, nil, nil)
  39. }
  40. // ResetPageScaleFactorParams requests that page scale factor is reset to
  41. // initial values.
  42. type ResetPageScaleFactorParams struct{}
  43. // ResetPageScaleFactor requests that page scale factor is reset to initial
  44. // values.
  45. //
  46. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-resetPageScaleFactor
  47. func ResetPageScaleFactor() *ResetPageScaleFactorParams {
  48. return &ResetPageScaleFactorParams{}
  49. }
  50. // Do executes Emulation.resetPageScaleFactor against the provided context.
  51. func (p *ResetPageScaleFactorParams) Do(ctx context.Context) (err error) {
  52. return cdp.Execute(ctx, CommandResetPageScaleFactor, nil, nil)
  53. }
  54. // SetFocusEmulationEnabledParams enables or disables simulating a focused
  55. // and active page.
  56. type SetFocusEmulationEnabledParams struct {
  57. Enabled bool `json:"enabled"` // Whether to enable to disable focus emulation.
  58. }
  59. // SetFocusEmulationEnabled enables or disables simulating a focused and
  60. // active page.
  61. //
  62. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setFocusEmulationEnabled
  63. //
  64. // parameters:
  65. //
  66. // enabled - Whether to enable to disable focus emulation.
  67. func SetFocusEmulationEnabled(enabled bool) *SetFocusEmulationEnabledParams {
  68. return &SetFocusEmulationEnabledParams{
  69. Enabled: enabled,
  70. }
  71. }
  72. // Do executes Emulation.setFocusEmulationEnabled against the provided context.
  73. func (p *SetFocusEmulationEnabledParams) Do(ctx context.Context) (err error) {
  74. return cdp.Execute(ctx, CommandSetFocusEmulationEnabled, p, nil)
  75. }
  76. // SetAutoDarkModeOverrideParams automatically render all web contents using
  77. // a dark theme.
  78. type SetAutoDarkModeOverrideParams struct {
  79. Enabled bool `json:"enabled"` // Whether to enable or disable automatic dark mode. If not specified, any existing override will be cleared.
  80. }
  81. // SetAutoDarkModeOverride automatically render all web contents using a dark
  82. // theme.
  83. //
  84. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setAutoDarkModeOverride
  85. //
  86. // parameters:
  87. func SetAutoDarkModeOverride() *SetAutoDarkModeOverrideParams {
  88. return &SetAutoDarkModeOverrideParams{
  89. Enabled: false,
  90. }
  91. }
  92. // WithEnabled whether to enable or disable automatic dark mode. If not
  93. // specified, any existing override will be cleared.
  94. func (p SetAutoDarkModeOverrideParams) WithEnabled(enabled bool) *SetAutoDarkModeOverrideParams {
  95. p.Enabled = enabled
  96. return &p
  97. }
  98. // Do executes Emulation.setAutoDarkModeOverride against the provided context.
  99. func (p *SetAutoDarkModeOverrideParams) Do(ctx context.Context) (err error) {
  100. return cdp.Execute(ctx, CommandSetAutoDarkModeOverride, p, nil)
  101. }
  102. // SetCPUThrottlingRateParams enables CPU throttling to emulate slow CPUs.
  103. type SetCPUThrottlingRateParams struct {
  104. Rate float64 `json:"rate"` // Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
  105. }
  106. // SetCPUThrottlingRate enables CPU throttling to emulate slow CPUs.
  107. //
  108. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setCPUThrottlingRate
  109. //
  110. // parameters:
  111. //
  112. // rate - Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc).
  113. func SetCPUThrottlingRate(rate float64) *SetCPUThrottlingRateParams {
  114. return &SetCPUThrottlingRateParams{
  115. Rate: rate,
  116. }
  117. }
  118. // Do executes Emulation.setCPUThrottlingRate against the provided context.
  119. func (p *SetCPUThrottlingRateParams) Do(ctx context.Context) (err error) {
  120. return cdp.Execute(ctx, CommandSetCPUThrottlingRate, p, nil)
  121. }
  122. // SetDefaultBackgroundColorOverrideParams sets or clears an override of the
  123. // default background color of the frame. This override is used if the content
  124. // does not specify one.
  125. type SetDefaultBackgroundColorOverrideParams struct {
  126. Color *cdp.RGBA `json:"color,omitempty,omitzero"` // RGBA of the default background color. If not specified, any existing override will be cleared.
  127. }
  128. // SetDefaultBackgroundColorOverride sets or clears an override of the
  129. // default background color of the frame. This override is used if the content
  130. // does not specify one.
  131. //
  132. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setDefaultBackgroundColorOverride
  133. //
  134. // parameters:
  135. func SetDefaultBackgroundColorOverride() *SetDefaultBackgroundColorOverrideParams {
  136. return &SetDefaultBackgroundColorOverrideParams{}
  137. }
  138. // WithColor rGBA of the default background color. If not specified, any
  139. // existing override will be cleared.
  140. func (p SetDefaultBackgroundColorOverrideParams) WithColor(color *cdp.RGBA) *SetDefaultBackgroundColorOverrideParams {
  141. p.Color = color
  142. return &p
  143. }
  144. // Do executes Emulation.setDefaultBackgroundColorOverride against the provided context.
  145. func (p *SetDefaultBackgroundColorOverrideParams) Do(ctx context.Context) (err error) {
  146. return cdp.Execute(ctx, CommandSetDefaultBackgroundColorOverride, p, nil)
  147. }
  148. // SetSafeAreaInsetsOverrideParams overrides the values for
  149. // env(safe-area-inset-*) and env(safe-area-max-inset-*). Unset values will
  150. // cause the respective variables to be undefined, even if previously
  151. // overridden.
  152. type SetSafeAreaInsetsOverrideParams struct {
  153. Insets *SafeAreaInsets `json:"insets"`
  154. }
  155. // SetSafeAreaInsetsOverride overrides the values for env(safe-area-inset-*)
  156. // and env(safe-area-max-inset-*). Unset values will cause the respective
  157. // variables to be undefined, even if previously overridden.
  158. //
  159. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setSafeAreaInsetsOverride
  160. //
  161. // parameters:
  162. //
  163. // insets
  164. func SetSafeAreaInsetsOverride(insets *SafeAreaInsets) *SetSafeAreaInsetsOverrideParams {
  165. return &SetSafeAreaInsetsOverrideParams{
  166. Insets: insets,
  167. }
  168. }
  169. // Do executes Emulation.setSafeAreaInsetsOverride against the provided context.
  170. func (p *SetSafeAreaInsetsOverrideParams) Do(ctx context.Context) (err error) {
  171. return cdp.Execute(ctx, CommandSetSafeAreaInsetsOverride, p, nil)
  172. }
  173. // SetDeviceMetricsOverrideParams overrides the values of device screen
  174. // dimensions (window.screen.width, window.screen.height, window.innerWidth,
  175. // window.innerHeight, and "device-width"/"device-height"-related CSS media
  176. // query results).
  177. type SetDeviceMetricsOverrideParams struct {
  178. Width int64 `json:"width"` // Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
  179. Height int64 `json:"height"` // Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
  180. DeviceScaleFactor float64 `json:"deviceScaleFactor"` // Overriding device scale factor value. 0 disables the override.
  181. Mobile bool `json:"mobile"` // Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
  182. Scale float64 `json:"scale,omitempty,omitzero"` // Scale to apply to resulting view image.
  183. ScreenWidth int64 `json:"screenWidth,omitempty,omitzero"` // Overriding screen width value in pixels (minimum 0, maximum 10000000).
  184. ScreenHeight int64 `json:"screenHeight,omitempty,omitzero"` // Overriding screen height value in pixels (minimum 0, maximum 10000000).
  185. PositionX int64 `json:"positionX,omitempty,omitzero"` // Overriding view X position on screen in pixels (minimum 0, maximum 10000000).
  186. PositionY int64 `json:"positionY,omitempty,omitzero"` // Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
  187. DontSetVisibleSize bool `json:"dontSetVisibleSize"` // Do not set visible view size, rely upon explicit setVisibleSize call.
  188. ScreenOrientation *ScreenOrientation `json:"screenOrientation,omitempty,omitzero"` // Screen orientation override.
  189. Viewport *page.Viewport `json:"viewport,omitempty,omitzero"` // If 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.
  190. }
  191. // SetDeviceMetricsOverride overrides the values of device screen dimensions
  192. // (window.screen.width, window.screen.height, window.innerWidth,
  193. // window.innerHeight, and "device-width"/"device-height"-related CSS media
  194. // query results).
  195. //
  196. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setDeviceMetricsOverride
  197. //
  198. // parameters:
  199. //
  200. // width - Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
  201. // height - Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
  202. // deviceScaleFactor - Overriding device scale factor value. 0 disables the override.
  203. // mobile - Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
  204. func SetDeviceMetricsOverride(width int64, height int64, deviceScaleFactor float64, mobile bool) *SetDeviceMetricsOverrideParams {
  205. return &SetDeviceMetricsOverrideParams{
  206. Width: width,
  207. Height: height,
  208. DeviceScaleFactor: deviceScaleFactor,
  209. Mobile: mobile,
  210. DontSetVisibleSize: false,
  211. }
  212. }
  213. // WithScale scale to apply to resulting view image.
  214. func (p SetDeviceMetricsOverrideParams) WithScale(scale float64) *SetDeviceMetricsOverrideParams {
  215. p.Scale = scale
  216. return &p
  217. }
  218. // WithScreenWidth overriding screen width value in pixels (minimum 0,
  219. // maximum 10000000).
  220. func (p SetDeviceMetricsOverrideParams) WithScreenWidth(screenWidth int64) *SetDeviceMetricsOverrideParams {
  221. p.ScreenWidth = screenWidth
  222. return &p
  223. }
  224. // WithScreenHeight overriding screen height value in pixels (minimum 0,
  225. // maximum 10000000).
  226. func (p SetDeviceMetricsOverrideParams) WithScreenHeight(screenHeight int64) *SetDeviceMetricsOverrideParams {
  227. p.ScreenHeight = screenHeight
  228. return &p
  229. }
  230. // WithPositionX overriding view X position on screen in pixels (minimum 0,
  231. // maximum 10000000).
  232. func (p SetDeviceMetricsOverrideParams) WithPositionX(positionX int64) *SetDeviceMetricsOverrideParams {
  233. p.PositionX = positionX
  234. return &p
  235. }
  236. // WithPositionY overriding view Y position on screen in pixels (minimum 0,
  237. // maximum 10000000).
  238. func (p SetDeviceMetricsOverrideParams) WithPositionY(positionY int64) *SetDeviceMetricsOverrideParams {
  239. p.PositionY = positionY
  240. return &p
  241. }
  242. // WithDontSetVisibleSize do not set visible view size, rely upon explicit
  243. // setVisibleSize call.
  244. func (p SetDeviceMetricsOverrideParams) WithDontSetVisibleSize(dontSetVisibleSize bool) *SetDeviceMetricsOverrideParams {
  245. p.DontSetVisibleSize = dontSetVisibleSize
  246. return &p
  247. }
  248. // WithScreenOrientation screen orientation override.
  249. func (p SetDeviceMetricsOverrideParams) WithScreenOrientation(screenOrientation *ScreenOrientation) *SetDeviceMetricsOverrideParams {
  250. p.ScreenOrientation = screenOrientation
  251. return &p
  252. }
  253. // WithViewport if set, the visible area of the page will be overridden to
  254. // this viewport. This viewport change is not observed by the page, e.g.
  255. // viewport-relative elements do not change positions.
  256. func (p SetDeviceMetricsOverrideParams) WithViewport(viewport *page.Viewport) *SetDeviceMetricsOverrideParams {
  257. p.Viewport = viewport
  258. return &p
  259. }
  260. // Do executes Emulation.setDeviceMetricsOverride against the provided context.
  261. func (p *SetDeviceMetricsOverrideParams) Do(ctx context.Context) (err error) {
  262. return cdp.Execute(ctx, CommandSetDeviceMetricsOverride, p, nil)
  263. }
  264. // SetDevicePostureOverrideParams start reporting the given posture value to
  265. // the Device Posture API. This override can also be set in
  266. // setDeviceMetricsOverride().
  267. type SetDevicePostureOverrideParams struct {
  268. Posture *DevicePosture `json:"posture"`
  269. }
  270. // SetDevicePostureOverride start reporting the given posture value to the
  271. // Device Posture API. This override can also be set in
  272. // setDeviceMetricsOverride().
  273. //
  274. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setDevicePostureOverride
  275. //
  276. // parameters:
  277. //
  278. // posture
  279. func SetDevicePostureOverride(posture *DevicePosture) *SetDevicePostureOverrideParams {
  280. return &SetDevicePostureOverrideParams{
  281. Posture: posture,
  282. }
  283. }
  284. // Do executes Emulation.setDevicePostureOverride against the provided context.
  285. func (p *SetDevicePostureOverrideParams) Do(ctx context.Context) (err error) {
  286. return cdp.Execute(ctx, CommandSetDevicePostureOverride, p, nil)
  287. }
  288. // ClearDevicePostureOverrideParams clears a device posture override set with
  289. // either setDeviceMetricsOverride() or setDevicePostureOverride() and starts
  290. // using posture information from the platform again. Does nothing if no
  291. // override is set.
  292. type ClearDevicePostureOverrideParams struct{}
  293. // ClearDevicePostureOverride clears a device posture override set with
  294. // either setDeviceMetricsOverride() or setDevicePostureOverride() and starts
  295. // using posture information from the platform again. Does nothing if no
  296. // override is set.
  297. //
  298. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-clearDevicePostureOverride
  299. func ClearDevicePostureOverride() *ClearDevicePostureOverrideParams {
  300. return &ClearDevicePostureOverrideParams{}
  301. }
  302. // Do executes Emulation.clearDevicePostureOverride against the provided context.
  303. func (p *ClearDevicePostureOverrideParams) Do(ctx context.Context) (err error) {
  304. return cdp.Execute(ctx, CommandClearDevicePostureOverride, nil, nil)
  305. }
  306. // SetDisplayFeaturesOverrideParams start using the given display features to
  307. // pupulate the Viewport Segments API. This override can also be set in
  308. // setDeviceMetricsOverride().
  309. type SetDisplayFeaturesOverrideParams struct {
  310. Features []*DisplayFeature `json:"features"`
  311. }
  312. // SetDisplayFeaturesOverride start using the given display features to
  313. // pupulate the Viewport Segments API. This override can also be set in
  314. // setDeviceMetricsOverride().
  315. //
  316. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setDisplayFeaturesOverride
  317. //
  318. // parameters:
  319. //
  320. // features
  321. func SetDisplayFeaturesOverride(features []*DisplayFeature) *SetDisplayFeaturesOverrideParams {
  322. return &SetDisplayFeaturesOverrideParams{
  323. Features: features,
  324. }
  325. }
  326. // Do executes Emulation.setDisplayFeaturesOverride against the provided context.
  327. func (p *SetDisplayFeaturesOverrideParams) Do(ctx context.Context) (err error) {
  328. return cdp.Execute(ctx, CommandSetDisplayFeaturesOverride, p, nil)
  329. }
  330. // ClearDisplayFeaturesOverrideParams clears the display features override
  331. // set with either setDeviceMetricsOverride() or setDisplayFeaturesOverride()
  332. // and starts using display features from the platform again. Does nothing if no
  333. // override is set.
  334. type ClearDisplayFeaturesOverrideParams struct{}
  335. // ClearDisplayFeaturesOverride clears the display features override set with
  336. // either setDeviceMetricsOverride() or setDisplayFeaturesOverride() and starts
  337. // using display features from the platform again. Does nothing if no override
  338. // is set.
  339. //
  340. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-clearDisplayFeaturesOverride
  341. func ClearDisplayFeaturesOverride() *ClearDisplayFeaturesOverrideParams {
  342. return &ClearDisplayFeaturesOverrideParams{}
  343. }
  344. // Do executes Emulation.clearDisplayFeaturesOverride against the provided context.
  345. func (p *ClearDisplayFeaturesOverrideParams) Do(ctx context.Context) (err error) {
  346. return cdp.Execute(ctx, CommandClearDisplayFeaturesOverride, nil, nil)
  347. }
  348. // SetScrollbarsHiddenParams [no description].
  349. type SetScrollbarsHiddenParams struct {
  350. Hidden bool `json:"hidden"` // Whether scrollbars should be always hidden.
  351. }
  352. // SetScrollbarsHidden [no description].
  353. //
  354. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setScrollbarsHidden
  355. //
  356. // parameters:
  357. //
  358. // hidden - Whether scrollbars should be always hidden.
  359. func SetScrollbarsHidden(hidden bool) *SetScrollbarsHiddenParams {
  360. return &SetScrollbarsHiddenParams{
  361. Hidden: hidden,
  362. }
  363. }
  364. // Do executes Emulation.setScrollbarsHidden against the provided context.
  365. func (p *SetScrollbarsHiddenParams) Do(ctx context.Context) (err error) {
  366. return cdp.Execute(ctx, CommandSetScrollbarsHidden, p, nil)
  367. }
  368. // SetDocumentCookieDisabledParams [no description].
  369. type SetDocumentCookieDisabledParams struct {
  370. Disabled bool `json:"disabled"` // Whether document.coookie API should be disabled.
  371. }
  372. // SetDocumentCookieDisabled [no description].
  373. //
  374. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setDocumentCookieDisabled
  375. //
  376. // parameters:
  377. //
  378. // disabled - Whether document.coookie API should be disabled.
  379. func SetDocumentCookieDisabled(disabled bool) *SetDocumentCookieDisabledParams {
  380. return &SetDocumentCookieDisabledParams{
  381. Disabled: disabled,
  382. }
  383. }
  384. // Do executes Emulation.setDocumentCookieDisabled against the provided context.
  385. func (p *SetDocumentCookieDisabledParams) Do(ctx context.Context) (err error) {
  386. return cdp.Execute(ctx, CommandSetDocumentCookieDisabled, p, nil)
  387. }
  388. // SetEmitTouchEventsForMouseParams [no description].
  389. type SetEmitTouchEventsForMouseParams struct {
  390. Enabled bool `json:"enabled"` // Whether touch emulation based on mouse input should be enabled.
  391. Configuration SetEmitTouchEventsForMouseConfiguration `json:"configuration,omitempty,omitzero"` // Touch/gesture events configuration. Default: current platform.
  392. }
  393. // SetEmitTouchEventsForMouse [no description].
  394. //
  395. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setEmitTouchEventsForMouse
  396. //
  397. // parameters:
  398. //
  399. // enabled - Whether touch emulation based on mouse input should be enabled.
  400. func SetEmitTouchEventsForMouse(enabled bool) *SetEmitTouchEventsForMouseParams {
  401. return &SetEmitTouchEventsForMouseParams{
  402. Enabled: enabled,
  403. }
  404. }
  405. // WithConfiguration touch/gesture events configuration. Default: current
  406. // platform.
  407. func (p SetEmitTouchEventsForMouseParams) WithConfiguration(configuration SetEmitTouchEventsForMouseConfiguration) *SetEmitTouchEventsForMouseParams {
  408. p.Configuration = configuration
  409. return &p
  410. }
  411. // Do executes Emulation.setEmitTouchEventsForMouse against the provided context.
  412. func (p *SetEmitTouchEventsForMouseParams) Do(ctx context.Context) (err error) {
  413. return cdp.Execute(ctx, CommandSetEmitTouchEventsForMouse, p, nil)
  414. }
  415. // SetEmulatedMediaParams emulates the given media type or media feature for
  416. // CSS media queries.
  417. type SetEmulatedMediaParams struct {
  418. Media string `json:"media,omitempty,omitzero"` // Media type to emulate. Empty string disables the override.
  419. Features []*MediaFeature `json:"features,omitempty,omitzero"` // Media features to emulate.
  420. }
  421. // SetEmulatedMedia emulates the given media type or media feature for CSS
  422. // media queries.
  423. //
  424. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setEmulatedMedia
  425. //
  426. // parameters:
  427. func SetEmulatedMedia() *SetEmulatedMediaParams {
  428. return &SetEmulatedMediaParams{}
  429. }
  430. // WithMedia media type to emulate. Empty string disables the override.
  431. func (p SetEmulatedMediaParams) WithMedia(media string) *SetEmulatedMediaParams {
  432. p.Media = media
  433. return &p
  434. }
  435. // WithFeatures media features to emulate.
  436. func (p SetEmulatedMediaParams) WithFeatures(features []*MediaFeature) *SetEmulatedMediaParams {
  437. p.Features = features
  438. return &p
  439. }
  440. // Do executes Emulation.setEmulatedMedia against the provided context.
  441. func (p *SetEmulatedMediaParams) Do(ctx context.Context) (err error) {
  442. return cdp.Execute(ctx, CommandSetEmulatedMedia, p, nil)
  443. }
  444. // SetEmulatedVisionDeficiencyParams emulates the given vision deficiency.
  445. type SetEmulatedVisionDeficiencyParams struct {
  446. Type SetEmulatedVisionDeficiencyType `json:"type"` // Vision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies.
  447. }
  448. // SetEmulatedVisionDeficiency emulates the given vision deficiency.
  449. //
  450. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setEmulatedVisionDeficiency
  451. //
  452. // parameters:
  453. //
  454. // type - Vision deficiency to emulate. Order: best-effort emulations come first, followed by any physiologically accurate emulations for medically recognized color vision deficiencies.
  455. func SetEmulatedVisionDeficiency(typeVal SetEmulatedVisionDeficiencyType) *SetEmulatedVisionDeficiencyParams {
  456. return &SetEmulatedVisionDeficiencyParams{
  457. Type: typeVal,
  458. }
  459. }
  460. // Do executes Emulation.setEmulatedVisionDeficiency against the provided context.
  461. func (p *SetEmulatedVisionDeficiencyParams) Do(ctx context.Context) (err error) {
  462. return cdp.Execute(ctx, CommandSetEmulatedVisionDeficiency, p, nil)
  463. }
  464. // SetGeolocationOverrideParams overrides the Geolocation Position or Error.
  465. // Omitting any of the parameters emulates position unavailable.
  466. type SetGeolocationOverrideParams struct {
  467. Latitude float64 `json:"latitude,omitempty,omitzero"` // Mock latitude
  468. Longitude float64 `json:"longitude,omitempty,omitzero"` // Mock longitude
  469. Accuracy float64 `json:"accuracy,omitempty,omitzero"` // Mock accuracy
  470. }
  471. // SetGeolocationOverride overrides the Geolocation Position or Error.
  472. // Omitting any of the parameters emulates position unavailable.
  473. //
  474. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setGeolocationOverride
  475. //
  476. // parameters:
  477. func SetGeolocationOverride() *SetGeolocationOverrideParams {
  478. return &SetGeolocationOverrideParams{}
  479. }
  480. // WithLatitude mock latitude.
  481. func (p SetGeolocationOverrideParams) WithLatitude(latitude float64) *SetGeolocationOverrideParams {
  482. p.Latitude = latitude
  483. return &p
  484. }
  485. // WithLongitude mock longitude.
  486. func (p SetGeolocationOverrideParams) WithLongitude(longitude float64) *SetGeolocationOverrideParams {
  487. p.Longitude = longitude
  488. return &p
  489. }
  490. // WithAccuracy mock accuracy.
  491. func (p SetGeolocationOverrideParams) WithAccuracy(accuracy float64) *SetGeolocationOverrideParams {
  492. p.Accuracy = accuracy
  493. return &p
  494. }
  495. // Do executes Emulation.setGeolocationOverride against the provided context.
  496. func (p *SetGeolocationOverrideParams) Do(ctx context.Context) (err error) {
  497. return cdp.Execute(ctx, CommandSetGeolocationOverride, p, nil)
  498. }
  499. // GetOverriddenSensorInformationParams [no description].
  500. type GetOverriddenSensorInformationParams struct {
  501. Type SensorType `json:"type"`
  502. }
  503. // GetOverriddenSensorInformation [no description].
  504. //
  505. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-getOverriddenSensorInformation
  506. //
  507. // parameters:
  508. //
  509. // type
  510. func GetOverriddenSensorInformation(typeVal SensorType) *GetOverriddenSensorInformationParams {
  511. return &GetOverriddenSensorInformationParams{
  512. Type: typeVal,
  513. }
  514. }
  515. // GetOverriddenSensorInformationReturns return values.
  516. type GetOverriddenSensorInformationReturns struct {
  517. RequestedSamplingFrequency float64 `json:"requestedSamplingFrequency,omitempty,omitzero"`
  518. }
  519. // Do executes Emulation.getOverriddenSensorInformation against the provided context.
  520. //
  521. // returns:
  522. //
  523. // requestedSamplingFrequency
  524. func (p *GetOverriddenSensorInformationParams) Do(ctx context.Context) (requestedSamplingFrequency float64, err error) {
  525. // execute
  526. var res GetOverriddenSensorInformationReturns
  527. err = cdp.Execute(ctx, CommandGetOverriddenSensorInformation, p, &res)
  528. if err != nil {
  529. return 0, err
  530. }
  531. return res.RequestedSamplingFrequency, nil
  532. }
  533. // SetSensorOverrideEnabledParams overrides a platform sensor of a given
  534. // type. If |enabled| is true, calls to Sensor.start() will use a virtual sensor
  535. // as backend rather than fetching data from a real hardware sensor. Otherwise,
  536. // existing virtual sensor-backend Sensor objects will fire an error event and
  537. // new calls to Sensor.start() will attempt to use a real sensor instead.
  538. type SetSensorOverrideEnabledParams struct {
  539. Enabled bool `json:"enabled"`
  540. Type SensorType `json:"type"`
  541. Metadata *SensorMetadata `json:"metadata,omitempty,omitzero"`
  542. }
  543. // SetSensorOverrideEnabled overrides a platform sensor of a given type. If
  544. // |enabled| is true, calls to Sensor.start() will use a virtual sensor as
  545. // backend rather than fetching data from a real hardware sensor. Otherwise,
  546. // existing virtual sensor-backend Sensor objects will fire an error event and
  547. // new calls to Sensor.start() will attempt to use a real sensor instead.
  548. //
  549. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setSensorOverrideEnabled
  550. //
  551. // parameters:
  552. //
  553. // enabled
  554. // type
  555. func SetSensorOverrideEnabled(enabled bool, typeVal SensorType) *SetSensorOverrideEnabledParams {
  556. return &SetSensorOverrideEnabledParams{
  557. Enabled: enabled,
  558. Type: typeVal,
  559. }
  560. }
  561. // WithMetadata [no description].
  562. func (p SetSensorOverrideEnabledParams) WithMetadata(metadata *SensorMetadata) *SetSensorOverrideEnabledParams {
  563. p.Metadata = metadata
  564. return &p
  565. }
  566. // Do executes Emulation.setSensorOverrideEnabled against the provided context.
  567. func (p *SetSensorOverrideEnabledParams) Do(ctx context.Context) (err error) {
  568. return cdp.Execute(ctx, CommandSetSensorOverrideEnabled, p, nil)
  569. }
  570. // SetSensorOverrideReadingsParams updates the sensor readings reported by a
  571. // sensor type previously overridden by setSensorOverrideEnabled.
  572. type SetSensorOverrideReadingsParams struct {
  573. Type SensorType `json:"type"`
  574. Reading *SensorReading `json:"reading"`
  575. }
  576. // SetSensorOverrideReadings updates the sensor readings reported by a sensor
  577. // type previously overridden by setSensorOverrideEnabled.
  578. //
  579. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setSensorOverrideReadings
  580. //
  581. // parameters:
  582. //
  583. // type
  584. // reading
  585. func SetSensorOverrideReadings(typeVal SensorType, reading *SensorReading) *SetSensorOverrideReadingsParams {
  586. return &SetSensorOverrideReadingsParams{
  587. Type: typeVal,
  588. Reading: reading,
  589. }
  590. }
  591. // Do executes Emulation.setSensorOverrideReadings against the provided context.
  592. func (p *SetSensorOverrideReadingsParams) Do(ctx context.Context) (err error) {
  593. return cdp.Execute(ctx, CommandSetSensorOverrideReadings, p, nil)
  594. }
  595. // SetPressureSourceOverrideEnabledParams overrides a pressure source of a
  596. // given type, as used by the Compute Pressure API, so that updates to
  597. // PressureObserver.observe() are provided via setPressureStateOverride instead
  598. // of being retrieved from platform-provided telemetry data.
  599. type SetPressureSourceOverrideEnabledParams struct {
  600. Enabled bool `json:"enabled"`
  601. Source PressureSource `json:"source"`
  602. Metadata *PressureMetadata `json:"metadata,omitempty,omitzero"`
  603. }
  604. // SetPressureSourceOverrideEnabled overrides a pressure source of a given
  605. // type, as used by the Compute Pressure API, so that updates to
  606. // PressureObserver.observe() are provided via setPressureStateOverride instead
  607. // of being retrieved from platform-provided telemetry data.
  608. //
  609. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setPressureSourceOverrideEnabled
  610. //
  611. // parameters:
  612. //
  613. // enabled
  614. // source
  615. func SetPressureSourceOverrideEnabled(enabled bool, source PressureSource) *SetPressureSourceOverrideEnabledParams {
  616. return &SetPressureSourceOverrideEnabledParams{
  617. Enabled: enabled,
  618. Source: source,
  619. }
  620. }
  621. // WithMetadata [no description].
  622. func (p SetPressureSourceOverrideEnabledParams) WithMetadata(metadata *PressureMetadata) *SetPressureSourceOverrideEnabledParams {
  623. p.Metadata = metadata
  624. return &p
  625. }
  626. // Do executes Emulation.setPressureSourceOverrideEnabled against the provided context.
  627. func (p *SetPressureSourceOverrideEnabledParams) Do(ctx context.Context) (err error) {
  628. return cdp.Execute(ctx, CommandSetPressureSourceOverrideEnabled, p, nil)
  629. }
  630. // SetPressureStateOverrideParams provides a given pressure state that will
  631. // be processed and eventually be delivered to PressureObserver users. |source|
  632. // must have been previously overridden by setPressureSourceOverrideEnabled.
  633. type SetPressureStateOverrideParams struct {
  634. Source PressureSource `json:"source"`
  635. State PressureState `json:"state"`
  636. }
  637. // SetPressureStateOverride provides a given pressure state that will be
  638. // processed and eventually be delivered to PressureObserver users. |source|
  639. // must have been previously overridden by setPressureSourceOverrideEnabled.
  640. //
  641. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setPressureStateOverride
  642. //
  643. // parameters:
  644. //
  645. // source
  646. // state
  647. func SetPressureStateOverride(source PressureSource, state PressureState) *SetPressureStateOverrideParams {
  648. return &SetPressureStateOverrideParams{
  649. Source: source,
  650. State: state,
  651. }
  652. }
  653. // Do executes Emulation.setPressureStateOverride against the provided context.
  654. func (p *SetPressureStateOverrideParams) Do(ctx context.Context) (err error) {
  655. return cdp.Execute(ctx, CommandSetPressureStateOverride, p, nil)
  656. }
  657. // SetIdleOverrideParams overrides the Idle state.
  658. type SetIdleOverrideParams struct {
  659. IsUserActive bool `json:"isUserActive"` // Mock isUserActive
  660. IsScreenUnlocked bool `json:"isScreenUnlocked"` // Mock isScreenUnlocked
  661. }
  662. // SetIdleOverride overrides the Idle state.
  663. //
  664. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setIdleOverride
  665. //
  666. // parameters:
  667. //
  668. // isUserActive - Mock isUserActive
  669. // isScreenUnlocked - Mock isScreenUnlocked
  670. func SetIdleOverride(isUserActive bool, isScreenUnlocked bool) *SetIdleOverrideParams {
  671. return &SetIdleOverrideParams{
  672. IsUserActive: isUserActive,
  673. IsScreenUnlocked: isScreenUnlocked,
  674. }
  675. }
  676. // Do executes Emulation.setIdleOverride against the provided context.
  677. func (p *SetIdleOverrideParams) Do(ctx context.Context) (err error) {
  678. return cdp.Execute(ctx, CommandSetIdleOverride, p, nil)
  679. }
  680. // ClearIdleOverrideParams clears Idle state overrides.
  681. type ClearIdleOverrideParams struct{}
  682. // ClearIdleOverride clears Idle state overrides.
  683. //
  684. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-clearIdleOverride
  685. func ClearIdleOverride() *ClearIdleOverrideParams {
  686. return &ClearIdleOverrideParams{}
  687. }
  688. // Do executes Emulation.clearIdleOverride against the provided context.
  689. func (p *ClearIdleOverrideParams) Do(ctx context.Context) (err error) {
  690. return cdp.Execute(ctx, CommandClearIdleOverride, nil, nil)
  691. }
  692. // SetPageScaleFactorParams sets a specified page scale factor.
  693. type SetPageScaleFactorParams struct {
  694. PageScaleFactor float64 `json:"pageScaleFactor"` // Page scale factor.
  695. }
  696. // SetPageScaleFactor sets a specified page scale factor.
  697. //
  698. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setPageScaleFactor
  699. //
  700. // parameters:
  701. //
  702. // pageScaleFactor - Page scale factor.
  703. func SetPageScaleFactor(pageScaleFactor float64) *SetPageScaleFactorParams {
  704. return &SetPageScaleFactorParams{
  705. PageScaleFactor: pageScaleFactor,
  706. }
  707. }
  708. // Do executes Emulation.setPageScaleFactor against the provided context.
  709. func (p *SetPageScaleFactorParams) Do(ctx context.Context) (err error) {
  710. return cdp.Execute(ctx, CommandSetPageScaleFactor, p, nil)
  711. }
  712. // SetScriptExecutionDisabledParams switches script execution in the page.
  713. type SetScriptExecutionDisabledParams struct {
  714. Value bool `json:"value"` // Whether script execution should be disabled in the page.
  715. }
  716. // SetScriptExecutionDisabled switches script execution in the page.
  717. //
  718. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setScriptExecutionDisabled
  719. //
  720. // parameters:
  721. //
  722. // value - Whether script execution should be disabled in the page.
  723. func SetScriptExecutionDisabled(value bool) *SetScriptExecutionDisabledParams {
  724. return &SetScriptExecutionDisabledParams{
  725. Value: value,
  726. }
  727. }
  728. // Do executes Emulation.setScriptExecutionDisabled against the provided context.
  729. func (p *SetScriptExecutionDisabledParams) Do(ctx context.Context) (err error) {
  730. return cdp.Execute(ctx, CommandSetScriptExecutionDisabled, p, nil)
  731. }
  732. // SetTouchEmulationEnabledParams enables touch on platforms which do not
  733. // support them.
  734. type SetTouchEmulationEnabledParams struct {
  735. Enabled bool `json:"enabled"` // Whether the touch event emulation should be enabled.
  736. MaxTouchPoints int64 `json:"maxTouchPoints,omitempty,omitzero"` // Maximum touch points supported. Defaults to one.
  737. }
  738. // SetTouchEmulationEnabled enables touch on platforms which do not support
  739. // them.
  740. //
  741. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setTouchEmulationEnabled
  742. //
  743. // parameters:
  744. //
  745. // enabled - Whether the touch event emulation should be enabled.
  746. func SetTouchEmulationEnabled(enabled bool) *SetTouchEmulationEnabledParams {
  747. return &SetTouchEmulationEnabledParams{
  748. Enabled: enabled,
  749. }
  750. }
  751. // WithMaxTouchPoints maximum touch points supported. Defaults to one.
  752. func (p SetTouchEmulationEnabledParams) WithMaxTouchPoints(maxTouchPoints int64) *SetTouchEmulationEnabledParams {
  753. p.MaxTouchPoints = maxTouchPoints
  754. return &p
  755. }
  756. // Do executes Emulation.setTouchEmulationEnabled against the provided context.
  757. func (p *SetTouchEmulationEnabledParams) Do(ctx context.Context) (err error) {
  758. return cdp.Execute(ctx, CommandSetTouchEmulationEnabled, p, nil)
  759. }
  760. // SetVirtualTimePolicyParams turns on virtual time for all frames (replacing
  761. // real-time with a synthetic time source) and sets the current virtual time
  762. // policy. Note this supersedes any previous time budget.
  763. type SetVirtualTimePolicyParams struct {
  764. Policy VirtualTimePolicy `json:"policy"`
  765. Budget float64 `json:"budget,omitempty,omitzero"` // If set, after this many virtual milliseconds have elapsed virtual time will be paused and a virtualTimeBudgetExpired event is sent.
  766. MaxVirtualTimeTaskStarvationCount int64 `json:"maxVirtualTimeTaskStarvationCount,omitempty,omitzero"` // If set this specifies the maximum number of tasks that can be run before virtual is forced forwards to prevent deadlock.
  767. InitialVirtualTime *cdp.TimeSinceEpoch `json:"initialVirtualTime,omitempty,omitzero"` // If set, base::Time::Now will be overridden to initially return this value.
  768. }
  769. // SetVirtualTimePolicy turns on virtual time for all frames (replacing
  770. // real-time with a synthetic time source) and sets the current virtual time
  771. // policy. Note this supersedes any previous time budget.
  772. //
  773. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setVirtualTimePolicy
  774. //
  775. // parameters:
  776. //
  777. // policy
  778. func SetVirtualTimePolicy(policy VirtualTimePolicy) *SetVirtualTimePolicyParams {
  779. return &SetVirtualTimePolicyParams{
  780. Policy: policy,
  781. }
  782. }
  783. // WithBudget if set, after this many virtual milliseconds have elapsed
  784. // virtual time will be paused and a virtualTimeBudgetExpired event is sent.
  785. func (p SetVirtualTimePolicyParams) WithBudget(budget float64) *SetVirtualTimePolicyParams {
  786. p.Budget = budget
  787. return &p
  788. }
  789. // WithMaxVirtualTimeTaskStarvationCount if set this specifies the maximum
  790. // number of tasks that can be run before virtual is forced forwards to prevent
  791. // deadlock.
  792. func (p SetVirtualTimePolicyParams) WithMaxVirtualTimeTaskStarvationCount(maxVirtualTimeTaskStarvationCount int64) *SetVirtualTimePolicyParams {
  793. p.MaxVirtualTimeTaskStarvationCount = maxVirtualTimeTaskStarvationCount
  794. return &p
  795. }
  796. // WithInitialVirtualTime if set, base::Time::Now will be overridden to
  797. // initially return this value.
  798. func (p SetVirtualTimePolicyParams) WithInitialVirtualTime(initialVirtualTime *cdp.TimeSinceEpoch) *SetVirtualTimePolicyParams {
  799. p.InitialVirtualTime = initialVirtualTime
  800. return &p
  801. }
  802. // SetVirtualTimePolicyReturns return values.
  803. type SetVirtualTimePolicyReturns struct {
  804. VirtualTimeTicksBase float64 `json:"virtualTimeTicksBase,omitempty,omitzero"` // Absolute timestamp at which virtual time was first enabled (up time in milliseconds).
  805. }
  806. // Do executes Emulation.setVirtualTimePolicy against the provided context.
  807. //
  808. // returns:
  809. //
  810. // virtualTimeTicksBase - Absolute timestamp at which virtual time was first enabled (up time in milliseconds).
  811. func (p *SetVirtualTimePolicyParams) Do(ctx context.Context) (virtualTimeTicksBase float64, err error) {
  812. // execute
  813. var res SetVirtualTimePolicyReturns
  814. err = cdp.Execute(ctx, CommandSetVirtualTimePolicy, p, &res)
  815. if err != nil {
  816. return 0, err
  817. }
  818. return res.VirtualTimeTicksBase, nil
  819. }
  820. // SetLocaleOverrideParams overrides default host system locale with the
  821. // specified one.
  822. type SetLocaleOverrideParams struct {
  823. Locale string `json:"locale,omitempty,omitzero"` // ICU style C locale (e.g. "en_US"). If not specified or empty, disables the override and restores default host system locale.
  824. }
  825. // SetLocaleOverride overrides default host system locale with the specified
  826. // one.
  827. //
  828. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setLocaleOverride
  829. //
  830. // parameters:
  831. func SetLocaleOverride() *SetLocaleOverrideParams {
  832. return &SetLocaleOverrideParams{}
  833. }
  834. // WithLocale iCU style C locale (e.g. "en_US"). If not specified or empty,
  835. // disables the override and restores default host system locale.
  836. func (p SetLocaleOverrideParams) WithLocale(locale string) *SetLocaleOverrideParams {
  837. p.Locale = locale
  838. return &p
  839. }
  840. // Do executes Emulation.setLocaleOverride against the provided context.
  841. func (p *SetLocaleOverrideParams) Do(ctx context.Context) (err error) {
  842. return cdp.Execute(ctx, CommandSetLocaleOverride, p, nil)
  843. }
  844. // SetTimezoneOverrideParams overrides default host system timezone with the
  845. // specified one.
  846. type SetTimezoneOverrideParams struct {
  847. TimezoneID string `json:"timezoneId"` // The 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.
  848. }
  849. // SetTimezoneOverride overrides default host system timezone with the
  850. // specified one.
  851. //
  852. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setTimezoneOverride
  853. //
  854. // parameters:
  855. //
  856. // timezoneID - The 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.
  857. func SetTimezoneOverride(timezoneID string) *SetTimezoneOverrideParams {
  858. return &SetTimezoneOverrideParams{
  859. TimezoneID: timezoneID,
  860. }
  861. }
  862. // Do executes Emulation.setTimezoneOverride against the provided context.
  863. func (p *SetTimezoneOverrideParams) Do(ctx context.Context) (err error) {
  864. return cdp.Execute(ctx, CommandSetTimezoneOverride, p, nil)
  865. }
  866. // SetDisabledImageTypesParams [no description].
  867. type SetDisabledImageTypesParams struct {
  868. ImageTypes []DisabledImageType `json:"imageTypes"` // Image types to disable.
  869. }
  870. // SetDisabledImageTypes [no description].
  871. //
  872. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setDisabledImageTypes
  873. //
  874. // parameters:
  875. //
  876. // imageTypes - Image types to disable.
  877. func SetDisabledImageTypes(imageTypes []DisabledImageType) *SetDisabledImageTypesParams {
  878. return &SetDisabledImageTypesParams{
  879. ImageTypes: imageTypes,
  880. }
  881. }
  882. // Do executes Emulation.setDisabledImageTypes against the provided context.
  883. func (p *SetDisabledImageTypesParams) Do(ctx context.Context) (err error) {
  884. return cdp.Execute(ctx, CommandSetDisabledImageTypes, p, nil)
  885. }
  886. // SetHardwareConcurrencyOverrideParams [no description].
  887. type SetHardwareConcurrencyOverrideParams struct {
  888. HardwareConcurrency int64 `json:"hardwareConcurrency"` // Hardware concurrency to report
  889. }
  890. // SetHardwareConcurrencyOverride [no description].
  891. //
  892. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setHardwareConcurrencyOverride
  893. //
  894. // parameters:
  895. //
  896. // hardwareConcurrency - Hardware concurrency to report
  897. func SetHardwareConcurrencyOverride(hardwareConcurrency int64) *SetHardwareConcurrencyOverrideParams {
  898. return &SetHardwareConcurrencyOverrideParams{
  899. HardwareConcurrency: hardwareConcurrency,
  900. }
  901. }
  902. // Do executes Emulation.setHardwareConcurrencyOverride against the provided context.
  903. func (p *SetHardwareConcurrencyOverrideParams) Do(ctx context.Context) (err error) {
  904. return cdp.Execute(ctx, CommandSetHardwareConcurrencyOverride, p, nil)
  905. }
  906. // SetUserAgentOverrideParams allows overriding user agent with the given
  907. // string. userAgentMetadata must be set for Client Hint headers to be sent.
  908. type SetUserAgentOverrideParams struct {
  909. UserAgent string `json:"userAgent"` // User agent to use.
  910. AcceptLanguage string `json:"acceptLanguage,omitempty,omitzero"` // Browser language to emulate.
  911. Platform string `json:"platform,omitempty,omitzero"` // The platform navigator.platform should return.
  912. UserAgentMetadata *UserAgentMetadata `json:"userAgentMetadata,omitempty,omitzero"` // To be sent in Sec-CH-UA-* headers and returned in navigator.userAgentData
  913. }
  914. // SetUserAgentOverride allows overriding user agent with the given string.
  915. // userAgentMetadata must be set for Client Hint headers to be sent.
  916. //
  917. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setUserAgentOverride
  918. //
  919. // parameters:
  920. //
  921. // userAgent - User agent to use.
  922. func SetUserAgentOverride(userAgent string) *SetUserAgentOverrideParams {
  923. return &SetUserAgentOverrideParams{
  924. UserAgent: userAgent,
  925. }
  926. }
  927. // WithAcceptLanguage browser language to emulate.
  928. func (p SetUserAgentOverrideParams) WithAcceptLanguage(acceptLanguage string) *SetUserAgentOverrideParams {
  929. p.AcceptLanguage = acceptLanguage
  930. return &p
  931. }
  932. // WithPlatform the platform navigator.platform should return.
  933. func (p SetUserAgentOverrideParams) WithPlatform(platform string) *SetUserAgentOverrideParams {
  934. p.Platform = platform
  935. return &p
  936. }
  937. // WithUserAgentMetadata to be sent in Sec-CH-UA-* headers and returned in
  938. // navigator.userAgentData.
  939. func (p SetUserAgentOverrideParams) WithUserAgentMetadata(userAgentMetadata *UserAgentMetadata) *SetUserAgentOverrideParams {
  940. p.UserAgentMetadata = userAgentMetadata
  941. return &p
  942. }
  943. // Do executes Emulation.setUserAgentOverride against the provided context.
  944. func (p *SetUserAgentOverrideParams) Do(ctx context.Context) (err error) {
  945. return cdp.Execute(ctx, CommandSetUserAgentOverride, p, nil)
  946. }
  947. // SetAutomationOverrideParams allows overriding the automation flag.
  948. type SetAutomationOverrideParams struct {
  949. Enabled bool `json:"enabled"` // Whether the override should be enabled.
  950. }
  951. // SetAutomationOverride allows overriding the automation flag.
  952. //
  953. // See: https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setAutomationOverride
  954. //
  955. // parameters:
  956. //
  957. // enabled - Whether the override should be enabled.
  958. func SetAutomationOverride(enabled bool) *SetAutomationOverrideParams {
  959. return &SetAutomationOverrideParams{
  960. Enabled: enabled,
  961. }
  962. }
  963. // Do executes Emulation.setAutomationOverride against the provided context.
  964. func (p *SetAutomationOverrideParams) Do(ctx context.Context) (err error) {
  965. return cdp.Execute(ctx, CommandSetAutomationOverride, p, nil)
  966. }
  967. // Command names.
  968. const (
  969. CommandClearDeviceMetricsOverride = "Emulation.clearDeviceMetricsOverride"
  970. CommandClearGeolocationOverride = "Emulation.clearGeolocationOverride"
  971. CommandResetPageScaleFactor = "Emulation.resetPageScaleFactor"
  972. CommandSetFocusEmulationEnabled = "Emulation.setFocusEmulationEnabled"
  973. CommandSetAutoDarkModeOverride = "Emulation.setAutoDarkModeOverride"
  974. CommandSetCPUThrottlingRate = "Emulation.setCPUThrottlingRate"
  975. CommandSetDefaultBackgroundColorOverride = "Emulation.setDefaultBackgroundColorOverride"
  976. CommandSetSafeAreaInsetsOverride = "Emulation.setSafeAreaInsetsOverride"
  977. CommandSetDeviceMetricsOverride = "Emulation.setDeviceMetricsOverride"
  978. CommandSetDevicePostureOverride = "Emulation.setDevicePostureOverride"
  979. CommandClearDevicePostureOverride = "Emulation.clearDevicePostureOverride"
  980. CommandSetDisplayFeaturesOverride = "Emulation.setDisplayFeaturesOverride"
  981. CommandClearDisplayFeaturesOverride = "Emulation.clearDisplayFeaturesOverride"
  982. CommandSetScrollbarsHidden = "Emulation.setScrollbarsHidden"
  983. CommandSetDocumentCookieDisabled = "Emulation.setDocumentCookieDisabled"
  984. CommandSetEmitTouchEventsForMouse = "Emulation.setEmitTouchEventsForMouse"
  985. CommandSetEmulatedMedia = "Emulation.setEmulatedMedia"
  986. CommandSetEmulatedVisionDeficiency = "Emulation.setEmulatedVisionDeficiency"
  987. CommandSetGeolocationOverride = "Emulation.setGeolocationOverride"
  988. CommandGetOverriddenSensorInformation = "Emulation.getOverriddenSensorInformation"
  989. CommandSetSensorOverrideEnabled = "Emulation.setSensorOverrideEnabled"
  990. CommandSetSensorOverrideReadings = "Emulation.setSensorOverrideReadings"
  991. CommandSetPressureSourceOverrideEnabled = "Emulation.setPressureSourceOverrideEnabled"
  992. CommandSetPressureStateOverride = "Emulation.setPressureStateOverride"
  993. CommandSetIdleOverride = "Emulation.setIdleOverride"
  994. CommandClearIdleOverride = "Emulation.clearIdleOverride"
  995. CommandSetPageScaleFactor = "Emulation.setPageScaleFactor"
  996. CommandSetScriptExecutionDisabled = "Emulation.setScriptExecutionDisabled"
  997. CommandSetTouchEmulationEnabled = "Emulation.setTouchEmulationEnabled"
  998. CommandSetVirtualTimePolicy = "Emulation.setVirtualTimePolicy"
  999. CommandSetLocaleOverride = "Emulation.setLocaleOverride"
  1000. CommandSetTimezoneOverride = "Emulation.setTimezoneOverride"
  1001. CommandSetDisabledImageTypes = "Emulation.setDisabledImageTypes"
  1002. CommandSetHardwareConcurrencyOverride = "Emulation.setHardwareConcurrencyOverride"
  1003. CommandSetUserAgentOverride = "Emulation.setUserAgentOverride"
  1004. CommandSetAutomationOverride = "Emulation.setAutomationOverride"
  1005. )