mithwire 0.50.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. mithwire/__init__.py +32 -0
  2. mithwire/cdp/README.md +4 -0
  3. mithwire/cdp/__init__.py +6 -0
  4. mithwire/cdp/accessibility.py +668 -0
  5. mithwire/cdp/animation.py +494 -0
  6. mithwire/cdp/audits.py +1995 -0
  7. mithwire/cdp/autofill.py +292 -0
  8. mithwire/cdp/background_service.py +215 -0
  9. mithwire/cdp/bluetooth_emulation.py +626 -0
  10. mithwire/cdp/browser.py +821 -0
  11. mithwire/cdp/cache_storage.py +311 -0
  12. mithwire/cdp/cast.py +172 -0
  13. mithwire/cdp/console.py +107 -0
  14. mithwire/cdp/crash_report_context.py +55 -0
  15. mithwire/cdp/css.py +2750 -0
  16. mithwire/cdp/database.py +179 -0
  17. mithwire/cdp/debugger.py +1405 -0
  18. mithwire/cdp/device_access.py +141 -0
  19. mithwire/cdp/device_orientation.py +45 -0
  20. mithwire/cdp/dom.py +2257 -0
  21. mithwire/cdp/dom_debugger.py +321 -0
  22. mithwire/cdp/dom_snapshot.py +876 -0
  23. mithwire/cdp/dom_storage.py +222 -0
  24. mithwire/cdp/emulation.py +1779 -0
  25. mithwire/cdp/event_breakpoints.py +56 -0
  26. mithwire/cdp/extensions.py +238 -0
  27. mithwire/cdp/fed_cm.py +283 -0
  28. mithwire/cdp/fetch.py +507 -0
  29. mithwire/cdp/file_system.py +115 -0
  30. mithwire/cdp/headless_experimental.py +115 -0
  31. mithwire/cdp/heap_profiler.py +401 -0
  32. mithwire/cdp/indexed_db.py +528 -0
  33. mithwire/cdp/input_.py +701 -0
  34. mithwire/cdp/inspector.py +95 -0
  35. mithwire/cdp/io.py +101 -0
  36. mithwire/cdp/layer_tree.py +464 -0
  37. mithwire/cdp/log.py +190 -0
  38. mithwire/cdp/media.py +313 -0
  39. mithwire/cdp/memory.py +305 -0
  40. mithwire/cdp/network.py +5342 -0
  41. mithwire/cdp/overlay.py +1468 -0
  42. mithwire/cdp/page.py +3972 -0
  43. mithwire/cdp/performance.py +124 -0
  44. mithwire/cdp/performance_timeline.py +200 -0
  45. mithwire/cdp/preload.py +575 -0
  46. mithwire/cdp/profiler.py +420 -0
  47. mithwire/cdp/pwa.py +278 -0
  48. mithwire/cdp/py.typed +0 -0
  49. mithwire/cdp/runtime.py +1589 -0
  50. mithwire/cdp/schema.py +50 -0
  51. mithwire/cdp/security.py +518 -0
  52. mithwire/cdp/service_worker.py +401 -0
  53. mithwire/cdp/smart_card_emulation.py +891 -0
  54. mithwire/cdp/storage.py +1573 -0
  55. mithwire/cdp/system_info.py +327 -0
  56. mithwire/cdp/target.py +829 -0
  57. mithwire/cdp/tethering.py +65 -0
  58. mithwire/cdp/tracing.py +377 -0
  59. mithwire/cdp/util.py +18 -0
  60. mithwire/cdp/web_audio.py +606 -0
  61. mithwire/cdp/web_authn.py +598 -0
  62. mithwire/cdp/web_mcp.py +293 -0
  63. mithwire/core/_contradict.py +142 -0
  64. mithwire/core/browser.py +923 -0
  65. mithwire/core/cf_templates/cf_dark_checkbox.png +0 -0
  66. mithwire/core/cf_templates/cf_light_checkbox.png +0 -0
  67. mithwire/core/config.py +323 -0
  68. mithwire/core/connection.py +564 -0
  69. mithwire/core/element.py +1205 -0
  70. mithwire/core/tab.py +2202 -0
  71. mithwire/core/util.py +5063 -0
  72. mithwire-0.50.3.dist-info/METADATA +1049 -0
  73. mithwire-0.50.3.dist-info/RECORD +76 -0
  74. mithwire-0.50.3.dist-info/WHEEL +5 -0
  75. mithwire-0.50.3.dist-info/licenses/LICENSE.txt +619 -0
  76. mithwire-0.50.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,821 @@
1
+ # DO NOT EDIT THIS FILE!
2
+ #
3
+ # This file is generated from the CDP specification. If you need to make
4
+ # changes, edit the generator and regenerate all of the modules.
5
+ #
6
+ # CDP domain: Browser
7
+
8
+ from __future__ import annotations
9
+ import enum
10
+ import typing
11
+ from dataclasses import dataclass
12
+ from .util import event_class, T_JSON_DICT
13
+
14
+ from . import page
15
+ from . import target
16
+ from deprecated.sphinx import deprecated # type: ignore
17
+
18
+
19
+ class BrowserContextID(str):
20
+ def to_json(self) -> str:
21
+ return self
22
+
23
+ @classmethod
24
+ def from_json(cls, json: str) -> BrowserContextID:
25
+ return cls(json)
26
+
27
+ def __repr__(self):
28
+ return 'BrowserContextID({})'.format(super().__repr__())
29
+
30
+
31
+ class WindowID(int):
32
+ def to_json(self) -> int:
33
+ return self
34
+
35
+ @classmethod
36
+ def from_json(cls, json: int) -> WindowID:
37
+ return cls(json)
38
+
39
+ def __repr__(self):
40
+ return 'WindowID({})'.format(super().__repr__())
41
+
42
+
43
+ class WindowState(enum.Enum):
44
+ '''
45
+ The state of the browser window.
46
+ '''
47
+ NORMAL = "normal"
48
+ MINIMIZED = "minimized"
49
+ MAXIMIZED = "maximized"
50
+ FULLSCREEN = "fullscreen"
51
+
52
+ def to_json(self) -> str:
53
+ return self.value
54
+
55
+ @classmethod
56
+ def from_json(cls, json: str) -> WindowState:
57
+ return cls(json)
58
+
59
+
60
+ @dataclass
61
+ class Bounds:
62
+ '''
63
+ Browser window bounds information
64
+ '''
65
+ #: The offset from the left edge of the screen to the window in pixels.
66
+ left: typing.Optional[int] = None
67
+
68
+ #: The offset from the top edge of the screen to the window in pixels.
69
+ top: typing.Optional[int] = None
70
+
71
+ #: The window width in pixels.
72
+ width: typing.Optional[int] = None
73
+
74
+ #: The window height in pixels.
75
+ height: typing.Optional[int] = None
76
+
77
+ #: The window state. Default to normal.
78
+ window_state: typing.Optional[WindowState] = None
79
+
80
+ def to_json(self) -> T_JSON_DICT:
81
+ json: T_JSON_DICT = dict()
82
+ if self.left is not None:
83
+ json['left'] = self.left
84
+ if self.top is not None:
85
+ json['top'] = self.top
86
+ if self.width is not None:
87
+ json['width'] = self.width
88
+ if self.height is not None:
89
+ json['height'] = self.height
90
+ if self.window_state is not None:
91
+ json['windowState'] = self.window_state.to_json()
92
+ return json
93
+
94
+ @classmethod
95
+ def from_json(cls, json: T_JSON_DICT) -> Bounds:
96
+ return cls(
97
+ left=int(json['left']) if json.get('left', None) is not None else None,
98
+ top=int(json['top']) if json.get('top', None) is not None else None,
99
+ width=int(json['width']) if json.get('width', None) is not None else None,
100
+ height=int(json['height']) if json.get('height', None) is not None else None,
101
+ window_state=WindowState.from_json(json['windowState']) if json.get('windowState', None) is not None else None,
102
+ )
103
+
104
+
105
+ class PermissionType(enum.Enum):
106
+ AR = "ar"
107
+ AUDIO_CAPTURE = "audioCapture"
108
+ AUTOMATIC_FULLSCREEN = "automaticFullscreen"
109
+ BACKGROUND_FETCH = "backgroundFetch"
110
+ BACKGROUND_SYNC = "backgroundSync"
111
+ CAMERA_PAN_TILT_ZOOM = "cameraPanTiltZoom"
112
+ CAPTURED_SURFACE_CONTROL = "capturedSurfaceControl"
113
+ CLIPBOARD_READ_WRITE = "clipboardReadWrite"
114
+ CLIPBOARD_SANITIZED_WRITE = "clipboardSanitizedWrite"
115
+ DISPLAY_CAPTURE = "displayCapture"
116
+ DURABLE_STORAGE = "durableStorage"
117
+ GEOLOCATION = "geolocation"
118
+ HAND_TRACKING = "handTracking"
119
+ IDLE_DETECTION = "idleDetection"
120
+ KEYBOARD_LOCK = "keyboardLock"
121
+ LOCAL_FONTS = "localFonts"
122
+ LOCAL_NETWORK = "localNetwork"
123
+ LOCAL_NETWORK_ACCESS = "localNetworkAccess"
124
+ LOOPBACK_NETWORK = "loopbackNetwork"
125
+ MIDI = "midi"
126
+ MIDI_SYSEX = "midiSysex"
127
+ NFC = "nfc"
128
+ NOTIFICATIONS = "notifications"
129
+ PAYMENT_HANDLER = "paymentHandler"
130
+ PERIODIC_BACKGROUND_SYNC = "periodicBackgroundSync"
131
+ POINTER_LOCK = "pointerLock"
132
+ PROTECTED_MEDIA_IDENTIFIER = "protectedMediaIdentifier"
133
+ SENSORS = "sensors"
134
+ SMART_CARD = "smartCard"
135
+ SPEAKER_SELECTION = "speakerSelection"
136
+ STORAGE_ACCESS = "storageAccess"
137
+ TOP_LEVEL_STORAGE_ACCESS = "topLevelStorageAccess"
138
+ VIDEO_CAPTURE = "videoCapture"
139
+ VR = "vr"
140
+ WAKE_LOCK_SCREEN = "wakeLockScreen"
141
+ WAKE_LOCK_SYSTEM = "wakeLockSystem"
142
+ WEB_APP_INSTALLATION = "webAppInstallation"
143
+ WEB_PRINTING = "webPrinting"
144
+ WINDOW_MANAGEMENT = "windowManagement"
145
+
146
+ def to_json(self) -> str:
147
+ return self.value
148
+
149
+ @classmethod
150
+ def from_json(cls, json: str) -> PermissionType:
151
+ return cls(json)
152
+
153
+
154
+ class PermissionSetting(enum.Enum):
155
+ GRANTED = "granted"
156
+ DENIED = "denied"
157
+ PROMPT = "prompt"
158
+
159
+ def to_json(self) -> str:
160
+ return self.value
161
+
162
+ @classmethod
163
+ def from_json(cls, json: str) -> PermissionSetting:
164
+ return cls(json)
165
+
166
+
167
+ @dataclass
168
+ class PermissionDescriptor:
169
+ '''
170
+ Definition of PermissionDescriptor defined in the Permissions API:
171
+ https://w3c.github.io/permissions/#dom-permissiondescriptor.
172
+ '''
173
+ #: Name of permission.
174
+ #: See https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/permissions/permission_descriptor.idl for valid permission names.
175
+ name: str
176
+
177
+ #: For "midi" permission, may also specify sysex control.
178
+ sysex: typing.Optional[bool] = None
179
+
180
+ #: For "push" permission, may specify userVisibleOnly.
181
+ #: Note that userVisibleOnly = true is the only currently supported type.
182
+ user_visible_only: typing.Optional[bool] = None
183
+
184
+ #: For "clipboard" permission, may specify allowWithoutSanitization.
185
+ allow_without_sanitization: typing.Optional[bool] = None
186
+
187
+ #: For "fullscreen" permission, must specify allowWithoutGesture:true.
188
+ allow_without_gesture: typing.Optional[bool] = None
189
+
190
+ #: For "camera" permission, may specify panTiltZoom.
191
+ pan_tilt_zoom: typing.Optional[bool] = None
192
+
193
+ def to_json(self) -> T_JSON_DICT:
194
+ json: T_JSON_DICT = dict()
195
+ json['name'] = self.name
196
+ if self.sysex is not None:
197
+ json['sysex'] = self.sysex
198
+ if self.user_visible_only is not None:
199
+ json['userVisibleOnly'] = self.user_visible_only
200
+ if self.allow_without_sanitization is not None:
201
+ json['allowWithoutSanitization'] = self.allow_without_sanitization
202
+ if self.allow_without_gesture is not None:
203
+ json['allowWithoutGesture'] = self.allow_without_gesture
204
+ if self.pan_tilt_zoom is not None:
205
+ json['panTiltZoom'] = self.pan_tilt_zoom
206
+ return json
207
+
208
+ @classmethod
209
+ def from_json(cls, json: T_JSON_DICT) -> PermissionDescriptor:
210
+ return cls(
211
+ name=str(json['name']),
212
+ sysex=bool(json['sysex']) if json.get('sysex', None) is not None else None,
213
+ user_visible_only=bool(json['userVisibleOnly']) if json.get('userVisibleOnly', None) is not None else None,
214
+ allow_without_sanitization=bool(json['allowWithoutSanitization']) if json.get('allowWithoutSanitization', None) is not None else None,
215
+ allow_without_gesture=bool(json['allowWithoutGesture']) if json.get('allowWithoutGesture', None) is not None else None,
216
+ pan_tilt_zoom=bool(json['panTiltZoom']) if json.get('panTiltZoom', None) is not None else None,
217
+ )
218
+
219
+
220
+ class BrowserCommandId(enum.Enum):
221
+ '''
222
+ Browser command ids used by executeBrowserCommand.
223
+ '''
224
+ OPEN_TAB_SEARCH = "openTabSearch"
225
+ CLOSE_TAB_SEARCH = "closeTabSearch"
226
+ OPEN_GLIC = "openGlic"
227
+
228
+ def to_json(self) -> str:
229
+ return self.value
230
+
231
+ @classmethod
232
+ def from_json(cls, json: str) -> BrowserCommandId:
233
+ return cls(json)
234
+
235
+
236
+ @dataclass
237
+ class Bucket:
238
+ '''
239
+ Chrome histogram bucket.
240
+ '''
241
+ #: Minimum value (inclusive).
242
+ low: int
243
+
244
+ #: Maximum value (exclusive).
245
+ high: int
246
+
247
+ #: Number of samples.
248
+ count: int
249
+
250
+ def to_json(self) -> T_JSON_DICT:
251
+ json: T_JSON_DICT = dict()
252
+ json['low'] = self.low
253
+ json['high'] = self.high
254
+ json['count'] = self.count
255
+ return json
256
+
257
+ @classmethod
258
+ def from_json(cls, json: T_JSON_DICT) -> Bucket:
259
+ return cls(
260
+ low=int(json['low']),
261
+ high=int(json['high']),
262
+ count=int(json['count']),
263
+ )
264
+
265
+
266
+ @dataclass
267
+ class Histogram:
268
+ '''
269
+ Chrome histogram.
270
+ '''
271
+ #: Name.
272
+ name: str
273
+
274
+ #: Sum of sample values.
275
+ sum_: int
276
+
277
+ #: Total number of samples.
278
+ count: int
279
+
280
+ #: Buckets.
281
+ buckets: typing.List[Bucket]
282
+
283
+ def to_json(self) -> T_JSON_DICT:
284
+ json: T_JSON_DICT = dict()
285
+ json['name'] = self.name
286
+ json['sum'] = self.sum_
287
+ json['count'] = self.count
288
+ json['buckets'] = [i.to_json() for i in self.buckets]
289
+ return json
290
+
291
+ @classmethod
292
+ def from_json(cls, json: T_JSON_DICT) -> Histogram:
293
+ return cls(
294
+ name=str(json['name']),
295
+ sum_=int(json['sum']),
296
+ count=int(json['count']),
297
+ buckets=[Bucket.from_json(i) for i in json['buckets']],
298
+ )
299
+
300
+
301
+ class PrivacySandboxAPI(enum.Enum):
302
+ BIDDING_AND_AUCTION_SERVICES = "BiddingAndAuctionServices"
303
+ TRUSTED_KEY_VALUE = "TrustedKeyValue"
304
+
305
+ def to_json(self) -> str:
306
+ return self.value
307
+
308
+ @classmethod
309
+ def from_json(cls, json: str) -> PrivacySandboxAPI:
310
+ return cls(json)
311
+
312
+
313
+ def set_permission(
314
+ permission: PermissionDescriptor,
315
+ setting: PermissionSetting,
316
+ origin: typing.Optional[str] = None,
317
+ embedded_origin: typing.Optional[str] = None,
318
+ browser_context_id: typing.Optional[BrowserContextID] = None
319
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
320
+ '''
321
+ Set permission settings for given embedding and embedded origins.
322
+
323
+ **EXPERIMENTAL**
324
+
325
+ :param permission: Descriptor of permission to override.
326
+ :param setting: Setting of the permission.
327
+ :param origin: *(Optional)* Embedding origin the permission applies to, all origins if not specified.
328
+ :param embedded_origin: *(Optional)* Embedded origin the permission applies to. It is ignored unless the embedding origin is present and valid. If the embedding origin is provided but the embedded origin isn't, the embedding origin is used as the embedded origin.
329
+ :param browser_context_id: *(Optional)* Context to override. When omitted, default browser context is used.
330
+ '''
331
+ params: T_JSON_DICT = dict()
332
+ params['permission'] = permission.to_json()
333
+ params['setting'] = setting.to_json()
334
+ if origin is not None:
335
+ params['origin'] = origin
336
+ if embedded_origin is not None:
337
+ params['embeddedOrigin'] = embedded_origin
338
+ if browser_context_id is not None:
339
+ params['browserContextId'] = browser_context_id.to_json()
340
+ cmd_dict: T_JSON_DICT = {
341
+ 'method': 'Browser.setPermission',
342
+ 'params': params,
343
+ }
344
+ json = yield cmd_dict
345
+
346
+
347
+ @deprecated(version="1.3")
348
+ def grant_permissions(
349
+ permissions: typing.List[PermissionType],
350
+ origin: typing.Optional[str] = None,
351
+ browser_context_id: typing.Optional[BrowserContextID] = None
352
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
353
+ '''
354
+ Grant specific permissions to the given origin and reject all others. Deprecated. Use
355
+ setPermission instead.
356
+
357
+ .. deprecated:: 1.3
358
+
359
+ **EXPERIMENTAL**
360
+
361
+ :param permissions:
362
+ :param origin: *(Optional)* Origin the permission applies to, all origins if not specified.
363
+ :param browser_context_id: *(Optional)* BrowserContext to override permissions. When omitted, default browser context is used.
364
+ '''
365
+ params: T_JSON_DICT = dict()
366
+ params['permissions'] = [i.to_json() for i in permissions]
367
+ if origin is not None:
368
+ params['origin'] = origin
369
+ if browser_context_id is not None:
370
+ params['browserContextId'] = browser_context_id.to_json()
371
+ cmd_dict: T_JSON_DICT = {
372
+ 'method': 'Browser.grantPermissions',
373
+ 'params': params,
374
+ }
375
+ json = yield cmd_dict
376
+
377
+
378
+ def reset_permissions(
379
+ browser_context_id: typing.Optional[BrowserContextID] = None
380
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
381
+ '''
382
+ Reset all permission management for all origins.
383
+
384
+ :param browser_context_id: *(Optional)* BrowserContext to reset permissions. When omitted, default browser context is used.
385
+ '''
386
+ params: T_JSON_DICT = dict()
387
+ if browser_context_id is not None:
388
+ params['browserContextId'] = browser_context_id.to_json()
389
+ cmd_dict: T_JSON_DICT = {
390
+ 'method': 'Browser.resetPermissions',
391
+ 'params': params,
392
+ }
393
+ json = yield cmd_dict
394
+
395
+
396
+ def set_download_behavior(
397
+ behavior: str,
398
+ browser_context_id: typing.Optional[BrowserContextID] = None,
399
+ download_path: typing.Optional[str] = None,
400
+ events_enabled: typing.Optional[bool] = None
401
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
402
+ '''
403
+ Set the behavior when downloading a file.
404
+
405
+ **EXPERIMENTAL**
406
+
407
+ :param behavior: Whether to allow all or deny all download requests, or use default Chrome behavior if available (otherwise deny). ``allowAndName`` allows download and names files according to their download guids.
408
+ :param browser_context_id: *(Optional)* BrowserContext to set download behavior. When omitted, default browser context is used.
409
+ :param download_path: *(Optional)* The default path to save downloaded files to. This is required if behavior is set to 'allow' or 'allowAndName'.
410
+ :param events_enabled: *(Optional)* Whether to emit download events (defaults to false).
411
+ '''
412
+ params: T_JSON_DICT = dict()
413
+ params['behavior'] = behavior
414
+ if browser_context_id is not None:
415
+ params['browserContextId'] = browser_context_id.to_json()
416
+ if download_path is not None:
417
+ params['downloadPath'] = download_path
418
+ if events_enabled is not None:
419
+ params['eventsEnabled'] = events_enabled
420
+ cmd_dict: T_JSON_DICT = {
421
+ 'method': 'Browser.setDownloadBehavior',
422
+ 'params': params,
423
+ }
424
+ json = yield cmd_dict
425
+
426
+
427
+ def cancel_download(
428
+ guid: str,
429
+ browser_context_id: typing.Optional[BrowserContextID] = None
430
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
431
+ '''
432
+ Cancel a download if in progress
433
+
434
+ **EXPERIMENTAL**
435
+
436
+ :param guid: Global unique identifier of the download.
437
+ :param browser_context_id: *(Optional)* BrowserContext to perform the action in. When omitted, default browser context is used.
438
+ '''
439
+ params: T_JSON_DICT = dict()
440
+ params['guid'] = guid
441
+ if browser_context_id is not None:
442
+ params['browserContextId'] = browser_context_id.to_json()
443
+ cmd_dict: T_JSON_DICT = {
444
+ 'method': 'Browser.cancelDownload',
445
+ 'params': params,
446
+ }
447
+ json = yield cmd_dict
448
+
449
+
450
+ def close() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
451
+ '''
452
+ Close browser gracefully.
453
+ '''
454
+ cmd_dict: T_JSON_DICT = {
455
+ 'method': 'Browser.close',
456
+ }
457
+ json = yield cmd_dict
458
+
459
+
460
+ def crash() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
461
+ '''
462
+ Crashes browser on the main thread.
463
+
464
+ **EXPERIMENTAL**
465
+ '''
466
+ cmd_dict: T_JSON_DICT = {
467
+ 'method': 'Browser.crash',
468
+ }
469
+ json = yield cmd_dict
470
+
471
+
472
+ def crash_gpu_process() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
473
+ '''
474
+ Crashes GPU process.
475
+
476
+ **EXPERIMENTAL**
477
+ '''
478
+ cmd_dict: T_JSON_DICT = {
479
+ 'method': 'Browser.crashGpuProcess',
480
+ }
481
+ json = yield cmd_dict
482
+
483
+
484
+ def get_version() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[str, str, str, str, str]]:
485
+ '''
486
+ Returns version information.
487
+
488
+ :returns: A tuple with the following items:
489
+
490
+ 0. **protocolVersion** - Protocol version.
491
+ 1. **product** - Product name.
492
+ 2. **revision** - Product revision.
493
+ 3. **userAgent** - User-Agent.
494
+ 4. **jsVersion** - V8 version.
495
+ '''
496
+ cmd_dict: T_JSON_DICT = {
497
+ 'method': 'Browser.getVersion',
498
+ }
499
+ json = yield cmd_dict
500
+ return (
501
+ str(json['protocolVersion']),
502
+ str(json['product']),
503
+ str(json['revision']),
504
+ str(json['userAgent']),
505
+ str(json['jsVersion'])
506
+ )
507
+
508
+
509
+ def get_browser_command_line() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[str]]:
510
+ '''
511
+ Returns the command line switches for the browser process if, and only if
512
+ --enable-automation is on the commandline.
513
+
514
+ **EXPERIMENTAL**
515
+
516
+ :returns: Commandline parameters
517
+ '''
518
+ cmd_dict: T_JSON_DICT = {
519
+ 'method': 'Browser.getBrowserCommandLine',
520
+ }
521
+ json = yield cmd_dict
522
+ return [str(i) for i in json['arguments']]
523
+
524
+
525
+ def get_histograms(
526
+ query: typing.Optional[str] = None,
527
+ delta: typing.Optional[bool] = None
528
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[Histogram]]:
529
+ '''
530
+ Get Chrome histograms.
531
+
532
+ **EXPERIMENTAL**
533
+
534
+ :param query: *(Optional)* Requested substring in name. Only histograms which have query as a substring in their name are extracted. An empty or absent query returns all histograms.
535
+ :param delta: *(Optional)* If true, retrieve delta since last delta call.
536
+ :returns: Histograms.
537
+ '''
538
+ params: T_JSON_DICT = dict()
539
+ if query is not None:
540
+ params['query'] = query
541
+ if delta is not None:
542
+ params['delta'] = delta
543
+ cmd_dict: T_JSON_DICT = {
544
+ 'method': 'Browser.getHistograms',
545
+ 'params': params,
546
+ }
547
+ json = yield cmd_dict
548
+ return [Histogram.from_json(i) for i in json['histograms']]
549
+
550
+
551
+ def get_histogram(
552
+ name: str,
553
+ delta: typing.Optional[bool] = None
554
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,Histogram]:
555
+ '''
556
+ Get a Chrome histogram by name.
557
+
558
+ **EXPERIMENTAL**
559
+
560
+ :param name: Requested histogram name.
561
+ :param delta: *(Optional)* If true, retrieve delta since last delta call.
562
+ :returns: Histogram.
563
+ '''
564
+ params: T_JSON_DICT = dict()
565
+ params['name'] = name
566
+ if delta is not None:
567
+ params['delta'] = delta
568
+ cmd_dict: T_JSON_DICT = {
569
+ 'method': 'Browser.getHistogram',
570
+ 'params': params,
571
+ }
572
+ json = yield cmd_dict
573
+ return Histogram.from_json(json['histogram'])
574
+
575
+
576
+ def get_window_bounds(
577
+ window_id: WindowID
578
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,Bounds]:
579
+ '''
580
+ Get position and size of the browser window.
581
+
582
+ **EXPERIMENTAL**
583
+
584
+ :param window_id: Browser window id.
585
+ :returns: Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
586
+ '''
587
+ params: T_JSON_DICT = dict()
588
+ params['windowId'] = window_id.to_json()
589
+ cmd_dict: T_JSON_DICT = {
590
+ 'method': 'Browser.getWindowBounds',
591
+ 'params': params,
592
+ }
593
+ json = yield cmd_dict
594
+ return Bounds.from_json(json['bounds'])
595
+
596
+
597
+ def get_window_for_target(
598
+ target_id: typing.Optional[target.TargetID] = None
599
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[WindowID, Bounds]]:
600
+ '''
601
+ Get the browser window that contains the devtools target.
602
+
603
+ **EXPERIMENTAL**
604
+
605
+ :param target_id: *(Optional)* Devtools agent host id. If called as a part of the session, associated targetId is used.
606
+ :returns: A tuple with the following items:
607
+
608
+ 0. **windowId** - Browser window id.
609
+ 1. **bounds** - Bounds information of the window. When window state is 'minimized', the restored window position and size are returned.
610
+ '''
611
+ params: T_JSON_DICT = dict()
612
+ if target_id is not None:
613
+ params['targetId'] = target_id.to_json()
614
+ cmd_dict: T_JSON_DICT = {
615
+ 'method': 'Browser.getWindowForTarget',
616
+ 'params': params,
617
+ }
618
+ json = yield cmd_dict
619
+ return (
620
+ WindowID.from_json(json['windowId']),
621
+ Bounds.from_json(json['bounds'])
622
+ )
623
+
624
+
625
+ def set_window_bounds(
626
+ window_id: WindowID,
627
+ bounds: Bounds
628
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
629
+ '''
630
+ Set position and/or size of the browser window.
631
+
632
+ **EXPERIMENTAL**
633
+
634
+ :param window_id: Browser window id.
635
+ :param bounds: New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
636
+ '''
637
+ params: T_JSON_DICT = dict()
638
+ params['windowId'] = window_id.to_json()
639
+ params['bounds'] = bounds.to_json()
640
+ cmd_dict: T_JSON_DICT = {
641
+ 'method': 'Browser.setWindowBounds',
642
+ 'params': params,
643
+ }
644
+ json = yield cmd_dict
645
+
646
+
647
+ def set_contents_size(
648
+ window_id: WindowID,
649
+ width: typing.Optional[int] = None,
650
+ height: typing.Optional[int] = None
651
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
652
+ '''
653
+ Set size of the browser contents resizing browser window as necessary.
654
+
655
+ **EXPERIMENTAL**
656
+
657
+ :param window_id: Browser window id.
658
+ :param width: *(Optional)* The window contents width in DIP. Assumes current width if omitted. Must be specified if 'height' is omitted.
659
+ :param height: *(Optional)* The window contents height in DIP. Assumes current height if omitted. Must be specified if 'width' is omitted.
660
+ '''
661
+ params: T_JSON_DICT = dict()
662
+ params['windowId'] = window_id.to_json()
663
+ if width is not None:
664
+ params['width'] = width
665
+ if height is not None:
666
+ params['height'] = height
667
+ cmd_dict: T_JSON_DICT = {
668
+ 'method': 'Browser.setContentsSize',
669
+ 'params': params,
670
+ }
671
+ json = yield cmd_dict
672
+
673
+
674
+ def set_dock_tile(
675
+ badge_label: typing.Optional[str] = None,
676
+ image: typing.Optional[str] = None
677
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
678
+ '''
679
+ Set dock tile details, platform-specific.
680
+
681
+ **EXPERIMENTAL**
682
+
683
+ :param badge_label: *(Optional)*
684
+ :param image: *(Optional)* Png encoded image. (Encoded as a base64 string when passed over JSON)
685
+ '''
686
+ params: T_JSON_DICT = dict()
687
+ if badge_label is not None:
688
+ params['badgeLabel'] = badge_label
689
+ if image is not None:
690
+ params['image'] = image
691
+ cmd_dict: T_JSON_DICT = {
692
+ 'method': 'Browser.setDockTile',
693
+ 'params': params,
694
+ }
695
+ json = yield cmd_dict
696
+
697
+
698
+ def execute_browser_command(
699
+ command_id: BrowserCommandId
700
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
701
+ '''
702
+ Invoke custom browser commands used by telemetry.
703
+
704
+ **EXPERIMENTAL**
705
+
706
+ :param command_id:
707
+ '''
708
+ params: T_JSON_DICT = dict()
709
+ params['commandId'] = command_id.to_json()
710
+ cmd_dict: T_JSON_DICT = {
711
+ 'method': 'Browser.executeBrowserCommand',
712
+ 'params': params,
713
+ }
714
+ json = yield cmd_dict
715
+
716
+
717
+ def add_privacy_sandbox_enrollment_override(
718
+ url: str
719
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
720
+ '''
721
+ Allows a site to use privacy sandbox features that require enrollment
722
+ without the site actually being enrolled. Only supported on page targets.
723
+
724
+ :param url:
725
+ '''
726
+ params: T_JSON_DICT = dict()
727
+ params['url'] = url
728
+ cmd_dict: T_JSON_DICT = {
729
+ 'method': 'Browser.addPrivacySandboxEnrollmentOverride',
730
+ 'params': params,
731
+ }
732
+ json = yield cmd_dict
733
+
734
+
735
+ def add_privacy_sandbox_coordinator_key_config(
736
+ api: PrivacySandboxAPI,
737
+ coordinator_origin: str,
738
+ key_config: str,
739
+ browser_context_id: typing.Optional[BrowserContextID] = None
740
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
741
+ '''
742
+ Configures encryption keys used with a given privacy sandbox API to talk
743
+ to a trusted coordinator. Since this is intended for test automation only,
744
+ coordinatorOrigin must be a .test domain. No existing coordinator
745
+ configuration for the origin may exist.
746
+
747
+ :param api:
748
+ :param coordinator_origin:
749
+ :param key_config:
750
+ :param browser_context_id: *(Optional)* BrowserContext to perform the action in. When omitted, default browser context is used.
751
+ '''
752
+ params: T_JSON_DICT = dict()
753
+ params['api'] = api.to_json()
754
+ params['coordinatorOrigin'] = coordinator_origin
755
+ params['keyConfig'] = key_config
756
+ if browser_context_id is not None:
757
+ params['browserContextId'] = browser_context_id.to_json()
758
+ cmd_dict: T_JSON_DICT = {
759
+ 'method': 'Browser.addPrivacySandboxCoordinatorKeyConfig',
760
+ 'params': params,
761
+ }
762
+ json = yield cmd_dict
763
+
764
+
765
+ @event_class('Browser.downloadWillBegin')
766
+ @dataclass
767
+ class DownloadWillBegin:
768
+ '''
769
+ **EXPERIMENTAL**
770
+
771
+ Fired when page is about to start a download.
772
+ '''
773
+ #: Id of the frame that caused the download to begin.
774
+ frame_id: page.FrameId
775
+ #: Global unique identifier of the download.
776
+ guid: str
777
+ #: URL of the resource being downloaded.
778
+ url: str
779
+ #: Suggested file name of the resource (the actual name of the file saved on disk may differ).
780
+ suggested_filename: str
781
+
782
+ @classmethod
783
+ def from_json(cls, json: T_JSON_DICT) -> DownloadWillBegin:
784
+ return cls(
785
+ frame_id=page.FrameId.from_json(json['frameId']),
786
+ guid=str(json['guid']),
787
+ url=str(json['url']),
788
+ suggested_filename=str(json['suggestedFilename'])
789
+ )
790
+
791
+
792
+ @event_class('Browser.downloadProgress')
793
+ @dataclass
794
+ class DownloadProgress:
795
+ '''
796
+ **EXPERIMENTAL**
797
+
798
+ Fired when download makes progress. Last call has ``done`` == true.
799
+ '''
800
+ #: Global unique identifier of the download.
801
+ guid: str
802
+ #: Total expected bytes to download.
803
+ total_bytes: float
804
+ #: Total bytes received.
805
+ received_bytes: float
806
+ #: Download status.
807
+ state: str
808
+ #: If download is "completed", provides the path of the downloaded file.
809
+ #: Depending on the platform, it is not guaranteed to be set, nor the file
810
+ #: is guaranteed to exist.
811
+ file_path: typing.Optional[str]
812
+
813
+ @classmethod
814
+ def from_json(cls, json: T_JSON_DICT) -> DownloadProgress:
815
+ return cls(
816
+ guid=str(json['guid']),
817
+ total_bytes=float(json['totalBytes']),
818
+ received_bytes=float(json['receivedBytes']),
819
+ state=str(json['state']),
820
+ file_path=str(json['filePath']) if json.get('filePath', None) is not None else None
821
+ )