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
mithwire/cdp/page.py ADDED
@@ -0,0 +1,3972 @@
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: Page
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 debugger
15
+ from . import dom
16
+ from . import emulation
17
+ from . import io
18
+ from . import network
19
+ from . import runtime
20
+ from deprecated.sphinx import deprecated # type: ignore
21
+
22
+
23
+ class FrameId(str):
24
+ '''
25
+ Unique frame identifier.
26
+ '''
27
+ def to_json(self) -> str:
28
+ return self
29
+
30
+ @classmethod
31
+ def from_json(cls, json: str) -> FrameId:
32
+ return cls(json)
33
+
34
+ def __repr__(self):
35
+ return 'FrameId({})'.format(super().__repr__())
36
+
37
+
38
+ class AdFrameType(enum.Enum):
39
+ '''
40
+ Indicates whether a frame has been identified as an ad.
41
+ '''
42
+ NONE = "none"
43
+ CHILD = "child"
44
+ ROOT = "root"
45
+
46
+ def to_json(self) -> str:
47
+ return self.value
48
+
49
+ @classmethod
50
+ def from_json(cls, json: str) -> AdFrameType:
51
+ return cls(json)
52
+
53
+
54
+ class AdFrameExplanation(enum.Enum):
55
+ PARENT_IS_AD = "ParentIsAd"
56
+ CREATED_BY_AD_SCRIPT = "CreatedByAdScript"
57
+ MATCHED_BLOCKING_RULE = "MatchedBlockingRule"
58
+
59
+ def to_json(self) -> str:
60
+ return self.value
61
+
62
+ @classmethod
63
+ def from_json(cls, json: str) -> AdFrameExplanation:
64
+ return cls(json)
65
+
66
+
67
+ @dataclass
68
+ class AdFrameStatus:
69
+ '''
70
+ Indicates whether a frame has been identified as an ad and why.
71
+ '''
72
+ ad_frame_type: AdFrameType
73
+
74
+ explanations: typing.Optional[typing.List[AdFrameExplanation]] = None
75
+
76
+ def to_json(self) -> T_JSON_DICT:
77
+ json: T_JSON_DICT = dict()
78
+ json['adFrameType'] = self.ad_frame_type.to_json()
79
+ if self.explanations is not None:
80
+ json['explanations'] = [i.to_json() for i in self.explanations]
81
+ return json
82
+
83
+ @classmethod
84
+ def from_json(cls, json: T_JSON_DICT) -> AdFrameStatus:
85
+ return cls(
86
+ ad_frame_type=AdFrameType.from_json(json['adFrameType']),
87
+ explanations=[AdFrameExplanation.from_json(i) for i in json['explanations']] if json.get('explanations', None) is not None else None,
88
+ )
89
+
90
+
91
+ class SecureContextType(enum.Enum):
92
+ '''
93
+ Indicates whether the frame is a secure context and why it is the case.
94
+ '''
95
+ SECURE = "Secure"
96
+ SECURE_LOCALHOST = "SecureLocalhost"
97
+ INSECURE_SCHEME = "InsecureScheme"
98
+ INSECURE_ANCESTOR = "InsecureAncestor"
99
+
100
+ def to_json(self) -> str:
101
+ return self.value
102
+
103
+ @classmethod
104
+ def from_json(cls, json: str) -> SecureContextType:
105
+ return cls(json)
106
+
107
+
108
+ class CrossOriginIsolatedContextType(enum.Enum):
109
+ '''
110
+ Indicates whether the frame is cross-origin isolated and why it is the case.
111
+ '''
112
+ ISOLATED = "Isolated"
113
+ NOT_ISOLATED = "NotIsolated"
114
+ NOT_ISOLATED_FEATURE_DISABLED = "NotIsolatedFeatureDisabled"
115
+
116
+ def to_json(self) -> str:
117
+ return self.value
118
+
119
+ @classmethod
120
+ def from_json(cls, json: str) -> CrossOriginIsolatedContextType:
121
+ return cls(json)
122
+
123
+
124
+ class GatedAPIFeatures(enum.Enum):
125
+ SHARED_ARRAY_BUFFERS = "SharedArrayBuffers"
126
+ SHARED_ARRAY_BUFFERS_TRANSFER_ALLOWED = "SharedArrayBuffersTransferAllowed"
127
+ PERFORMANCE_MEASURE_MEMORY = "PerformanceMeasureMemory"
128
+ PERFORMANCE_PROFILE = "PerformanceProfile"
129
+
130
+ def to_json(self) -> str:
131
+ return self.value
132
+
133
+ @classmethod
134
+ def from_json(cls, json: str) -> GatedAPIFeatures:
135
+ return cls(json)
136
+
137
+
138
+ class PermissionsPolicyFeature(enum.Enum):
139
+ '''
140
+ All Permissions Policy features. This enum should match the one defined
141
+ in services/network/public/cpp/permissions_policy/permissions_policy_features.json5.
142
+ LINT.IfChange(PermissionsPolicyFeature)
143
+ '''
144
+ ACCELEROMETER = "accelerometer"
145
+ ALL_SCREENS_CAPTURE = "all-screens-capture"
146
+ AMBIENT_LIGHT_SENSOR = "ambient-light-sensor"
147
+ ARIA_NOTIFY = "aria-notify"
148
+ ATTRIBUTION_REPORTING = "attribution-reporting"
149
+ AUTOFILL = "autofill"
150
+ AUTOPLAY = "autoplay"
151
+ BLUETOOTH = "bluetooth"
152
+ BROWSING_TOPICS = "browsing-topics"
153
+ CAMERA = "camera"
154
+ CAPTURED_SURFACE_CONTROL = "captured-surface-control"
155
+ CH_DPR = "ch-dpr"
156
+ CH_DEVICE_MEMORY = "ch-device-memory"
157
+ CH_DOWNLINK = "ch-downlink"
158
+ CH_ECT = "ch-ect"
159
+ CH_PREFERS_COLOR_SCHEME = "ch-prefers-color-scheme"
160
+ CH_PREFERS_REDUCED_MOTION = "ch-prefers-reduced-motion"
161
+ CH_PREFERS_REDUCED_TRANSPARENCY = "ch-prefers-reduced-transparency"
162
+ CH_RTT = "ch-rtt"
163
+ CH_SAVE_DATA = "ch-save-data"
164
+ CH_UA = "ch-ua"
165
+ CH_UA_ARCH = "ch-ua-arch"
166
+ CH_UA_BITNESS = "ch-ua-bitness"
167
+ CH_UA_HIGH_ENTROPY_VALUES = "ch-ua-high-entropy-values"
168
+ CH_UA_PLATFORM = "ch-ua-platform"
169
+ CH_UA_MODEL = "ch-ua-model"
170
+ CH_UA_MOBILE = "ch-ua-mobile"
171
+ CH_UA_FORM_FACTORS = "ch-ua-form-factors"
172
+ CH_UA_FULL_VERSION = "ch-ua-full-version"
173
+ CH_UA_FULL_VERSION_LIST = "ch-ua-full-version-list"
174
+ CH_UA_PLATFORM_VERSION = "ch-ua-platform-version"
175
+ CH_UA_WOW64 = "ch-ua-wow64"
176
+ CH_VIEWPORT_HEIGHT = "ch-viewport-height"
177
+ CH_VIEWPORT_WIDTH = "ch-viewport-width"
178
+ CH_WIDTH = "ch-width"
179
+ CLIPBOARD_READ = "clipboard-read"
180
+ CLIPBOARD_WRITE = "clipboard-write"
181
+ COMPUTE_PRESSURE = "compute-pressure"
182
+ CONTROLLED_FRAME = "controlled-frame"
183
+ CROSS_ORIGIN_ISOLATED = "cross-origin-isolated"
184
+ DEFERRED_FETCH = "deferred-fetch"
185
+ DEFERRED_FETCH_MINIMAL = "deferred-fetch-minimal"
186
+ DEVICE_ATTRIBUTES = "device-attributes"
187
+ DIGITAL_CREDENTIALS_CREATE = "digital-credentials-create"
188
+ DIGITAL_CREDENTIALS_GET = "digital-credentials-get"
189
+ DIRECT_SOCKETS = "direct-sockets"
190
+ DIRECT_SOCKETS_MULTICAST = "direct-sockets-multicast"
191
+ DIRECT_SOCKETS_PRIVATE = "direct-sockets-private"
192
+ DISPLAY_CAPTURE = "display-capture"
193
+ DOCUMENT_DOMAIN = "document-domain"
194
+ ENCRYPTED_MEDIA = "encrypted-media"
195
+ EXECUTION_WHILE_OUT_OF_VIEWPORT = "execution-while-out-of-viewport"
196
+ EXECUTION_WHILE_NOT_RENDERED = "execution-while-not-rendered"
197
+ FOCUS_WITHOUT_USER_ACTIVATION = "focus-without-user-activation"
198
+ FULLSCREEN = "fullscreen"
199
+ FROBULATE = "frobulate"
200
+ GAMEPAD = "gamepad"
201
+ GEOLOCATION = "geolocation"
202
+ GYROSCOPE = "gyroscope"
203
+ HID = "hid"
204
+ IDENTITY_CREDENTIALS_GET = "identity-credentials-get"
205
+ IDLE_DETECTION = "idle-detection"
206
+ INTEREST_COHORT = "interest-cohort"
207
+ JOIN_AD_INTEREST_GROUP = "join-ad-interest-group"
208
+ KEYBOARD_MAP = "keyboard-map"
209
+ LANGUAGE_DETECTOR = "language-detector"
210
+ LANGUAGE_MODEL = "language-model"
211
+ LOCAL_FONTS = "local-fonts"
212
+ LOCAL_NETWORK = "local-network"
213
+ LOCAL_NETWORK_ACCESS = "local-network-access"
214
+ LOOPBACK_NETWORK = "loopback-network"
215
+ MAGNETOMETER = "magnetometer"
216
+ MANUAL_TEXT = "manual-text"
217
+ MEDIA_PLAYBACK_WHILE_NOT_VISIBLE = "media-playback-while-not-visible"
218
+ MICROPHONE = "microphone"
219
+ MIDI = "midi"
220
+ ON_DEVICE_SPEECH_RECOGNITION = "on-device-speech-recognition"
221
+ OTP_CREDENTIALS = "otp-credentials"
222
+ PAYMENT = "payment"
223
+ PICTURE_IN_PICTURE = "picture-in-picture"
224
+ PRIVATE_AGGREGATION = "private-aggregation"
225
+ PRIVATE_STATE_TOKEN_ISSUANCE = "private-state-token-issuance"
226
+ PRIVATE_STATE_TOKEN_REDEMPTION = "private-state-token-redemption"
227
+ PUBLICKEY_CREDENTIALS_CREATE = "publickey-credentials-create"
228
+ PUBLICKEY_CREDENTIALS_GET = "publickey-credentials-get"
229
+ RECORD_AD_AUCTION_EVENTS = "record-ad-auction-events"
230
+ REWRITER = "rewriter"
231
+ RUN_AD_AUCTION = "run-ad-auction"
232
+ SCREEN_WAKE_LOCK = "screen-wake-lock"
233
+ SERIAL = "serial"
234
+ SHARED_STORAGE = "shared-storage"
235
+ SHARED_STORAGE_SELECT_URL = "shared-storage-select-url"
236
+ SMART_CARD = "smart-card"
237
+ SPEAKER_SELECTION = "speaker-selection"
238
+ STORAGE_ACCESS = "storage-access"
239
+ SUB_APPS = "sub-apps"
240
+ SUMMARIZER = "summarizer"
241
+ SYNC_XHR = "sync-xhr"
242
+ TOOLS = "tools"
243
+ TRANSLATOR = "translator"
244
+ UNLOAD = "unload"
245
+ USB = "usb"
246
+ USB_UNRESTRICTED = "usb-unrestricted"
247
+ VERTICAL_SCROLL = "vertical-scroll"
248
+ WEB_APP_INSTALLATION = "web-app-installation"
249
+ WEB_PRINTING = "web-printing"
250
+ WEB_SHARE = "web-share"
251
+ WINDOW_MANAGEMENT = "window-management"
252
+ WRITER = "writer"
253
+ XR_SPATIAL_TRACKING = "xr-spatial-tracking"
254
+
255
+ def to_json(self) -> str:
256
+ return self.value
257
+
258
+ @classmethod
259
+ def from_json(cls, json: str) -> PermissionsPolicyFeature:
260
+ return cls(json)
261
+
262
+
263
+ class PermissionsPolicyBlockReason(enum.Enum):
264
+ '''
265
+ Reason for a permissions policy feature to be disabled.
266
+ '''
267
+ HEADER = "Header"
268
+ IFRAME_ATTRIBUTE = "IframeAttribute"
269
+ IN_FENCED_FRAME_TREE = "InFencedFrameTree"
270
+ IN_ISOLATED_APP = "InIsolatedApp"
271
+
272
+ def to_json(self) -> str:
273
+ return self.value
274
+
275
+ @classmethod
276
+ def from_json(cls, json: str) -> PermissionsPolicyBlockReason:
277
+ return cls(json)
278
+
279
+
280
+ @dataclass
281
+ class PermissionsPolicyBlockLocator:
282
+ frame_id: FrameId
283
+
284
+ block_reason: PermissionsPolicyBlockReason
285
+
286
+ def to_json(self) -> T_JSON_DICT:
287
+ json: T_JSON_DICT = dict()
288
+ json['frameId'] = self.frame_id.to_json()
289
+ json['blockReason'] = self.block_reason.to_json()
290
+ return json
291
+
292
+ @classmethod
293
+ def from_json(cls, json: T_JSON_DICT) -> PermissionsPolicyBlockLocator:
294
+ return cls(
295
+ frame_id=FrameId.from_json(json['frameId']),
296
+ block_reason=PermissionsPolicyBlockReason.from_json(json['blockReason']),
297
+ )
298
+
299
+
300
+ @dataclass
301
+ class PermissionsPolicyFeatureState:
302
+ feature: PermissionsPolicyFeature
303
+
304
+ allowed: bool
305
+
306
+ locator: typing.Optional[PermissionsPolicyBlockLocator] = None
307
+
308
+ def to_json(self) -> T_JSON_DICT:
309
+ json: T_JSON_DICT = dict()
310
+ json['feature'] = self.feature.to_json()
311
+ json['allowed'] = self.allowed
312
+ if self.locator is not None:
313
+ json['locator'] = self.locator.to_json()
314
+ return json
315
+
316
+ @classmethod
317
+ def from_json(cls, json: T_JSON_DICT) -> PermissionsPolicyFeatureState:
318
+ return cls(
319
+ feature=PermissionsPolicyFeature.from_json(json['feature']),
320
+ allowed=bool(json['allowed']),
321
+ locator=PermissionsPolicyBlockLocator.from_json(json['locator']) if json.get('locator', None) is not None else None,
322
+ )
323
+
324
+
325
+ class OriginTrialTokenStatus(enum.Enum):
326
+ '''
327
+ Origin Trial(https://www.chromium.org/blink/origin-trials) support.
328
+ Status for an Origin Trial token.
329
+ '''
330
+ SUCCESS = "Success"
331
+ NOT_SUPPORTED = "NotSupported"
332
+ INSECURE = "Insecure"
333
+ EXPIRED = "Expired"
334
+ WRONG_ORIGIN = "WrongOrigin"
335
+ INVALID_SIGNATURE = "InvalidSignature"
336
+ MALFORMED = "Malformed"
337
+ WRONG_VERSION = "WrongVersion"
338
+ FEATURE_DISABLED = "FeatureDisabled"
339
+ TOKEN_DISABLED = "TokenDisabled"
340
+ FEATURE_DISABLED_FOR_USER = "FeatureDisabledForUser"
341
+ UNKNOWN_TRIAL = "UnknownTrial"
342
+
343
+ def to_json(self) -> str:
344
+ return self.value
345
+
346
+ @classmethod
347
+ def from_json(cls, json: str) -> OriginTrialTokenStatus:
348
+ return cls(json)
349
+
350
+
351
+ class OriginTrialStatus(enum.Enum):
352
+ '''
353
+ Status for an Origin Trial.
354
+ '''
355
+ ENABLED = "Enabled"
356
+ VALID_TOKEN_NOT_PROVIDED = "ValidTokenNotProvided"
357
+ OS_NOT_SUPPORTED = "OSNotSupported"
358
+ TRIAL_NOT_ALLOWED = "TrialNotAllowed"
359
+
360
+ def to_json(self) -> str:
361
+ return self.value
362
+
363
+ @classmethod
364
+ def from_json(cls, json: str) -> OriginTrialStatus:
365
+ return cls(json)
366
+
367
+
368
+ class OriginTrialUsageRestriction(enum.Enum):
369
+ NONE = "None"
370
+ SUBSET = "Subset"
371
+
372
+ def to_json(self) -> str:
373
+ return self.value
374
+
375
+ @classmethod
376
+ def from_json(cls, json: str) -> OriginTrialUsageRestriction:
377
+ return cls(json)
378
+
379
+
380
+ @dataclass
381
+ class OriginTrialToken:
382
+ origin: str
383
+
384
+ match_sub_domains: bool
385
+
386
+ trial_name: str
387
+
388
+ expiry_time: network.TimeSinceEpoch
389
+
390
+ is_third_party: bool
391
+
392
+ usage_restriction: OriginTrialUsageRestriction
393
+
394
+ def to_json(self) -> T_JSON_DICT:
395
+ json: T_JSON_DICT = dict()
396
+ json['origin'] = self.origin
397
+ json['matchSubDomains'] = self.match_sub_domains
398
+ json['trialName'] = self.trial_name
399
+ json['expiryTime'] = self.expiry_time.to_json()
400
+ json['isThirdParty'] = self.is_third_party
401
+ json['usageRestriction'] = self.usage_restriction.to_json()
402
+ return json
403
+
404
+ @classmethod
405
+ def from_json(cls, json: T_JSON_DICT) -> OriginTrialToken:
406
+ return cls(
407
+ origin=str(json['origin']),
408
+ match_sub_domains=bool(json['matchSubDomains']),
409
+ trial_name=str(json['trialName']),
410
+ expiry_time=network.TimeSinceEpoch.from_json(json['expiryTime']),
411
+ is_third_party=bool(json['isThirdParty']),
412
+ usage_restriction=OriginTrialUsageRestriction.from_json(json['usageRestriction']),
413
+ )
414
+
415
+
416
+ @dataclass
417
+ class OriginTrialTokenWithStatus:
418
+ raw_token_text: str
419
+
420
+ status: OriginTrialTokenStatus
421
+
422
+ #: ``parsedToken`` is present only when the token is extractable and
423
+ #: parsable.
424
+ parsed_token: typing.Optional[OriginTrialToken] = None
425
+
426
+ def to_json(self) -> T_JSON_DICT:
427
+ json: T_JSON_DICT = dict()
428
+ json['rawTokenText'] = self.raw_token_text
429
+ json['status'] = self.status.to_json()
430
+ if self.parsed_token is not None:
431
+ json['parsedToken'] = self.parsed_token.to_json()
432
+ return json
433
+
434
+ @classmethod
435
+ def from_json(cls, json: T_JSON_DICT) -> OriginTrialTokenWithStatus:
436
+ return cls(
437
+ raw_token_text=str(json['rawTokenText']),
438
+ status=OriginTrialTokenStatus.from_json(json['status']),
439
+ parsed_token=OriginTrialToken.from_json(json['parsedToken']) if json.get('parsedToken', None) is not None else None,
440
+ )
441
+
442
+
443
+ @dataclass
444
+ class OriginTrial:
445
+ trial_name: str
446
+
447
+ status: OriginTrialStatus
448
+
449
+ tokens_with_status: typing.List[OriginTrialTokenWithStatus]
450
+
451
+ def to_json(self) -> T_JSON_DICT:
452
+ json: T_JSON_DICT = dict()
453
+ json['trialName'] = self.trial_name
454
+ json['status'] = self.status.to_json()
455
+ json['tokensWithStatus'] = [i.to_json() for i in self.tokens_with_status]
456
+ return json
457
+
458
+ @classmethod
459
+ def from_json(cls, json: T_JSON_DICT) -> OriginTrial:
460
+ return cls(
461
+ trial_name=str(json['trialName']),
462
+ status=OriginTrialStatus.from_json(json['status']),
463
+ tokens_with_status=[OriginTrialTokenWithStatus.from_json(i) for i in json['tokensWithStatus']],
464
+ )
465
+
466
+
467
+ @dataclass
468
+ class SecurityOriginDetails:
469
+ '''
470
+ Additional information about the frame document's security origin.
471
+ '''
472
+ #: Indicates whether the frame document's security origin is one
473
+ #: of the local hostnames (e.g. "localhost") or IP addresses (IPv4
474
+ #: 127.0.0.0/8 or IPv6 ::1).
475
+ is_localhost: bool
476
+
477
+ def to_json(self) -> T_JSON_DICT:
478
+ json: T_JSON_DICT = dict()
479
+ json['isLocalhost'] = self.is_localhost
480
+ return json
481
+
482
+ @classmethod
483
+ def from_json(cls, json: T_JSON_DICT) -> SecurityOriginDetails:
484
+ return cls(
485
+ is_localhost=bool(json['isLocalhost']),
486
+ )
487
+
488
+
489
+ @dataclass
490
+ class Frame:
491
+ '''
492
+ Information about the Frame on the page.
493
+ '''
494
+ #: Frame unique identifier.
495
+ id_: FrameId
496
+
497
+ #: Identifier of the loader associated with this frame.
498
+ loader_id: network.LoaderId
499
+
500
+ #: Frame document's URL without fragment.
501
+ url: str
502
+
503
+ #: Frame document's registered domain, taking the public suffixes list into account.
504
+ #: Extracted from the Frame's url.
505
+ #: Example URLs: http://www.google.com/file.html -> "google.com"
506
+ #: http://a.b.co.uk/file.html -> "b.co.uk"
507
+ domain_and_registry: str
508
+
509
+ #: Frame document's security origin.
510
+ security_origin: str
511
+
512
+ #: Frame document's mimeType as determined by the browser.
513
+ mime_type: str
514
+
515
+ #: Indicates whether the main document is a secure context and explains why that is the case.
516
+ secure_context_type: SecureContextType
517
+
518
+ #: Indicates whether this is a cross origin isolated context.
519
+ cross_origin_isolated_context_type: CrossOriginIsolatedContextType
520
+
521
+ #: Indicated which gated APIs / features are available.
522
+ gated_api_features: typing.List[GatedAPIFeatures]
523
+
524
+ #: Parent frame identifier.
525
+ parent_id: typing.Optional[FrameId] = None
526
+
527
+ #: Frame's name as specified in the tag.
528
+ name: typing.Optional[str] = None
529
+
530
+ #: Frame document's URL fragment including the '#'.
531
+ url_fragment: typing.Optional[str] = None
532
+
533
+ #: Additional details about the frame document's security origin.
534
+ security_origin_details: typing.Optional[SecurityOriginDetails] = None
535
+
536
+ #: If the frame failed to load, this contains the URL that could not be loaded. Note that unlike url above, this URL may contain a fragment.
537
+ unreachable_url: typing.Optional[str] = None
538
+
539
+ #: Indicates whether this frame was tagged as an ad and why.
540
+ ad_frame_status: typing.Optional[AdFrameStatus] = None
541
+
542
+ def to_json(self) -> T_JSON_DICT:
543
+ json: T_JSON_DICT = dict()
544
+ json['id'] = self.id_.to_json()
545
+ json['loaderId'] = self.loader_id.to_json()
546
+ json['url'] = self.url
547
+ json['domainAndRegistry'] = self.domain_and_registry
548
+ json['securityOrigin'] = self.security_origin
549
+ json['mimeType'] = self.mime_type
550
+ json['secureContextType'] = self.secure_context_type.to_json()
551
+ json['crossOriginIsolatedContextType'] = self.cross_origin_isolated_context_type.to_json()
552
+ json['gatedAPIFeatures'] = [i.to_json() for i in self.gated_api_features]
553
+ if self.parent_id is not None:
554
+ json['parentId'] = self.parent_id.to_json()
555
+ if self.name is not None:
556
+ json['name'] = self.name
557
+ if self.url_fragment is not None:
558
+ json['urlFragment'] = self.url_fragment
559
+ if self.security_origin_details is not None:
560
+ json['securityOriginDetails'] = self.security_origin_details.to_json()
561
+ if self.unreachable_url is not None:
562
+ json['unreachableUrl'] = self.unreachable_url
563
+ if self.ad_frame_status is not None:
564
+ json['adFrameStatus'] = self.ad_frame_status.to_json()
565
+ return json
566
+
567
+ @classmethod
568
+ def from_json(cls, json: T_JSON_DICT) -> Frame:
569
+ return cls(
570
+ id_=FrameId.from_json(json['id']),
571
+ loader_id=network.LoaderId.from_json(json['loaderId']),
572
+ url=str(json['url']),
573
+ domain_and_registry=str(json['domainAndRegistry']),
574
+ security_origin=str(json['securityOrigin']),
575
+ mime_type=str(json['mimeType']),
576
+ secure_context_type=SecureContextType.from_json(json['secureContextType']),
577
+ cross_origin_isolated_context_type=CrossOriginIsolatedContextType.from_json(json['crossOriginIsolatedContextType']),
578
+ gated_api_features=[GatedAPIFeatures.from_json(i) for i in json['gatedAPIFeatures']],
579
+ parent_id=FrameId.from_json(json['parentId']) if json.get('parentId', None) is not None else None,
580
+ name=str(json['name']) if json.get('name', None) is not None else None,
581
+ url_fragment=str(json['urlFragment']) if json.get('urlFragment', None) is not None else None,
582
+ security_origin_details=SecurityOriginDetails.from_json(json['securityOriginDetails']) if json.get('securityOriginDetails', None) is not None else None,
583
+ unreachable_url=str(json['unreachableUrl']) if json.get('unreachableUrl', None) is not None else None,
584
+ ad_frame_status=AdFrameStatus.from_json(json['adFrameStatus']) if json.get('adFrameStatus', None) is not None else None,
585
+ )
586
+
587
+
588
+ @dataclass
589
+ class FrameResource:
590
+ '''
591
+ Information about the Resource on the page.
592
+ '''
593
+ #: Resource URL.
594
+ url: str
595
+
596
+ #: Type of this resource.
597
+ type_: network.ResourceType
598
+
599
+ #: Resource mimeType as determined by the browser.
600
+ mime_type: str
601
+
602
+ #: last-modified timestamp as reported by server.
603
+ last_modified: typing.Optional[network.TimeSinceEpoch] = None
604
+
605
+ #: Resource content size.
606
+ content_size: typing.Optional[float] = None
607
+
608
+ #: True if the resource failed to load.
609
+ failed: typing.Optional[bool] = None
610
+
611
+ #: True if the resource was canceled during loading.
612
+ canceled: typing.Optional[bool] = None
613
+
614
+ def to_json(self) -> T_JSON_DICT:
615
+ json: T_JSON_DICT = dict()
616
+ json['url'] = self.url
617
+ json['type'] = self.type_.to_json()
618
+ json['mimeType'] = self.mime_type
619
+ if self.last_modified is not None:
620
+ json['lastModified'] = self.last_modified.to_json()
621
+ if self.content_size is not None:
622
+ json['contentSize'] = self.content_size
623
+ if self.failed is not None:
624
+ json['failed'] = self.failed
625
+ if self.canceled is not None:
626
+ json['canceled'] = self.canceled
627
+ return json
628
+
629
+ @classmethod
630
+ def from_json(cls, json: T_JSON_DICT) -> FrameResource:
631
+ return cls(
632
+ url=str(json['url']),
633
+ type_=network.ResourceType.from_json(json['type']),
634
+ mime_type=str(json['mimeType']),
635
+ last_modified=network.TimeSinceEpoch.from_json(json['lastModified']) if json.get('lastModified', None) is not None else None,
636
+ content_size=float(json['contentSize']) if json.get('contentSize', None) is not None else None,
637
+ failed=bool(json['failed']) if json.get('failed', None) is not None else None,
638
+ canceled=bool(json['canceled']) if json.get('canceled', None) is not None else None,
639
+ )
640
+
641
+
642
+ @dataclass
643
+ class FrameResourceTree:
644
+ '''
645
+ Information about the Frame hierarchy along with their cached resources.
646
+ '''
647
+ #: Frame information for this tree item.
648
+ frame: Frame
649
+
650
+ #: Information about frame resources.
651
+ resources: typing.List[FrameResource]
652
+
653
+ #: Child frames.
654
+ child_frames: typing.Optional[typing.List[FrameResourceTree]] = None
655
+
656
+ def to_json(self) -> T_JSON_DICT:
657
+ json: T_JSON_DICT = dict()
658
+ json['frame'] = self.frame.to_json()
659
+ json['resources'] = [i.to_json() for i in self.resources]
660
+ if self.child_frames is not None:
661
+ json['childFrames'] = [i.to_json() for i in self.child_frames]
662
+ return json
663
+
664
+ @classmethod
665
+ def from_json(cls, json: T_JSON_DICT) -> FrameResourceTree:
666
+ return cls(
667
+ frame=Frame.from_json(json['frame']),
668
+ resources=[FrameResource.from_json(i) for i in json['resources']],
669
+ child_frames=[FrameResourceTree.from_json(i) for i in json['childFrames']] if json.get('childFrames', None) is not None else None,
670
+ )
671
+
672
+
673
+ @dataclass
674
+ class FrameTree:
675
+ '''
676
+ Information about the Frame hierarchy.
677
+ '''
678
+ #: Frame information for this tree item.
679
+ frame: Frame
680
+
681
+ #: Child frames.
682
+ child_frames: typing.Optional[typing.List[FrameTree]] = None
683
+
684
+ def to_json(self) -> T_JSON_DICT:
685
+ json: T_JSON_DICT = dict()
686
+ json['frame'] = self.frame.to_json()
687
+ if self.child_frames is not None:
688
+ json['childFrames'] = [i.to_json() for i in self.child_frames]
689
+ return json
690
+
691
+ @classmethod
692
+ def from_json(cls, json: T_JSON_DICT) -> FrameTree:
693
+ return cls(
694
+ frame=Frame.from_json(json['frame']),
695
+ child_frames=[FrameTree.from_json(i) for i in json['childFrames']] if json.get('childFrames', None) is not None else None,
696
+ )
697
+
698
+
699
+ class ScriptIdentifier(str):
700
+ '''
701
+ Unique script identifier.
702
+ '''
703
+ def to_json(self) -> str:
704
+ return self
705
+
706
+ @classmethod
707
+ def from_json(cls, json: str) -> ScriptIdentifier:
708
+ return cls(json)
709
+
710
+ def __repr__(self):
711
+ return 'ScriptIdentifier({})'.format(super().__repr__())
712
+
713
+
714
+ class TransitionType(enum.Enum):
715
+ '''
716
+ Transition type.
717
+ '''
718
+ LINK = "link"
719
+ TYPED = "typed"
720
+ ADDRESS_BAR = "address_bar"
721
+ AUTO_BOOKMARK = "auto_bookmark"
722
+ AUTO_SUBFRAME = "auto_subframe"
723
+ MANUAL_SUBFRAME = "manual_subframe"
724
+ GENERATED = "generated"
725
+ AUTO_TOPLEVEL = "auto_toplevel"
726
+ FORM_SUBMIT = "form_submit"
727
+ RELOAD = "reload"
728
+ KEYWORD = "keyword"
729
+ KEYWORD_GENERATED = "keyword_generated"
730
+ OTHER = "other"
731
+
732
+ def to_json(self) -> str:
733
+ return self.value
734
+
735
+ @classmethod
736
+ def from_json(cls, json: str) -> TransitionType:
737
+ return cls(json)
738
+
739
+
740
+ @dataclass
741
+ class NavigationEntry:
742
+ '''
743
+ Navigation history entry.
744
+ '''
745
+ #: Unique id of the navigation history entry.
746
+ id_: int
747
+
748
+ #: URL of the navigation history entry.
749
+ url: str
750
+
751
+ #: URL that the user typed in the url bar.
752
+ user_typed_url: str
753
+
754
+ #: Title of the navigation history entry.
755
+ title: str
756
+
757
+ #: Transition type.
758
+ transition_type: TransitionType
759
+
760
+ def to_json(self) -> T_JSON_DICT:
761
+ json: T_JSON_DICT = dict()
762
+ json['id'] = self.id_
763
+ json['url'] = self.url
764
+ json['userTypedURL'] = self.user_typed_url
765
+ json['title'] = self.title
766
+ json['transitionType'] = self.transition_type.to_json()
767
+ return json
768
+
769
+ @classmethod
770
+ def from_json(cls, json: T_JSON_DICT) -> NavigationEntry:
771
+ return cls(
772
+ id_=int(json['id']),
773
+ url=str(json['url']),
774
+ user_typed_url=str(json['userTypedURL']),
775
+ title=str(json['title']),
776
+ transition_type=TransitionType.from_json(json['transitionType']),
777
+ )
778
+
779
+
780
+ @dataclass
781
+ class ScreencastFrameMetadata:
782
+ '''
783
+ Screencast frame metadata.
784
+ '''
785
+ #: Top offset in DIP.
786
+ offset_top: float
787
+
788
+ #: Page scale factor.
789
+ page_scale_factor: float
790
+
791
+ #: Device screen width in DIP.
792
+ device_width: float
793
+
794
+ #: Device screen height in DIP.
795
+ device_height: float
796
+
797
+ #: Position of horizontal scroll in CSS pixels.
798
+ scroll_offset_x: float
799
+
800
+ #: Position of vertical scroll in CSS pixels.
801
+ scroll_offset_y: float
802
+
803
+ #: Frame swap timestamp.
804
+ timestamp: typing.Optional[network.TimeSinceEpoch] = None
805
+
806
+ def to_json(self) -> T_JSON_DICT:
807
+ json: T_JSON_DICT = dict()
808
+ json['offsetTop'] = self.offset_top
809
+ json['pageScaleFactor'] = self.page_scale_factor
810
+ json['deviceWidth'] = self.device_width
811
+ json['deviceHeight'] = self.device_height
812
+ json['scrollOffsetX'] = self.scroll_offset_x
813
+ json['scrollOffsetY'] = self.scroll_offset_y
814
+ if self.timestamp is not None:
815
+ json['timestamp'] = self.timestamp.to_json()
816
+ return json
817
+
818
+ @classmethod
819
+ def from_json(cls, json: T_JSON_DICT) -> ScreencastFrameMetadata:
820
+ return cls(
821
+ offset_top=float(json['offsetTop']),
822
+ page_scale_factor=float(json['pageScaleFactor']),
823
+ device_width=float(json['deviceWidth']),
824
+ device_height=float(json['deviceHeight']),
825
+ scroll_offset_x=float(json['scrollOffsetX']),
826
+ scroll_offset_y=float(json['scrollOffsetY']),
827
+ timestamp=network.TimeSinceEpoch.from_json(json['timestamp']) if json.get('timestamp', None) is not None else None,
828
+ )
829
+
830
+
831
+ class DialogType(enum.Enum):
832
+ '''
833
+ Javascript dialog type.
834
+ '''
835
+ ALERT = "alert"
836
+ CONFIRM = "confirm"
837
+ PROMPT = "prompt"
838
+ BEFOREUNLOAD = "beforeunload"
839
+
840
+ def to_json(self) -> str:
841
+ return self.value
842
+
843
+ @classmethod
844
+ def from_json(cls, json: str) -> DialogType:
845
+ return cls(json)
846
+
847
+
848
+ @dataclass
849
+ class AppManifestError:
850
+ '''
851
+ Error while paring app manifest.
852
+ '''
853
+ #: Error message.
854
+ message: str
855
+
856
+ #: If critical, this is a non-recoverable parse error.
857
+ critical: int
858
+
859
+ #: Error line.
860
+ line: int
861
+
862
+ #: Error column.
863
+ column: int
864
+
865
+ def to_json(self) -> T_JSON_DICT:
866
+ json: T_JSON_DICT = dict()
867
+ json['message'] = self.message
868
+ json['critical'] = self.critical
869
+ json['line'] = self.line
870
+ json['column'] = self.column
871
+ return json
872
+
873
+ @classmethod
874
+ def from_json(cls, json: T_JSON_DICT) -> AppManifestError:
875
+ return cls(
876
+ message=str(json['message']),
877
+ critical=int(json['critical']),
878
+ line=int(json['line']),
879
+ column=int(json['column']),
880
+ )
881
+
882
+
883
+ @dataclass
884
+ class AppManifestParsedProperties:
885
+ '''
886
+ Parsed app manifest properties.
887
+ '''
888
+ #: Computed scope value
889
+ scope: str
890
+
891
+ def to_json(self) -> T_JSON_DICT:
892
+ json: T_JSON_DICT = dict()
893
+ json['scope'] = self.scope
894
+ return json
895
+
896
+ @classmethod
897
+ def from_json(cls, json: T_JSON_DICT) -> AppManifestParsedProperties:
898
+ return cls(
899
+ scope=str(json['scope']),
900
+ )
901
+
902
+
903
+ @dataclass
904
+ class LayoutViewport:
905
+ '''
906
+ Layout viewport position and dimensions.
907
+ '''
908
+ #: Horizontal offset relative to the document (CSS pixels).
909
+ page_x: int
910
+
911
+ #: Vertical offset relative to the document (CSS pixels).
912
+ page_y: int
913
+
914
+ #: Width (CSS pixels), excludes scrollbar if present.
915
+ client_width: int
916
+
917
+ #: Height (CSS pixels), excludes scrollbar if present.
918
+ client_height: int
919
+
920
+ def to_json(self) -> T_JSON_DICT:
921
+ json: T_JSON_DICT = dict()
922
+ json['pageX'] = self.page_x
923
+ json['pageY'] = self.page_y
924
+ json['clientWidth'] = self.client_width
925
+ json['clientHeight'] = self.client_height
926
+ return json
927
+
928
+ @classmethod
929
+ def from_json(cls, json: T_JSON_DICT) -> LayoutViewport:
930
+ return cls(
931
+ page_x=int(json['pageX']),
932
+ page_y=int(json['pageY']),
933
+ client_width=int(json['clientWidth']),
934
+ client_height=int(json['clientHeight']),
935
+ )
936
+
937
+
938
+ @dataclass
939
+ class VisualViewport:
940
+ '''
941
+ Visual viewport position, dimensions, and scale.
942
+ '''
943
+ #: Horizontal offset relative to the layout viewport (CSS pixels).
944
+ offset_x: float
945
+
946
+ #: Vertical offset relative to the layout viewport (CSS pixels).
947
+ offset_y: float
948
+
949
+ #: Horizontal offset relative to the document (CSS pixels).
950
+ page_x: float
951
+
952
+ #: Vertical offset relative to the document (CSS pixels).
953
+ page_y: float
954
+
955
+ #: Width (CSS pixels), excludes scrollbar if present.
956
+ client_width: float
957
+
958
+ #: Height (CSS pixels), excludes scrollbar if present.
959
+ client_height: float
960
+
961
+ #: Scale relative to the ideal viewport (size at width=device-width).
962
+ scale: float
963
+
964
+ #: Page zoom factor (CSS to device independent pixels ratio).
965
+ zoom: typing.Optional[float] = None
966
+
967
+ def to_json(self) -> T_JSON_DICT:
968
+ json: T_JSON_DICT = dict()
969
+ json['offsetX'] = self.offset_x
970
+ json['offsetY'] = self.offset_y
971
+ json['pageX'] = self.page_x
972
+ json['pageY'] = self.page_y
973
+ json['clientWidth'] = self.client_width
974
+ json['clientHeight'] = self.client_height
975
+ json['scale'] = self.scale
976
+ if self.zoom is not None:
977
+ json['zoom'] = self.zoom
978
+ return json
979
+
980
+ @classmethod
981
+ def from_json(cls, json: T_JSON_DICT) -> VisualViewport:
982
+ return cls(
983
+ offset_x=float(json['offsetX']),
984
+ offset_y=float(json['offsetY']),
985
+ page_x=float(json['pageX']),
986
+ page_y=float(json['pageY']),
987
+ client_width=float(json['clientWidth']),
988
+ client_height=float(json['clientHeight']),
989
+ scale=float(json['scale']),
990
+ zoom=float(json['zoom']) if json.get('zoom', None) is not None else None,
991
+ )
992
+
993
+
994
+ @dataclass
995
+ class Viewport:
996
+ '''
997
+ Viewport for capturing screenshot.
998
+ '''
999
+ #: X offset in device independent pixels (dip).
1000
+ x: float
1001
+
1002
+ #: Y offset in device independent pixels (dip).
1003
+ y: float
1004
+
1005
+ #: Rectangle width in device independent pixels (dip).
1006
+ width: float
1007
+
1008
+ #: Rectangle height in device independent pixels (dip).
1009
+ height: float
1010
+
1011
+ #: Page scale factor.
1012
+ scale: float
1013
+
1014
+ def to_json(self) -> T_JSON_DICT:
1015
+ json: T_JSON_DICT = dict()
1016
+ json['x'] = self.x
1017
+ json['y'] = self.y
1018
+ json['width'] = self.width
1019
+ json['height'] = self.height
1020
+ json['scale'] = self.scale
1021
+ return json
1022
+
1023
+ @classmethod
1024
+ def from_json(cls, json: T_JSON_DICT) -> Viewport:
1025
+ return cls(
1026
+ x=float(json['x']),
1027
+ y=float(json['y']),
1028
+ width=float(json['width']),
1029
+ height=float(json['height']),
1030
+ scale=float(json['scale']),
1031
+ )
1032
+
1033
+
1034
+ @dataclass
1035
+ class FontFamilies:
1036
+ '''
1037
+ Generic font families collection.
1038
+ '''
1039
+ #: The standard font-family.
1040
+ standard: typing.Optional[str] = None
1041
+
1042
+ #: The fixed font-family.
1043
+ fixed: typing.Optional[str] = None
1044
+
1045
+ #: The serif font-family.
1046
+ serif: typing.Optional[str] = None
1047
+
1048
+ #: The sansSerif font-family.
1049
+ sans_serif: typing.Optional[str] = None
1050
+
1051
+ #: The cursive font-family.
1052
+ cursive: typing.Optional[str] = None
1053
+
1054
+ #: The fantasy font-family.
1055
+ fantasy: typing.Optional[str] = None
1056
+
1057
+ #: The math font-family.
1058
+ math: typing.Optional[str] = None
1059
+
1060
+ def to_json(self) -> T_JSON_DICT:
1061
+ json: T_JSON_DICT = dict()
1062
+ if self.standard is not None:
1063
+ json['standard'] = self.standard
1064
+ if self.fixed is not None:
1065
+ json['fixed'] = self.fixed
1066
+ if self.serif is not None:
1067
+ json['serif'] = self.serif
1068
+ if self.sans_serif is not None:
1069
+ json['sansSerif'] = self.sans_serif
1070
+ if self.cursive is not None:
1071
+ json['cursive'] = self.cursive
1072
+ if self.fantasy is not None:
1073
+ json['fantasy'] = self.fantasy
1074
+ if self.math is not None:
1075
+ json['math'] = self.math
1076
+ return json
1077
+
1078
+ @classmethod
1079
+ def from_json(cls, json: T_JSON_DICT) -> FontFamilies:
1080
+ return cls(
1081
+ standard=str(json['standard']) if json.get('standard', None) is not None else None,
1082
+ fixed=str(json['fixed']) if json.get('fixed', None) is not None else None,
1083
+ serif=str(json['serif']) if json.get('serif', None) is not None else None,
1084
+ sans_serif=str(json['sansSerif']) if json.get('sansSerif', None) is not None else None,
1085
+ cursive=str(json['cursive']) if json.get('cursive', None) is not None else None,
1086
+ fantasy=str(json['fantasy']) if json.get('fantasy', None) is not None else None,
1087
+ math=str(json['math']) if json.get('math', None) is not None else None,
1088
+ )
1089
+
1090
+
1091
+ @dataclass
1092
+ class ScriptFontFamilies:
1093
+ '''
1094
+ Font families collection for a script.
1095
+ '''
1096
+ #: Name of the script which these font families are defined for.
1097
+ script: str
1098
+
1099
+ #: Generic font families collection for the script.
1100
+ font_families: FontFamilies
1101
+
1102
+ def to_json(self) -> T_JSON_DICT:
1103
+ json: T_JSON_DICT = dict()
1104
+ json['script'] = self.script
1105
+ json['fontFamilies'] = self.font_families.to_json()
1106
+ return json
1107
+
1108
+ @classmethod
1109
+ def from_json(cls, json: T_JSON_DICT) -> ScriptFontFamilies:
1110
+ return cls(
1111
+ script=str(json['script']),
1112
+ font_families=FontFamilies.from_json(json['fontFamilies']),
1113
+ )
1114
+
1115
+
1116
+ @dataclass
1117
+ class FontSizes:
1118
+ '''
1119
+ Default font sizes.
1120
+ '''
1121
+ #: Default standard font size.
1122
+ standard: typing.Optional[int] = None
1123
+
1124
+ #: Default fixed font size.
1125
+ fixed: typing.Optional[int] = None
1126
+
1127
+ def to_json(self) -> T_JSON_DICT:
1128
+ json: T_JSON_DICT = dict()
1129
+ if self.standard is not None:
1130
+ json['standard'] = self.standard
1131
+ if self.fixed is not None:
1132
+ json['fixed'] = self.fixed
1133
+ return json
1134
+
1135
+ @classmethod
1136
+ def from_json(cls, json: T_JSON_DICT) -> FontSizes:
1137
+ return cls(
1138
+ standard=int(json['standard']) if json.get('standard', None) is not None else None,
1139
+ fixed=int(json['fixed']) if json.get('fixed', None) is not None else None,
1140
+ )
1141
+
1142
+
1143
+ class ClientNavigationReason(enum.Enum):
1144
+ ANCHOR_CLICK = "anchorClick"
1145
+ FORM_SUBMISSION_GET = "formSubmissionGet"
1146
+ FORM_SUBMISSION_POST = "formSubmissionPost"
1147
+ HTTP_HEADER_REFRESH = "httpHeaderRefresh"
1148
+ INITIAL_FRAME_NAVIGATION = "initialFrameNavigation"
1149
+ META_TAG_REFRESH = "metaTagRefresh"
1150
+ OTHER = "other"
1151
+ PAGE_BLOCK_INTERSTITIAL = "pageBlockInterstitial"
1152
+ RELOAD = "reload"
1153
+ SCRIPT_INITIATED = "scriptInitiated"
1154
+
1155
+ def to_json(self) -> str:
1156
+ return self.value
1157
+
1158
+ @classmethod
1159
+ def from_json(cls, json: str) -> ClientNavigationReason:
1160
+ return cls(json)
1161
+
1162
+
1163
+ class ClientNavigationDisposition(enum.Enum):
1164
+ CURRENT_TAB = "currentTab"
1165
+ NEW_TAB = "newTab"
1166
+ NEW_WINDOW = "newWindow"
1167
+ DOWNLOAD = "download"
1168
+
1169
+ def to_json(self) -> str:
1170
+ return self.value
1171
+
1172
+ @classmethod
1173
+ def from_json(cls, json: str) -> ClientNavigationDisposition:
1174
+ return cls(json)
1175
+
1176
+
1177
+ @dataclass
1178
+ class InstallabilityErrorArgument:
1179
+ #: Argument name (e.g. name:'minimum-icon-size-in-pixels').
1180
+ name: str
1181
+
1182
+ #: Argument value (e.g. value:'64').
1183
+ value: str
1184
+
1185
+ def to_json(self) -> T_JSON_DICT:
1186
+ json: T_JSON_DICT = dict()
1187
+ json['name'] = self.name
1188
+ json['value'] = self.value
1189
+ return json
1190
+
1191
+ @classmethod
1192
+ def from_json(cls, json: T_JSON_DICT) -> InstallabilityErrorArgument:
1193
+ return cls(
1194
+ name=str(json['name']),
1195
+ value=str(json['value']),
1196
+ )
1197
+
1198
+
1199
+ @dataclass
1200
+ class InstallabilityError:
1201
+ '''
1202
+ The installability error
1203
+ '''
1204
+ #: The error id (e.g. 'manifest-missing-suitable-icon').
1205
+ error_id: str
1206
+
1207
+ #: The list of error arguments (e.g. {name:'minimum-icon-size-in-pixels', value:'64'}).
1208
+ error_arguments: typing.List[InstallabilityErrorArgument]
1209
+
1210
+ def to_json(self) -> T_JSON_DICT:
1211
+ json: T_JSON_DICT = dict()
1212
+ json['errorId'] = self.error_id
1213
+ json['errorArguments'] = [i.to_json() for i in self.error_arguments]
1214
+ return json
1215
+
1216
+ @classmethod
1217
+ def from_json(cls, json: T_JSON_DICT) -> InstallabilityError:
1218
+ return cls(
1219
+ error_id=str(json['errorId']),
1220
+ error_arguments=[InstallabilityErrorArgument.from_json(i) for i in json['errorArguments']],
1221
+ )
1222
+
1223
+
1224
+ class ReferrerPolicy(enum.Enum):
1225
+ '''
1226
+ The referring-policy used for the navigation.
1227
+ '''
1228
+ NO_REFERRER = "noReferrer"
1229
+ NO_REFERRER_WHEN_DOWNGRADE = "noReferrerWhenDowngrade"
1230
+ ORIGIN = "origin"
1231
+ ORIGIN_WHEN_CROSS_ORIGIN = "originWhenCrossOrigin"
1232
+ SAME_ORIGIN = "sameOrigin"
1233
+ STRICT_ORIGIN = "strictOrigin"
1234
+ STRICT_ORIGIN_WHEN_CROSS_ORIGIN = "strictOriginWhenCrossOrigin"
1235
+ UNSAFE_URL = "unsafeUrl"
1236
+
1237
+ def to_json(self) -> str:
1238
+ return self.value
1239
+
1240
+ @classmethod
1241
+ def from_json(cls, json: str) -> ReferrerPolicy:
1242
+ return cls(json)
1243
+
1244
+
1245
+ @dataclass
1246
+ class CompilationCacheParams:
1247
+ '''
1248
+ Per-script compilation cache parameters for ``Page.produceCompilationCache``
1249
+ '''
1250
+ #: The URL of the script to produce a compilation cache entry for.
1251
+ url: str
1252
+
1253
+ #: A hint to the backend whether eager compilation is recommended.
1254
+ #: (the actual compilation mode used is upon backend discretion).
1255
+ eager: typing.Optional[bool] = None
1256
+
1257
+ def to_json(self) -> T_JSON_DICT:
1258
+ json: T_JSON_DICT = dict()
1259
+ json['url'] = self.url
1260
+ if self.eager is not None:
1261
+ json['eager'] = self.eager
1262
+ return json
1263
+
1264
+ @classmethod
1265
+ def from_json(cls, json: T_JSON_DICT) -> CompilationCacheParams:
1266
+ return cls(
1267
+ url=str(json['url']),
1268
+ eager=bool(json['eager']) if json.get('eager', None) is not None else None,
1269
+ )
1270
+
1271
+
1272
+ @dataclass
1273
+ class FileFilter:
1274
+ name: typing.Optional[str] = None
1275
+
1276
+ accepts: typing.Optional[typing.List[str]] = None
1277
+
1278
+ def to_json(self) -> T_JSON_DICT:
1279
+ json: T_JSON_DICT = dict()
1280
+ if self.name is not None:
1281
+ json['name'] = self.name
1282
+ if self.accepts is not None:
1283
+ json['accepts'] = [i for i in self.accepts]
1284
+ return json
1285
+
1286
+ @classmethod
1287
+ def from_json(cls, json: T_JSON_DICT) -> FileFilter:
1288
+ return cls(
1289
+ name=str(json['name']) if json.get('name', None) is not None else None,
1290
+ accepts=[str(i) for i in json['accepts']] if json.get('accepts', None) is not None else None,
1291
+ )
1292
+
1293
+
1294
+ @dataclass
1295
+ class FileHandler:
1296
+ action: str
1297
+
1298
+ name: str
1299
+
1300
+ #: Won't repeat the enums, using string for easy comparison. Same as the
1301
+ #: other enums below.
1302
+ launch_type: str
1303
+
1304
+ icons: typing.Optional[typing.List[ImageResource]] = None
1305
+
1306
+ #: Mimic a map, name is the key, accepts is the value.
1307
+ accepts: typing.Optional[typing.List[FileFilter]] = None
1308
+
1309
+ def to_json(self) -> T_JSON_DICT:
1310
+ json: T_JSON_DICT = dict()
1311
+ json['action'] = self.action
1312
+ json['name'] = self.name
1313
+ json['launchType'] = self.launch_type
1314
+ if self.icons is not None:
1315
+ json['icons'] = [i.to_json() for i in self.icons]
1316
+ if self.accepts is not None:
1317
+ json['accepts'] = [i.to_json() for i in self.accepts]
1318
+ return json
1319
+
1320
+ @classmethod
1321
+ def from_json(cls, json: T_JSON_DICT) -> FileHandler:
1322
+ return cls(
1323
+ action=str(json['action']),
1324
+ name=str(json['name']),
1325
+ launch_type=str(json['launchType']),
1326
+ icons=[ImageResource.from_json(i) for i in json['icons']] if json.get('icons', None) is not None else None,
1327
+ accepts=[FileFilter.from_json(i) for i in json['accepts']] if json.get('accepts', None) is not None else None,
1328
+ )
1329
+
1330
+
1331
+ @dataclass
1332
+ class ImageResource:
1333
+ '''
1334
+ The image definition used in both icon and screenshot.
1335
+ '''
1336
+ #: The src field in the definition, but changing to url in favor of
1337
+ #: consistency.
1338
+ url: str
1339
+
1340
+ sizes: typing.Optional[str] = None
1341
+
1342
+ type_: typing.Optional[str] = None
1343
+
1344
+ def to_json(self) -> T_JSON_DICT:
1345
+ json: T_JSON_DICT = dict()
1346
+ json['url'] = self.url
1347
+ if self.sizes is not None:
1348
+ json['sizes'] = self.sizes
1349
+ if self.type_ is not None:
1350
+ json['type'] = self.type_
1351
+ return json
1352
+
1353
+ @classmethod
1354
+ def from_json(cls, json: T_JSON_DICT) -> ImageResource:
1355
+ return cls(
1356
+ url=str(json['url']),
1357
+ sizes=str(json['sizes']) if json.get('sizes', None) is not None else None,
1358
+ type_=str(json['type']) if json.get('type', None) is not None else None,
1359
+ )
1360
+
1361
+
1362
+ @dataclass
1363
+ class LaunchHandler:
1364
+ client_mode: str
1365
+
1366
+ def to_json(self) -> T_JSON_DICT:
1367
+ json: T_JSON_DICT = dict()
1368
+ json['clientMode'] = self.client_mode
1369
+ return json
1370
+
1371
+ @classmethod
1372
+ def from_json(cls, json: T_JSON_DICT) -> LaunchHandler:
1373
+ return cls(
1374
+ client_mode=str(json['clientMode']),
1375
+ )
1376
+
1377
+
1378
+ @dataclass
1379
+ class ProtocolHandler:
1380
+ protocol: str
1381
+
1382
+ url: str
1383
+
1384
+ def to_json(self) -> T_JSON_DICT:
1385
+ json: T_JSON_DICT = dict()
1386
+ json['protocol'] = self.protocol
1387
+ json['url'] = self.url
1388
+ return json
1389
+
1390
+ @classmethod
1391
+ def from_json(cls, json: T_JSON_DICT) -> ProtocolHandler:
1392
+ return cls(
1393
+ protocol=str(json['protocol']),
1394
+ url=str(json['url']),
1395
+ )
1396
+
1397
+
1398
+ @dataclass
1399
+ class RelatedApplication:
1400
+ url: str
1401
+
1402
+ id_: typing.Optional[str] = None
1403
+
1404
+ def to_json(self) -> T_JSON_DICT:
1405
+ json: T_JSON_DICT = dict()
1406
+ json['url'] = self.url
1407
+ if self.id_ is not None:
1408
+ json['id'] = self.id_
1409
+ return json
1410
+
1411
+ @classmethod
1412
+ def from_json(cls, json: T_JSON_DICT) -> RelatedApplication:
1413
+ return cls(
1414
+ url=str(json['url']),
1415
+ id_=str(json['id']) if json.get('id', None) is not None else None,
1416
+ )
1417
+
1418
+
1419
+ @dataclass
1420
+ class ScopeExtension:
1421
+ #: Instead of using tuple, this field always returns the serialized string
1422
+ #: for easy understanding and comparison.
1423
+ origin: str
1424
+
1425
+ has_origin_wildcard: bool
1426
+
1427
+ def to_json(self) -> T_JSON_DICT:
1428
+ json: T_JSON_DICT = dict()
1429
+ json['origin'] = self.origin
1430
+ json['hasOriginWildcard'] = self.has_origin_wildcard
1431
+ return json
1432
+
1433
+ @classmethod
1434
+ def from_json(cls, json: T_JSON_DICT) -> ScopeExtension:
1435
+ return cls(
1436
+ origin=str(json['origin']),
1437
+ has_origin_wildcard=bool(json['hasOriginWildcard']),
1438
+ )
1439
+
1440
+
1441
+ @dataclass
1442
+ class Screenshot:
1443
+ image: ImageResource
1444
+
1445
+ form_factor: str
1446
+
1447
+ label: typing.Optional[str] = None
1448
+
1449
+ def to_json(self) -> T_JSON_DICT:
1450
+ json: T_JSON_DICT = dict()
1451
+ json['image'] = self.image.to_json()
1452
+ json['formFactor'] = self.form_factor
1453
+ if self.label is not None:
1454
+ json['label'] = self.label
1455
+ return json
1456
+
1457
+ @classmethod
1458
+ def from_json(cls, json: T_JSON_DICT) -> Screenshot:
1459
+ return cls(
1460
+ image=ImageResource.from_json(json['image']),
1461
+ form_factor=str(json['formFactor']),
1462
+ label=str(json['label']) if json.get('label', None) is not None else None,
1463
+ )
1464
+
1465
+
1466
+ @dataclass
1467
+ class ShareTarget:
1468
+ action: str
1469
+
1470
+ method: str
1471
+
1472
+ enctype: str
1473
+
1474
+ #: Embed the ShareTargetParams
1475
+ title: typing.Optional[str] = None
1476
+
1477
+ text: typing.Optional[str] = None
1478
+
1479
+ url: typing.Optional[str] = None
1480
+
1481
+ files: typing.Optional[typing.List[FileFilter]] = None
1482
+
1483
+ def to_json(self) -> T_JSON_DICT:
1484
+ json: T_JSON_DICT = dict()
1485
+ json['action'] = self.action
1486
+ json['method'] = self.method
1487
+ json['enctype'] = self.enctype
1488
+ if self.title is not None:
1489
+ json['title'] = self.title
1490
+ if self.text is not None:
1491
+ json['text'] = self.text
1492
+ if self.url is not None:
1493
+ json['url'] = self.url
1494
+ if self.files is not None:
1495
+ json['files'] = [i.to_json() for i in self.files]
1496
+ return json
1497
+
1498
+ @classmethod
1499
+ def from_json(cls, json: T_JSON_DICT) -> ShareTarget:
1500
+ return cls(
1501
+ action=str(json['action']),
1502
+ method=str(json['method']),
1503
+ enctype=str(json['enctype']),
1504
+ title=str(json['title']) if json.get('title', None) is not None else None,
1505
+ text=str(json['text']) if json.get('text', None) is not None else None,
1506
+ url=str(json['url']) if json.get('url', None) is not None else None,
1507
+ files=[FileFilter.from_json(i) for i in json['files']] if json.get('files', None) is not None else None,
1508
+ )
1509
+
1510
+
1511
+ @dataclass
1512
+ class Shortcut:
1513
+ name: str
1514
+
1515
+ url: str
1516
+
1517
+ def to_json(self) -> T_JSON_DICT:
1518
+ json: T_JSON_DICT = dict()
1519
+ json['name'] = self.name
1520
+ json['url'] = self.url
1521
+ return json
1522
+
1523
+ @classmethod
1524
+ def from_json(cls, json: T_JSON_DICT) -> Shortcut:
1525
+ return cls(
1526
+ name=str(json['name']),
1527
+ url=str(json['url']),
1528
+ )
1529
+
1530
+
1531
+ @dataclass
1532
+ class WebAppManifest:
1533
+ background_color: typing.Optional[str] = None
1534
+
1535
+ #: The extra description provided by the manifest.
1536
+ description: typing.Optional[str] = None
1537
+
1538
+ dir_: typing.Optional[str] = None
1539
+
1540
+ display: typing.Optional[str] = None
1541
+
1542
+ #: The overrided display mode controlled by the user.
1543
+ display_overrides: typing.Optional[typing.List[str]] = None
1544
+
1545
+ #: The handlers to open files.
1546
+ file_handlers: typing.Optional[typing.List[FileHandler]] = None
1547
+
1548
+ icons: typing.Optional[typing.List[ImageResource]] = None
1549
+
1550
+ id_: typing.Optional[str] = None
1551
+
1552
+ lang: typing.Optional[str] = None
1553
+
1554
+ #: TODO(crbug.com/1231886): This field is non-standard and part of a Chrome
1555
+ #: experiment. See:
1556
+ #: https://github.com/WICG/web-app-launch/blob/main/launch_handler.md
1557
+ launch_handler: typing.Optional[LaunchHandler] = None
1558
+
1559
+ name: typing.Optional[str] = None
1560
+
1561
+ orientation: typing.Optional[str] = None
1562
+
1563
+ prefer_related_applications: typing.Optional[bool] = None
1564
+
1565
+ #: The handlers to open protocols.
1566
+ protocol_handlers: typing.Optional[typing.List[ProtocolHandler]] = None
1567
+
1568
+ related_applications: typing.Optional[typing.List[RelatedApplication]] = None
1569
+
1570
+ scope: typing.Optional[str] = None
1571
+
1572
+ #: Non-standard, see
1573
+ #: https://github.com/WICG/manifest-incubations/blob/gh-pages/scope_extensions-explainer.md
1574
+ scope_extensions: typing.Optional[typing.List[ScopeExtension]] = None
1575
+
1576
+ #: The screenshots used by chromium.
1577
+ screenshots: typing.Optional[typing.List[Screenshot]] = None
1578
+
1579
+ share_target: typing.Optional[ShareTarget] = None
1580
+
1581
+ short_name: typing.Optional[str] = None
1582
+
1583
+ shortcuts: typing.Optional[typing.List[Shortcut]] = None
1584
+
1585
+ start_url: typing.Optional[str] = None
1586
+
1587
+ theme_color: typing.Optional[str] = None
1588
+
1589
+ def to_json(self) -> T_JSON_DICT:
1590
+ json: T_JSON_DICT = dict()
1591
+ if self.background_color is not None:
1592
+ json['backgroundColor'] = self.background_color
1593
+ if self.description is not None:
1594
+ json['description'] = self.description
1595
+ if self.dir_ is not None:
1596
+ json['dir'] = self.dir_
1597
+ if self.display is not None:
1598
+ json['display'] = self.display
1599
+ if self.display_overrides is not None:
1600
+ json['displayOverrides'] = [i for i in self.display_overrides]
1601
+ if self.file_handlers is not None:
1602
+ json['fileHandlers'] = [i.to_json() for i in self.file_handlers]
1603
+ if self.icons is not None:
1604
+ json['icons'] = [i.to_json() for i in self.icons]
1605
+ if self.id_ is not None:
1606
+ json['id'] = self.id_
1607
+ if self.lang is not None:
1608
+ json['lang'] = self.lang
1609
+ if self.launch_handler is not None:
1610
+ json['launchHandler'] = self.launch_handler.to_json()
1611
+ if self.name is not None:
1612
+ json['name'] = self.name
1613
+ if self.orientation is not None:
1614
+ json['orientation'] = self.orientation
1615
+ if self.prefer_related_applications is not None:
1616
+ json['preferRelatedApplications'] = self.prefer_related_applications
1617
+ if self.protocol_handlers is not None:
1618
+ json['protocolHandlers'] = [i.to_json() for i in self.protocol_handlers]
1619
+ if self.related_applications is not None:
1620
+ json['relatedApplications'] = [i.to_json() for i in self.related_applications]
1621
+ if self.scope is not None:
1622
+ json['scope'] = self.scope
1623
+ if self.scope_extensions is not None:
1624
+ json['scopeExtensions'] = [i.to_json() for i in self.scope_extensions]
1625
+ if self.screenshots is not None:
1626
+ json['screenshots'] = [i.to_json() for i in self.screenshots]
1627
+ if self.share_target is not None:
1628
+ json['shareTarget'] = self.share_target.to_json()
1629
+ if self.short_name is not None:
1630
+ json['shortName'] = self.short_name
1631
+ if self.shortcuts is not None:
1632
+ json['shortcuts'] = [i.to_json() for i in self.shortcuts]
1633
+ if self.start_url is not None:
1634
+ json['startUrl'] = self.start_url
1635
+ if self.theme_color is not None:
1636
+ json['themeColor'] = self.theme_color
1637
+ return json
1638
+
1639
+ @classmethod
1640
+ def from_json(cls, json: T_JSON_DICT) -> WebAppManifest:
1641
+ return cls(
1642
+ background_color=str(json['backgroundColor']) if json.get('backgroundColor', None) is not None else None,
1643
+ description=str(json['description']) if json.get('description', None) is not None else None,
1644
+ dir_=str(json['dir']) if json.get('dir', None) is not None else None,
1645
+ display=str(json['display']) if json.get('display', None) is not None else None,
1646
+ display_overrides=[str(i) for i in json['displayOverrides']] if json.get('displayOverrides', None) is not None else None,
1647
+ file_handlers=[FileHandler.from_json(i) for i in json['fileHandlers']] if json.get('fileHandlers', None) is not None else None,
1648
+ icons=[ImageResource.from_json(i) for i in json['icons']] if json.get('icons', None) is not None else None,
1649
+ id_=str(json['id']) if json.get('id', None) is not None else None,
1650
+ lang=str(json['lang']) if json.get('lang', None) is not None else None,
1651
+ launch_handler=LaunchHandler.from_json(json['launchHandler']) if json.get('launchHandler', None) is not None else None,
1652
+ name=str(json['name']) if json.get('name', None) is not None else None,
1653
+ orientation=str(json['orientation']) if json.get('orientation', None) is not None else None,
1654
+ prefer_related_applications=bool(json['preferRelatedApplications']) if json.get('preferRelatedApplications', None) is not None else None,
1655
+ protocol_handlers=[ProtocolHandler.from_json(i) for i in json['protocolHandlers']] if json.get('protocolHandlers', None) is not None else None,
1656
+ related_applications=[RelatedApplication.from_json(i) for i in json['relatedApplications']] if json.get('relatedApplications', None) is not None else None,
1657
+ scope=str(json['scope']) if json.get('scope', None) is not None else None,
1658
+ scope_extensions=[ScopeExtension.from_json(i) for i in json['scopeExtensions']] if json.get('scopeExtensions', None) is not None else None,
1659
+ screenshots=[Screenshot.from_json(i) for i in json['screenshots']] if json.get('screenshots', None) is not None else None,
1660
+ share_target=ShareTarget.from_json(json['shareTarget']) if json.get('shareTarget', None) is not None else None,
1661
+ short_name=str(json['shortName']) if json.get('shortName', None) is not None else None,
1662
+ shortcuts=[Shortcut.from_json(i) for i in json['shortcuts']] if json.get('shortcuts', None) is not None else None,
1663
+ start_url=str(json['startUrl']) if json.get('startUrl', None) is not None else None,
1664
+ theme_color=str(json['themeColor']) if json.get('themeColor', None) is not None else None,
1665
+ )
1666
+
1667
+
1668
+ class NavigationType(enum.Enum):
1669
+ '''
1670
+ The type of a frameNavigated event.
1671
+ '''
1672
+ NAVIGATION = "Navigation"
1673
+ BACK_FORWARD_CACHE_RESTORE = "BackForwardCacheRestore"
1674
+
1675
+ def to_json(self) -> str:
1676
+ return self.value
1677
+
1678
+ @classmethod
1679
+ def from_json(cls, json: str) -> NavigationType:
1680
+ return cls(json)
1681
+
1682
+
1683
+ class BackForwardCacheNotRestoredReason(enum.Enum):
1684
+ '''
1685
+ List of not restored reasons for back-forward cache.
1686
+ '''
1687
+ NOT_PRIMARY_MAIN_FRAME = "NotPrimaryMainFrame"
1688
+ BACK_FORWARD_CACHE_DISABLED = "BackForwardCacheDisabled"
1689
+ RELATED_ACTIVE_CONTENTS_EXIST = "RelatedActiveContentsExist"
1690
+ HTTP_STATUS_NOT_OK = "HTTPStatusNotOK"
1691
+ SCHEME_NOT_HTTP_OR_HTTPS = "SchemeNotHTTPOrHTTPS"
1692
+ LOADING = "Loading"
1693
+ WAS_GRANTED_MEDIA_ACCESS = "WasGrantedMediaAccess"
1694
+ DISABLE_FOR_RENDER_FRAME_HOST_CALLED = "DisableForRenderFrameHostCalled"
1695
+ DOMAIN_NOT_ALLOWED = "DomainNotAllowed"
1696
+ HTTP_METHOD_NOT_GET = "HTTPMethodNotGET"
1697
+ SUBFRAME_IS_NAVIGATING = "SubframeIsNavigating"
1698
+ TIMEOUT = "Timeout"
1699
+ CACHE_LIMIT = "CacheLimit"
1700
+ JAVA_SCRIPT_EXECUTION = "JavaScriptExecution"
1701
+ RENDERER_PROCESS_KILLED = "RendererProcessKilled"
1702
+ RENDERER_PROCESS_CRASHED = "RendererProcessCrashed"
1703
+ SCHEDULER_TRACKED_FEATURE_USED = "SchedulerTrackedFeatureUsed"
1704
+ CONFLICTING_BROWSING_INSTANCE = "ConflictingBrowsingInstance"
1705
+ CACHE_FLUSHED = "CacheFlushed"
1706
+ SERVICE_WORKER_VERSION_ACTIVATION = "ServiceWorkerVersionActivation"
1707
+ SESSION_RESTORED = "SessionRestored"
1708
+ SERVICE_WORKER_POST_MESSAGE = "ServiceWorkerPostMessage"
1709
+ ENTERED_BACK_FORWARD_CACHE_BEFORE_SERVICE_WORKER_HOST_ADDED = "EnteredBackForwardCacheBeforeServiceWorkerHostAdded"
1710
+ RENDER_FRAME_HOST_REUSED_SAME_SITE = "RenderFrameHostReused_SameSite"
1711
+ RENDER_FRAME_HOST_REUSED_CROSS_SITE = "RenderFrameHostReused_CrossSite"
1712
+ SERVICE_WORKER_CLAIM = "ServiceWorkerClaim"
1713
+ IGNORE_EVENT_AND_EVICT = "IgnoreEventAndEvict"
1714
+ HAVE_INNER_CONTENTS = "HaveInnerContents"
1715
+ TIMEOUT_PUTTING_IN_CACHE = "TimeoutPuttingInCache"
1716
+ BACK_FORWARD_CACHE_DISABLED_BY_LOW_MEMORY = "BackForwardCacheDisabledByLowMemory"
1717
+ BACK_FORWARD_CACHE_DISABLED_BY_COMMAND_LINE = "BackForwardCacheDisabledByCommandLine"
1718
+ NETWORK_REQUEST_DATAPIPE_DRAINED_AS_BYTES_CONSUMER = "NetworkRequestDatapipeDrainedAsBytesConsumer"
1719
+ NETWORK_REQUEST_REDIRECTED = "NetworkRequestRedirected"
1720
+ NETWORK_REQUEST_TIMEOUT = "NetworkRequestTimeout"
1721
+ NETWORK_EXCEEDS_BUFFER_LIMIT = "NetworkExceedsBufferLimit"
1722
+ NAVIGATION_CANCELLED_WHILE_RESTORING = "NavigationCancelledWhileRestoring"
1723
+ NOT_MOST_RECENT_NAVIGATION_ENTRY = "NotMostRecentNavigationEntry"
1724
+ BACK_FORWARD_CACHE_DISABLED_FOR_PRERENDER = "BackForwardCacheDisabledForPrerender"
1725
+ USER_AGENT_OVERRIDE_DIFFERS = "UserAgentOverrideDiffers"
1726
+ FOREGROUND_CACHE_LIMIT = "ForegroundCacheLimit"
1727
+ FORWARD_CACHE_DISABLED = "ForwardCacheDisabled"
1728
+ BROWSING_INSTANCE_NOT_SWAPPED = "BrowsingInstanceNotSwapped"
1729
+ BACK_FORWARD_CACHE_DISABLED_FOR_DELEGATE = "BackForwardCacheDisabledForDelegate"
1730
+ UNLOAD_HANDLER_EXISTS_IN_MAIN_FRAME = "UnloadHandlerExistsInMainFrame"
1731
+ UNLOAD_HANDLER_EXISTS_IN_SUB_FRAME = "UnloadHandlerExistsInSubFrame"
1732
+ SERVICE_WORKER_UNREGISTRATION = "ServiceWorkerUnregistration"
1733
+ CACHE_CONTROL_NO_STORE = "CacheControlNoStore"
1734
+ CACHE_CONTROL_NO_STORE_COOKIE_MODIFIED = "CacheControlNoStoreCookieModified"
1735
+ CACHE_CONTROL_NO_STORE_HTTP_ONLY_COOKIE_MODIFIED = "CacheControlNoStoreHTTPOnlyCookieModified"
1736
+ NO_RESPONSE_HEAD = "NoResponseHead"
1737
+ UNKNOWN = "Unknown"
1738
+ ACTIVATION_NAVIGATIONS_DISALLOWED_FOR_BUG1234857 = "ActivationNavigationsDisallowedForBug1234857"
1739
+ ERROR_DOCUMENT = "ErrorDocument"
1740
+ FENCED_FRAMES_EMBEDDER = "FencedFramesEmbedder"
1741
+ COOKIE_DISABLED = "CookieDisabled"
1742
+ HTTP_AUTH_REQUIRED = "HTTPAuthRequired"
1743
+ COOKIE_FLUSHED = "CookieFlushed"
1744
+ BROADCAST_CHANNEL_ON_MESSAGE = "BroadcastChannelOnMessage"
1745
+ WEB_VIEW_SETTINGS_CHANGED = "WebViewSettingsChanged"
1746
+ WEB_VIEW_JAVA_SCRIPT_OBJECT_CHANGED = "WebViewJavaScriptObjectChanged"
1747
+ WEB_VIEW_MESSAGE_LISTENER_INJECTED = "WebViewMessageListenerInjected"
1748
+ WEB_VIEW_SAFE_BROWSING_ALLOWLIST_CHANGED = "WebViewSafeBrowsingAllowlistChanged"
1749
+ WEB_VIEW_DOCUMENT_START_JAVASCRIPT_CHANGED = "WebViewDocumentStartJavascriptChanged"
1750
+ WEB_SOCKET = "WebSocket"
1751
+ WEB_TRANSPORT = "WebTransport"
1752
+ WEB_RTC = "WebRTC"
1753
+ MAIN_RESOURCE_HAS_CACHE_CONTROL_NO_STORE = "MainResourceHasCacheControlNoStore"
1754
+ MAIN_RESOURCE_HAS_CACHE_CONTROL_NO_CACHE = "MainResourceHasCacheControlNoCache"
1755
+ SUBRESOURCE_HAS_CACHE_CONTROL_NO_STORE = "SubresourceHasCacheControlNoStore"
1756
+ SUBRESOURCE_HAS_CACHE_CONTROL_NO_CACHE = "SubresourceHasCacheControlNoCache"
1757
+ CONTAINS_PLUGINS = "ContainsPlugins"
1758
+ DOCUMENT_LOADED = "DocumentLoaded"
1759
+ OUTSTANDING_NETWORK_REQUEST_OTHERS = "OutstandingNetworkRequestOthers"
1760
+ REQUESTED_MIDI_PERMISSION = "RequestedMIDIPermission"
1761
+ REQUESTED_AUDIO_CAPTURE_PERMISSION = "RequestedAudioCapturePermission"
1762
+ REQUESTED_VIDEO_CAPTURE_PERMISSION = "RequestedVideoCapturePermission"
1763
+ REQUESTED_BACK_FORWARD_CACHE_BLOCKED_SENSORS = "RequestedBackForwardCacheBlockedSensors"
1764
+ REQUESTED_BACKGROUND_WORK_PERMISSION = "RequestedBackgroundWorkPermission"
1765
+ BROADCAST_CHANNEL = "BroadcastChannel"
1766
+ WEB_XR = "WebXR"
1767
+ SHARED_WORKER = "SharedWorker"
1768
+ SHARED_WORKER_MESSAGE = "SharedWorkerMessage"
1769
+ SHARED_WORKER_WITH_NO_ACTIVE_CLIENT = "SharedWorkerWithNoActiveClient"
1770
+ WEB_LOCKS = "WebLocks"
1771
+ WEB_LOCKS_CONTENTION = "WebLocksContention"
1772
+ WEB_HID = "WebHID"
1773
+ WEB_BLUETOOTH = "WebBluetooth"
1774
+ WEB_SHARE = "WebShare"
1775
+ REQUESTED_STORAGE_ACCESS_GRANT = "RequestedStorageAccessGrant"
1776
+ WEB_NFC = "WebNfc"
1777
+ OUTSTANDING_NETWORK_REQUEST_FETCH = "OutstandingNetworkRequestFetch"
1778
+ OUTSTANDING_NETWORK_REQUEST_XHR = "OutstandingNetworkRequestXHR"
1779
+ APP_BANNER = "AppBanner"
1780
+ PRINTING = "Printing"
1781
+ WEB_DATABASE = "WebDatabase"
1782
+ PICTURE_IN_PICTURE = "PictureInPicture"
1783
+ SPEECH_RECOGNIZER = "SpeechRecognizer"
1784
+ IDLE_MANAGER = "IdleManager"
1785
+ PAYMENT_MANAGER = "PaymentManager"
1786
+ SPEECH_SYNTHESIS = "SpeechSynthesis"
1787
+ KEYBOARD_LOCK = "KeyboardLock"
1788
+ WEB_OTP_SERVICE = "WebOTPService"
1789
+ OUTSTANDING_NETWORK_REQUEST_DIRECT_SOCKET = "OutstandingNetworkRequestDirectSocket"
1790
+ INJECTED_JAVASCRIPT = "InjectedJavascript"
1791
+ INJECTED_STYLE_SHEET = "InjectedStyleSheet"
1792
+ KEEPALIVE_REQUEST = "KeepaliveRequest"
1793
+ INDEXED_DB_EVENT = "IndexedDBEvent"
1794
+ DUMMY = "Dummy"
1795
+ JS_NETWORK_REQUEST_RECEIVED_CACHE_CONTROL_NO_STORE_RESOURCE = "JsNetworkRequestReceivedCacheControlNoStoreResource"
1796
+ WEB_RTC_USED_WITH_CCNS = "WebRTCUsedWithCCNS"
1797
+ WEB_TRANSPORT_USED_WITH_CCNS = "WebTransportUsedWithCCNS"
1798
+ WEB_SOCKET_USED_WITH_CCNS = "WebSocketUsedWithCCNS"
1799
+ SMART_CARD = "SmartCard"
1800
+ LIVE_MEDIA_STREAM_TRACK = "LiveMediaStreamTrack"
1801
+ UNLOAD_HANDLER = "UnloadHandler"
1802
+ PARSER_ABORTED = "ParserAborted"
1803
+ CONTENT_SECURITY_HANDLER = "ContentSecurityHandler"
1804
+ CONTENT_WEB_AUTHENTICATION_API = "ContentWebAuthenticationAPI"
1805
+ CONTENT_FILE_CHOOSER = "ContentFileChooser"
1806
+ CONTENT_SERIAL = "ContentSerial"
1807
+ CONTENT_FILE_SYSTEM_ACCESS = "ContentFileSystemAccess"
1808
+ CONTENT_MEDIA_DEVICES_DISPATCHER_HOST = "ContentMediaDevicesDispatcherHost"
1809
+ CONTENT_WEB_BLUETOOTH = "ContentWebBluetooth"
1810
+ CONTENT_WEB_USB = "ContentWebUSB"
1811
+ CONTENT_MEDIA_SESSION_SERVICE = "ContentMediaSessionService"
1812
+ CONTENT_SCREEN_READER = "ContentScreenReader"
1813
+ CONTENT_DISCARDED = "ContentDiscarded"
1814
+ EMBEDDER_POPUP_BLOCKER_TAB_HELPER = "EmbedderPopupBlockerTabHelper"
1815
+ EMBEDDER_SAFE_BROWSING_TRIGGERED_POPUP_BLOCKER = "EmbedderSafeBrowsingTriggeredPopupBlocker"
1816
+ EMBEDDER_SAFE_BROWSING_THREAT_DETAILS = "EmbedderSafeBrowsingThreatDetails"
1817
+ EMBEDDER_APP_BANNER_MANAGER = "EmbedderAppBannerManager"
1818
+ EMBEDDER_DOM_DISTILLER_VIEWER_SOURCE = "EmbedderDomDistillerViewerSource"
1819
+ EMBEDDER_DOM_DISTILLER_SELF_DELETING_REQUEST_DELEGATE = "EmbedderDomDistillerSelfDeletingRequestDelegate"
1820
+ EMBEDDER_OOM_INTERVENTION_TAB_HELPER = "EmbedderOomInterventionTabHelper"
1821
+ EMBEDDER_OFFLINE_PAGE = "EmbedderOfflinePage"
1822
+ EMBEDDER_CHROME_PASSWORD_MANAGER_CLIENT_BIND_CREDENTIAL_MANAGER = "EmbedderChromePasswordManagerClientBindCredentialManager"
1823
+ EMBEDDER_PERMISSION_REQUEST_MANAGER = "EmbedderPermissionRequestManager"
1824
+ EMBEDDER_MODAL_DIALOG = "EmbedderModalDialog"
1825
+ EMBEDDER_EXTENSIONS = "EmbedderExtensions"
1826
+ EMBEDDER_EXTENSION_MESSAGING = "EmbedderExtensionMessaging"
1827
+ EMBEDDER_EXTENSION_MESSAGING_FOR_OPEN_PORT = "EmbedderExtensionMessagingForOpenPort"
1828
+ EMBEDDER_EXTENSION_SENT_MESSAGE_TO_CACHED_FRAME = "EmbedderExtensionSentMessageToCachedFrame"
1829
+ EMBEDDER_EXTENSION_FRAME = "EmbedderExtensionFrame"
1830
+ REQUESTED_BY_WEB_VIEW_CLIENT = "RequestedByWebViewClient"
1831
+ POST_MESSAGE_BY_WEB_VIEW_CLIENT = "PostMessageByWebViewClient"
1832
+ CACHE_CONTROL_NO_STORE_DEVICE_BOUND_SESSION_TERMINATED = "CacheControlNoStoreDeviceBoundSessionTerminated"
1833
+ CACHE_LIMIT_PRUNED_ON_MODERATE_MEMORY_PRESSURE = "CacheLimitPrunedOnModerateMemoryPressure"
1834
+ CACHE_LIMIT_PRUNED_ON_CRITICAL_MEMORY_PRESSURE = "CacheLimitPrunedOnCriticalMemoryPressure"
1835
+
1836
+ def to_json(self) -> str:
1837
+ return self.value
1838
+
1839
+ @classmethod
1840
+ def from_json(cls, json: str) -> BackForwardCacheNotRestoredReason:
1841
+ return cls(json)
1842
+
1843
+
1844
+ class BackForwardCacheNotRestoredReasonType(enum.Enum):
1845
+ '''
1846
+ Types of not restored reasons for back-forward cache.
1847
+ '''
1848
+ SUPPORT_PENDING = "SupportPending"
1849
+ PAGE_SUPPORT_NEEDED = "PageSupportNeeded"
1850
+ CIRCUMSTANTIAL = "Circumstantial"
1851
+
1852
+ def to_json(self) -> str:
1853
+ return self.value
1854
+
1855
+ @classmethod
1856
+ def from_json(cls, json: str) -> BackForwardCacheNotRestoredReasonType:
1857
+ return cls(json)
1858
+
1859
+
1860
+ @dataclass
1861
+ class BackForwardCacheBlockingDetails:
1862
+ #: Line number in the script (0-based).
1863
+ line_number: int
1864
+
1865
+ #: Column number in the script (0-based).
1866
+ column_number: int
1867
+
1868
+ #: Url of the file where blockage happened. Optional because of tests.
1869
+ url: typing.Optional[str] = None
1870
+
1871
+ #: Function name where blockage happened. Optional because of anonymous functions and tests.
1872
+ function: typing.Optional[str] = None
1873
+
1874
+ def to_json(self) -> T_JSON_DICT:
1875
+ json: T_JSON_DICT = dict()
1876
+ json['lineNumber'] = self.line_number
1877
+ json['columnNumber'] = self.column_number
1878
+ if self.url is not None:
1879
+ json['url'] = self.url
1880
+ if self.function is not None:
1881
+ json['function'] = self.function
1882
+ return json
1883
+
1884
+ @classmethod
1885
+ def from_json(cls, json: T_JSON_DICT) -> BackForwardCacheBlockingDetails:
1886
+ return cls(
1887
+ line_number=int(json['lineNumber']),
1888
+ column_number=int(json['columnNumber']),
1889
+ url=str(json['url']) if json.get('url', None) is not None else None,
1890
+ function=str(json['function']) if json.get('function', None) is not None else None,
1891
+ )
1892
+
1893
+
1894
+ @dataclass
1895
+ class BackForwardCacheNotRestoredExplanation:
1896
+ #: Type of the reason
1897
+ type_: BackForwardCacheNotRestoredReasonType
1898
+
1899
+ #: Not restored reason
1900
+ reason: BackForwardCacheNotRestoredReason
1901
+
1902
+ #: Context associated with the reason. The meaning of this context is
1903
+ #: dependent on the reason:
1904
+ #: - EmbedderExtensionSentMessageToCachedFrame: the extension ID.
1905
+ context: typing.Optional[str] = None
1906
+
1907
+ details: typing.Optional[typing.List[BackForwardCacheBlockingDetails]] = None
1908
+
1909
+ def to_json(self) -> T_JSON_DICT:
1910
+ json: T_JSON_DICT = dict()
1911
+ json['type'] = self.type_.to_json()
1912
+ json['reason'] = self.reason.to_json()
1913
+ if self.context is not None:
1914
+ json['context'] = self.context
1915
+ if self.details is not None:
1916
+ json['details'] = [i.to_json() for i in self.details]
1917
+ return json
1918
+
1919
+ @classmethod
1920
+ def from_json(cls, json: T_JSON_DICT) -> BackForwardCacheNotRestoredExplanation:
1921
+ return cls(
1922
+ type_=BackForwardCacheNotRestoredReasonType.from_json(json['type']),
1923
+ reason=BackForwardCacheNotRestoredReason.from_json(json['reason']),
1924
+ context=str(json['context']) if json.get('context', None) is not None else None,
1925
+ details=[BackForwardCacheBlockingDetails.from_json(i) for i in json['details']] if json.get('details', None) is not None else None,
1926
+ )
1927
+
1928
+
1929
+ @dataclass
1930
+ class BackForwardCacheNotRestoredExplanationTree:
1931
+ #: URL of each frame
1932
+ url: str
1933
+
1934
+ #: Not restored reasons of each frame
1935
+ explanations: typing.List[BackForwardCacheNotRestoredExplanation]
1936
+
1937
+ #: Array of children frame
1938
+ children: typing.List[BackForwardCacheNotRestoredExplanationTree]
1939
+
1940
+ def to_json(self) -> T_JSON_DICT:
1941
+ json: T_JSON_DICT = dict()
1942
+ json['url'] = self.url
1943
+ json['explanations'] = [i.to_json() for i in self.explanations]
1944
+ json['children'] = [i.to_json() for i in self.children]
1945
+ return json
1946
+
1947
+ @classmethod
1948
+ def from_json(cls, json: T_JSON_DICT) -> BackForwardCacheNotRestoredExplanationTree:
1949
+ return cls(
1950
+ url=str(json['url']),
1951
+ explanations=[BackForwardCacheNotRestoredExplanation.from_json(i) for i in json['explanations']],
1952
+ children=[BackForwardCacheNotRestoredExplanationTree.from_json(i) for i in json['children']],
1953
+ )
1954
+
1955
+
1956
+ @deprecated(version="1.3")
1957
+ def add_script_to_evaluate_on_load(
1958
+ script_source: str
1959
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,ScriptIdentifier]:
1960
+ '''
1961
+ Deprecated, please use addScriptToEvaluateOnNewDocument instead.
1962
+
1963
+ .. deprecated:: 1.3
1964
+
1965
+ **EXPERIMENTAL**
1966
+
1967
+ :param script_source:
1968
+ :returns: Identifier of the added script.
1969
+ '''
1970
+ params: T_JSON_DICT = dict()
1971
+ params['scriptSource'] = script_source
1972
+ cmd_dict: T_JSON_DICT = {
1973
+ 'method': 'Page.addScriptToEvaluateOnLoad',
1974
+ 'params': params,
1975
+ }
1976
+ json = yield cmd_dict
1977
+ return ScriptIdentifier.from_json(json['identifier'])
1978
+
1979
+
1980
+ def add_script_to_evaluate_on_new_document(
1981
+ source: str,
1982
+ world_name: typing.Optional[str] = None,
1983
+ include_command_line_api: typing.Optional[bool] = None,
1984
+ run_immediately: typing.Optional[bool] = None
1985
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,ScriptIdentifier]:
1986
+ '''
1987
+ Evaluates given script in every frame upon creation (before loading frame's scripts).
1988
+
1989
+ :param source:
1990
+ :param world_name: **(EXPERIMENTAL)** *(Optional)* If specified, creates an isolated world with the given name and evaluates given script in it. This world name will be used as the ExecutionContextDescription::name when the corresponding event is emitted.
1991
+ :param include_command_line_api: **(EXPERIMENTAL)** *(Optional)* Specifies whether command line API should be available to the script, defaults to false.
1992
+ :param run_immediately: **(EXPERIMENTAL)** *(Optional)* If true, runs the script immediately on existing execution contexts or worlds. Default: false.
1993
+ :returns: Identifier of the added script.
1994
+ '''
1995
+ params: T_JSON_DICT = dict()
1996
+ params['source'] = source
1997
+ if world_name is not None:
1998
+ params['worldName'] = world_name
1999
+ if include_command_line_api is not None:
2000
+ params['includeCommandLineAPI'] = include_command_line_api
2001
+ if run_immediately is not None:
2002
+ params['runImmediately'] = run_immediately
2003
+ cmd_dict: T_JSON_DICT = {
2004
+ 'method': 'Page.addScriptToEvaluateOnNewDocument',
2005
+ 'params': params,
2006
+ }
2007
+ json = yield cmd_dict
2008
+ return ScriptIdentifier.from_json(json['identifier'])
2009
+
2010
+
2011
+ def bring_to_front() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2012
+ '''
2013
+ Brings page to front (activates tab).
2014
+ '''
2015
+ cmd_dict: T_JSON_DICT = {
2016
+ 'method': 'Page.bringToFront',
2017
+ }
2018
+ json = yield cmd_dict
2019
+
2020
+
2021
+ def capture_screenshot(
2022
+ format_: typing.Optional[str] = None,
2023
+ quality: typing.Optional[int] = None,
2024
+ clip: typing.Optional[Viewport] = None,
2025
+ from_surface: typing.Optional[bool] = None,
2026
+ capture_beyond_viewport: typing.Optional[bool] = None,
2027
+ optimize_for_speed: typing.Optional[bool] = None
2028
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
2029
+ '''
2030
+ Capture page screenshot.
2031
+
2032
+ :param format_: *(Optional)* Image compression format (defaults to png).
2033
+ :param quality: *(Optional)* Compression quality from range [0..100] (jpeg only).
2034
+ :param clip: *(Optional)* Capture the screenshot of a given region only.
2035
+ :param from_surface: **(EXPERIMENTAL)** *(Optional)* Capture the screenshot from the surface, rather than the view. Defaults to true.
2036
+ :param capture_beyond_viewport: **(EXPERIMENTAL)** *(Optional)* Capture the screenshot beyond the viewport. Defaults to false.
2037
+ :param optimize_for_speed: **(EXPERIMENTAL)** *(Optional)* Optimize image encoding for speed, not for resulting size (defaults to false)
2038
+ :returns: Base64-encoded image data. (Encoded as a base64 string when passed over JSON)
2039
+ '''
2040
+ params: T_JSON_DICT = dict()
2041
+ if format_ is not None:
2042
+ params['format'] = format_
2043
+ if quality is not None:
2044
+ params['quality'] = quality
2045
+ if clip is not None:
2046
+ params['clip'] = clip.to_json()
2047
+ if from_surface is not None:
2048
+ params['fromSurface'] = from_surface
2049
+ if capture_beyond_viewport is not None:
2050
+ params['captureBeyondViewport'] = capture_beyond_viewport
2051
+ if optimize_for_speed is not None:
2052
+ params['optimizeForSpeed'] = optimize_for_speed
2053
+ cmd_dict: T_JSON_DICT = {
2054
+ 'method': 'Page.captureScreenshot',
2055
+ 'params': params,
2056
+ }
2057
+ json = yield cmd_dict
2058
+ return str(json['data'])
2059
+
2060
+
2061
+ def capture_snapshot(
2062
+ format_: typing.Optional[str] = None
2063
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
2064
+ '''
2065
+ Returns a snapshot of the page as a string. For MHTML format, the serialization includes
2066
+ iframes, shadow DOM, external resources, and element-inline styles.
2067
+
2068
+ **EXPERIMENTAL**
2069
+
2070
+ :param format_: *(Optional)* Format (defaults to mhtml).
2071
+ :returns: Serialized page data.
2072
+ '''
2073
+ params: T_JSON_DICT = dict()
2074
+ if format_ is not None:
2075
+ params['format'] = format_
2076
+ cmd_dict: T_JSON_DICT = {
2077
+ 'method': 'Page.captureSnapshot',
2078
+ 'params': params,
2079
+ }
2080
+ json = yield cmd_dict
2081
+ return str(json['data'])
2082
+
2083
+
2084
+ @deprecated(version="1.3")
2085
+ def clear_device_metrics_override() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2086
+ '''
2087
+ Clears the overridden device metrics.
2088
+
2089
+ .. deprecated:: 1.3
2090
+
2091
+ **EXPERIMENTAL**
2092
+ '''
2093
+ cmd_dict: T_JSON_DICT = {
2094
+ 'method': 'Page.clearDeviceMetricsOverride',
2095
+ }
2096
+ json = yield cmd_dict
2097
+
2098
+
2099
+ @deprecated(version="1.3")
2100
+ def clear_device_orientation_override() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2101
+ '''
2102
+ Clears the overridden Device Orientation.
2103
+
2104
+ .. deprecated:: 1.3
2105
+
2106
+ **EXPERIMENTAL**
2107
+ '''
2108
+ cmd_dict: T_JSON_DICT = {
2109
+ 'method': 'Page.clearDeviceOrientationOverride',
2110
+ }
2111
+ json = yield cmd_dict
2112
+
2113
+
2114
+ @deprecated(version="1.3")
2115
+ def clear_geolocation_override() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2116
+ '''
2117
+ Clears the overridden Geolocation Position and Error.
2118
+
2119
+ .. deprecated:: 1.3
2120
+ '''
2121
+ cmd_dict: T_JSON_DICT = {
2122
+ 'method': 'Page.clearGeolocationOverride',
2123
+ }
2124
+ json = yield cmd_dict
2125
+
2126
+
2127
+ def create_isolated_world(
2128
+ frame_id: FrameId,
2129
+ world_name: typing.Optional[str] = None,
2130
+ grant_univeral_access: typing.Optional[bool] = None
2131
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,runtime.ExecutionContextId]:
2132
+ '''
2133
+ Creates an isolated world for the given frame.
2134
+
2135
+ :param frame_id: Id of the frame in which the isolated world should be created.
2136
+ :param world_name: *(Optional)* An optional name which is reported in the Execution Context.
2137
+ :param grant_univeral_access: *(Optional)* Whether or not universal access should be granted to the isolated world. This is a powerful option, use with caution.
2138
+ :returns: Execution context of the isolated world.
2139
+ '''
2140
+ params: T_JSON_DICT = dict()
2141
+ params['frameId'] = frame_id.to_json()
2142
+ if world_name is not None:
2143
+ params['worldName'] = world_name
2144
+ if grant_univeral_access is not None:
2145
+ params['grantUniveralAccess'] = grant_univeral_access
2146
+ cmd_dict: T_JSON_DICT = {
2147
+ 'method': 'Page.createIsolatedWorld',
2148
+ 'params': params,
2149
+ }
2150
+ json = yield cmd_dict
2151
+ return runtime.ExecutionContextId.from_json(json['executionContextId'])
2152
+
2153
+
2154
+ @deprecated(version="1.3")
2155
+ def delete_cookie(
2156
+ cookie_name: str,
2157
+ url: str
2158
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2159
+ '''
2160
+ Deletes browser cookie with given name, domain and path.
2161
+
2162
+ .. deprecated:: 1.3
2163
+
2164
+ **EXPERIMENTAL**
2165
+
2166
+ :param cookie_name: Name of the cookie to remove.
2167
+ :param url: URL to match cooke domain and path.
2168
+ '''
2169
+ params: T_JSON_DICT = dict()
2170
+ params['cookieName'] = cookie_name
2171
+ params['url'] = url
2172
+ cmd_dict: T_JSON_DICT = {
2173
+ 'method': 'Page.deleteCookie',
2174
+ 'params': params,
2175
+ }
2176
+ json = yield cmd_dict
2177
+
2178
+
2179
+ def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2180
+ '''
2181
+ Disables page domain notifications.
2182
+ '''
2183
+ cmd_dict: T_JSON_DICT = {
2184
+ 'method': 'Page.disable',
2185
+ }
2186
+ json = yield cmd_dict
2187
+
2188
+
2189
+ def enable(
2190
+ enable_file_chooser_opened_event: typing.Optional[bool] = None
2191
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2192
+ '''
2193
+ Enables page domain notifications.
2194
+
2195
+ :param enable_file_chooser_opened_event: **(EXPERIMENTAL)** *(Optional)* If true, the ```Page.fileChooserOpened```` event will be emitted regardless of the state set by ````Page.setInterceptFileChooserDialog``` command (default: false).
2196
+ '''
2197
+ params: T_JSON_DICT = dict()
2198
+ if enable_file_chooser_opened_event is not None:
2199
+ params['enableFileChooserOpenedEvent'] = enable_file_chooser_opened_event
2200
+ cmd_dict: T_JSON_DICT = {
2201
+ 'method': 'Page.enable',
2202
+ 'params': params,
2203
+ }
2204
+ json = yield cmd_dict
2205
+
2206
+
2207
+ def get_app_manifest(
2208
+ manifest_id: typing.Optional[str] = None
2209
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[str, typing.List[AppManifestError], typing.Optional[str], typing.Optional[AppManifestParsedProperties], WebAppManifest]]:
2210
+ '''
2211
+ Gets the processed manifest for this current document.
2212
+ This API always waits for the manifest to be loaded.
2213
+ If manifestId is provided, and it does not match the manifest of the
2214
+ current document, this API errors out.
2215
+ If there is not a loaded page, this API errors out immediately.
2216
+
2217
+ :param manifest_id: *(Optional)*
2218
+ :returns: A tuple with the following items:
2219
+
2220
+ 0. **url** - Manifest location.
2221
+ 1. **errors** -
2222
+ 2. **data** - *(Optional)* Manifest content.
2223
+ 3. **parsed** - *(Optional)* Parsed manifest properties. Deprecated, use manifest instead.
2224
+ 4. **manifest** -
2225
+ '''
2226
+ params: T_JSON_DICT = dict()
2227
+ if manifest_id is not None:
2228
+ params['manifestId'] = manifest_id
2229
+ cmd_dict: T_JSON_DICT = {
2230
+ 'method': 'Page.getAppManifest',
2231
+ 'params': params,
2232
+ }
2233
+ json = yield cmd_dict
2234
+ return (
2235
+ str(json['url']),
2236
+ [AppManifestError.from_json(i) for i in json['errors']],
2237
+ str(json['data']) if json.get('data', None) is not None else None,
2238
+ AppManifestParsedProperties.from_json(json['parsed']) if json.get('parsed', None) is not None else None,
2239
+ WebAppManifest.from_json(json['manifest'])
2240
+ )
2241
+
2242
+
2243
+ def get_installability_errors() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[InstallabilityError]]:
2244
+ '''
2245
+
2246
+
2247
+ **EXPERIMENTAL**
2248
+
2249
+ :returns:
2250
+ '''
2251
+ cmd_dict: T_JSON_DICT = {
2252
+ 'method': 'Page.getInstallabilityErrors',
2253
+ }
2254
+ json = yield cmd_dict
2255
+ return [InstallabilityError.from_json(i) for i in json['installabilityErrors']]
2256
+
2257
+
2258
+ @deprecated(version="1.3")
2259
+ def get_manifest_icons() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Optional[str]]:
2260
+ '''
2261
+ Deprecated because it's not guaranteed that the returned icon is in fact the one used for PWA installation.
2262
+
2263
+ .. deprecated:: 1.3
2264
+
2265
+ **EXPERIMENTAL**
2266
+
2267
+ :returns:
2268
+ '''
2269
+ cmd_dict: T_JSON_DICT = {
2270
+ 'method': 'Page.getManifestIcons',
2271
+ }
2272
+ json = yield cmd_dict
2273
+ return str(json['primaryIcon']) if json.get('primaryIcon', None) is not None else None
2274
+
2275
+
2276
+ def get_app_id() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[typing.Optional[str], typing.Optional[str]]]:
2277
+ '''
2278
+ Returns the unique (PWA) app id.
2279
+ Only returns values if the feature flag 'WebAppEnableManifestId' is enabled
2280
+
2281
+ **EXPERIMENTAL**
2282
+
2283
+ :returns: A tuple with the following items:
2284
+
2285
+ 0. **appId** - *(Optional)* App id, either from manifest's id attribute or computed from start_url
2286
+ 1. **recommendedId** - *(Optional)* Recommendation for manifest's id attribute to match current id computed from start_url
2287
+ '''
2288
+ cmd_dict: T_JSON_DICT = {
2289
+ 'method': 'Page.getAppId',
2290
+ }
2291
+ json = yield cmd_dict
2292
+ return (
2293
+ str(json['appId']) if json.get('appId', None) is not None else None,
2294
+ str(json['recommendedId']) if json.get('recommendedId', None) is not None else None
2295
+ )
2296
+
2297
+
2298
+ def get_ad_script_ancestry(
2299
+ frame_id: FrameId
2300
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Optional[network.AdAncestry]]:
2301
+ '''
2302
+
2303
+
2304
+ **EXPERIMENTAL**
2305
+
2306
+ :param frame_id:
2307
+ :returns: *(Optional)* The ancestry chain of ad script identifiers leading to this frame's creation, along with the root script's filterlist rule. The ancestry chain is ordered from the most immediate script (in the frame creation stack) to more distant ancestors (that created the immediately preceding script). Only sent if frame is labelled as an ad and ids are available.
2308
+ '''
2309
+ params: T_JSON_DICT = dict()
2310
+ params['frameId'] = frame_id.to_json()
2311
+ cmd_dict: T_JSON_DICT = {
2312
+ 'method': 'Page.getAdScriptAncestry',
2313
+ 'params': params,
2314
+ }
2315
+ json = yield cmd_dict
2316
+ return network.AdAncestry.from_json(json['adScriptAncestry']) if json.get('adScriptAncestry', None) is not None else None
2317
+
2318
+
2319
+ def get_frame_tree() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,FrameTree]:
2320
+ '''
2321
+ Returns present frame tree structure.
2322
+
2323
+ :returns: Present frame tree structure.
2324
+ '''
2325
+ cmd_dict: T_JSON_DICT = {
2326
+ 'method': 'Page.getFrameTree',
2327
+ }
2328
+ json = yield cmd_dict
2329
+ return FrameTree.from_json(json['frameTree'])
2330
+
2331
+
2332
+ def get_layout_metrics() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[LayoutViewport, VisualViewport, dom.Rect, LayoutViewport, VisualViewport, dom.Rect]]:
2333
+ '''
2334
+ Returns metrics relating to the layouting of the page, such as viewport bounds/scale.
2335
+
2336
+ :returns: A tuple with the following items:
2337
+
2338
+ 0. **layoutViewport** - Deprecated metrics relating to the layout viewport. Is in device pixels. Use ``cssLayoutViewport`` instead.
2339
+ 1. **visualViewport** - Deprecated metrics relating to the visual viewport. Is in device pixels. Use ``cssVisualViewport`` instead.
2340
+ 2. **contentSize** - Deprecated size of scrollable area. Is in DP. Use ``cssContentSize`` instead.
2341
+ 3. **cssLayoutViewport** - Metrics relating to the layout viewport in CSS pixels.
2342
+ 4. **cssVisualViewport** - Metrics relating to the visual viewport in CSS pixels.
2343
+ 5. **cssContentSize** - Size of scrollable area in CSS pixels.
2344
+ '''
2345
+ cmd_dict: T_JSON_DICT = {
2346
+ 'method': 'Page.getLayoutMetrics',
2347
+ }
2348
+ json = yield cmd_dict
2349
+ return (
2350
+ LayoutViewport.from_json(json['layoutViewport']),
2351
+ VisualViewport.from_json(json['visualViewport']),
2352
+ dom.Rect.from_json(json['contentSize']),
2353
+ LayoutViewport.from_json(json['cssLayoutViewport']),
2354
+ VisualViewport.from_json(json['cssVisualViewport']),
2355
+ dom.Rect.from_json(json['cssContentSize'])
2356
+ )
2357
+
2358
+
2359
+ def get_navigation_history() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[int, typing.List[NavigationEntry]]]:
2360
+ '''
2361
+ Returns navigation history for the current page.
2362
+
2363
+ :returns: A tuple with the following items:
2364
+
2365
+ 0. **currentIndex** - Index of the current navigation history entry.
2366
+ 1. **entries** - Array of navigation history entries.
2367
+ '''
2368
+ cmd_dict: T_JSON_DICT = {
2369
+ 'method': 'Page.getNavigationHistory',
2370
+ }
2371
+ json = yield cmd_dict
2372
+ return (
2373
+ int(json['currentIndex']),
2374
+ [NavigationEntry.from_json(i) for i in json['entries']]
2375
+ )
2376
+
2377
+
2378
+ def reset_navigation_history() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2379
+ '''
2380
+ Resets navigation history for the current page.
2381
+ '''
2382
+ cmd_dict: T_JSON_DICT = {
2383
+ 'method': 'Page.resetNavigationHistory',
2384
+ }
2385
+ json = yield cmd_dict
2386
+
2387
+
2388
+ def get_resource_content(
2389
+ frame_id: FrameId,
2390
+ url: str
2391
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[str, bool]]:
2392
+ '''
2393
+ Returns content of the given resource.
2394
+
2395
+ **EXPERIMENTAL**
2396
+
2397
+ :param frame_id: Frame id to get resource for.
2398
+ :param url: URL of the resource to get content for.
2399
+ :returns: A tuple with the following items:
2400
+
2401
+ 0. **content** - Resource content.
2402
+ 1. **base64Encoded** - True, if content was served as base64.
2403
+ '''
2404
+ params: T_JSON_DICT = dict()
2405
+ params['frameId'] = frame_id.to_json()
2406
+ params['url'] = url
2407
+ cmd_dict: T_JSON_DICT = {
2408
+ 'method': 'Page.getResourceContent',
2409
+ 'params': params,
2410
+ }
2411
+ json = yield cmd_dict
2412
+ return (
2413
+ str(json['content']),
2414
+ bool(json['base64Encoded'])
2415
+ )
2416
+
2417
+
2418
+ def get_resource_tree() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,FrameResourceTree]:
2419
+ '''
2420
+ Returns present frame / resource tree structure.
2421
+
2422
+ **EXPERIMENTAL**
2423
+
2424
+ :returns: Present frame / resource tree structure.
2425
+ '''
2426
+ cmd_dict: T_JSON_DICT = {
2427
+ 'method': 'Page.getResourceTree',
2428
+ }
2429
+ json = yield cmd_dict
2430
+ return FrameResourceTree.from_json(json['frameTree'])
2431
+
2432
+
2433
+ def handle_java_script_dialog(
2434
+ accept: bool,
2435
+ prompt_text: typing.Optional[str] = None
2436
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2437
+ '''
2438
+ Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).
2439
+
2440
+ :param accept: Whether to accept or dismiss the dialog.
2441
+ :param prompt_text: *(Optional)* The text to enter into the dialog prompt before accepting. Used only if this is a prompt dialog.
2442
+ '''
2443
+ params: T_JSON_DICT = dict()
2444
+ params['accept'] = accept
2445
+ if prompt_text is not None:
2446
+ params['promptText'] = prompt_text
2447
+ cmd_dict: T_JSON_DICT = {
2448
+ 'method': 'Page.handleJavaScriptDialog',
2449
+ 'params': params,
2450
+ }
2451
+ json = yield cmd_dict
2452
+
2453
+
2454
+ def navigate(
2455
+ url: str,
2456
+ referrer: typing.Optional[str] = None,
2457
+ transition_type: typing.Optional[TransitionType] = None,
2458
+ frame_id: typing.Optional[FrameId] = None,
2459
+ referrer_policy: typing.Optional[ReferrerPolicy] = None
2460
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[FrameId, typing.Optional[network.LoaderId], typing.Optional[str], typing.Optional[bool]]]:
2461
+ '''
2462
+ Navigates current page to the given URL.
2463
+
2464
+ :param url: URL to navigate the page to.
2465
+ :param referrer: *(Optional)* Referrer URL.
2466
+ :param transition_type: *(Optional)* Intended transition type.
2467
+ :param frame_id: *(Optional)* Frame id to navigate, if not specified navigates the top frame.
2468
+ :param referrer_policy: **(EXPERIMENTAL)** *(Optional)* Referrer-policy used for the navigation.
2469
+ :returns: A tuple with the following items:
2470
+
2471
+ 0. **frameId** - Frame id that has navigated (or failed to navigate)
2472
+ 1. **loaderId** - *(Optional)* Loader identifier. This is omitted in case of same-document navigation, as the previously committed loaderId would not change.
2473
+ 2. **errorText** - *(Optional)* User friendly error message, present if and only if navigation has failed.
2474
+ 3. **isDownload** - *(Optional)* Whether the navigation resulted in a download.
2475
+ '''
2476
+ params: T_JSON_DICT = dict()
2477
+ params['url'] = url
2478
+ if referrer is not None:
2479
+ params['referrer'] = referrer
2480
+ if transition_type is not None:
2481
+ params['transitionType'] = transition_type.to_json()
2482
+ if frame_id is not None:
2483
+ params['frameId'] = frame_id.to_json()
2484
+ if referrer_policy is not None:
2485
+ params['referrerPolicy'] = referrer_policy.to_json()
2486
+ cmd_dict: T_JSON_DICT = {
2487
+ 'method': 'Page.navigate',
2488
+ 'params': params,
2489
+ }
2490
+ json = yield cmd_dict
2491
+ return (
2492
+ FrameId.from_json(json['frameId']),
2493
+ network.LoaderId.from_json(json['loaderId']) if json.get('loaderId', None) is not None else None,
2494
+ str(json['errorText']) if json.get('errorText', None) is not None else None,
2495
+ bool(json['isDownload']) if json.get('isDownload', None) is not None else None
2496
+ )
2497
+
2498
+
2499
+ def navigate_to_history_entry(
2500
+ entry_id: int
2501
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2502
+ '''
2503
+ Navigates current page to the given history entry.
2504
+
2505
+ :param entry_id: Unique id of the entry to navigate to.
2506
+ '''
2507
+ params: T_JSON_DICT = dict()
2508
+ params['entryId'] = entry_id
2509
+ cmd_dict: T_JSON_DICT = {
2510
+ 'method': 'Page.navigateToHistoryEntry',
2511
+ 'params': params,
2512
+ }
2513
+ json = yield cmd_dict
2514
+
2515
+
2516
+ def print_to_pdf(
2517
+ landscape: typing.Optional[bool] = None,
2518
+ display_header_footer: typing.Optional[bool] = None,
2519
+ print_background: typing.Optional[bool] = None,
2520
+ scale: typing.Optional[float] = None,
2521
+ paper_width: typing.Optional[float] = None,
2522
+ paper_height: typing.Optional[float] = None,
2523
+ margin_top: typing.Optional[float] = None,
2524
+ margin_bottom: typing.Optional[float] = None,
2525
+ margin_left: typing.Optional[float] = None,
2526
+ margin_right: typing.Optional[float] = None,
2527
+ page_ranges: typing.Optional[str] = None,
2528
+ header_template: typing.Optional[str] = None,
2529
+ footer_template: typing.Optional[str] = None,
2530
+ prefer_css_page_size: typing.Optional[bool] = None,
2531
+ transfer_mode: typing.Optional[str] = None,
2532
+ generate_tagged_pdf: typing.Optional[bool] = None,
2533
+ generate_document_outline: typing.Optional[bool] = None
2534
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[str, typing.Optional[io.StreamHandle]]]:
2535
+ '''
2536
+ Print page as PDF.
2537
+
2538
+ :param landscape: *(Optional)* Paper orientation. Defaults to false.
2539
+ :param display_header_footer: *(Optional)* Display header and footer. Defaults to false.
2540
+ :param print_background: *(Optional)* Print background graphics. Defaults to false.
2541
+ :param scale: *(Optional)* Scale of the webpage rendering. Defaults to 1.
2542
+ :param paper_width: *(Optional)* Paper width in inches. Defaults to 8.5 inches.
2543
+ :param paper_height: *(Optional)* Paper height in inches. Defaults to 11 inches.
2544
+ :param margin_top: *(Optional)* Top margin in inches. Defaults to 1cm (~0.4 inches).
2545
+ :param margin_bottom: *(Optional)* Bottom margin in inches. Defaults to 1cm (~0.4 inches).
2546
+ :param margin_left: *(Optional)* Left margin in inches. Defaults to 1cm (~0.4 inches).
2547
+ :param margin_right: *(Optional)* Right margin in inches. Defaults to 1cm (~0.4 inches).
2548
+ :param page_ranges: *(Optional)* Paper ranges to print, one based, e.g., '1-5, 8, 11-13'. Pages are printed in the document order, not in the order specified, and no more than once. Defaults to empty string, which implies the entire document is printed. The page numbers are quietly capped to actual page count of the document, and ranges beyond the end of the document are ignored. If this results in no pages to print, an error is reported. It is an error to specify a range with start greater than end.
2549
+ :param header_template: *(Optional)* HTML template for the print header. Should be valid HTML markup with following classes used to inject printing values into them: - ```date````: formatted print date - ````title````: document title - ````url````: document location - ````pageNumber````: current page number - ````totalPages````: total pages in the document For example, ````<span class=title></span>```` would generate span containing the title.
2550
+ :param footer_template: *(Optional)* HTML template for the print footer. Should use the same format as the ````headerTemplate````.
2551
+ :param prefer_css_page_size: *(Optional)* Whether or not to prefer page size as defined by css. Defaults to false, in which case the content will be scaled to fit the paper size.
2552
+ :param transfer_mode: **(EXPERIMENTAL)** *(Optional)* return as stream
2553
+ :param generate_tagged_pdf: **(EXPERIMENTAL)** *(Optional)* Whether or not to generate tagged (accessible) PDF. Defaults to embedder choice.
2554
+ :param generate_document_outline: **(EXPERIMENTAL)** *(Optional)* Whether or not to embed the document outline into the PDF.
2555
+ :returns: A tuple with the following items:
2556
+
2557
+ 0. **data** - Base64-encoded pdf data. Empty if `` returnAsStream` is specified. (Encoded as a base64 string when passed over JSON)
2558
+ 1. **stream** - *(Optional)* A handle of the stream that holds resulting PDF data.
2559
+ '''
2560
+ params: T_JSON_DICT = dict()
2561
+ if landscape is not None:
2562
+ params['landscape'] = landscape
2563
+ if display_header_footer is not None:
2564
+ params['displayHeaderFooter'] = display_header_footer
2565
+ if print_background is not None:
2566
+ params['printBackground'] = print_background
2567
+ if scale is not None:
2568
+ params['scale'] = scale
2569
+ if paper_width is not None:
2570
+ params['paperWidth'] = paper_width
2571
+ if paper_height is not None:
2572
+ params['paperHeight'] = paper_height
2573
+ if margin_top is not None:
2574
+ params['marginTop'] = margin_top
2575
+ if margin_bottom is not None:
2576
+ params['marginBottom'] = margin_bottom
2577
+ if margin_left is not None:
2578
+ params['marginLeft'] = margin_left
2579
+ if margin_right is not None:
2580
+ params['marginRight'] = margin_right
2581
+ if page_ranges is not None:
2582
+ params['pageRanges'] = page_ranges
2583
+ if header_template is not None:
2584
+ params['headerTemplate'] = header_template
2585
+ if footer_template is not None:
2586
+ params['footerTemplate'] = footer_template
2587
+ if prefer_css_page_size is not None:
2588
+ params['preferCSSPageSize'] = prefer_css_page_size
2589
+ if transfer_mode is not None:
2590
+ params['transferMode'] = transfer_mode
2591
+ if generate_tagged_pdf is not None:
2592
+ params['generateTaggedPDF'] = generate_tagged_pdf
2593
+ if generate_document_outline is not None:
2594
+ params['generateDocumentOutline'] = generate_document_outline
2595
+ cmd_dict: T_JSON_DICT = {
2596
+ 'method': 'Page.printToPDF',
2597
+ 'params': params,
2598
+ }
2599
+ json = yield cmd_dict
2600
+ return (
2601
+ str(json['data']),
2602
+ io.StreamHandle.from_json(json['stream']) if json.get('stream', None) is not None else None
2603
+ )
2604
+
2605
+
2606
+ def reload(
2607
+ ignore_cache: typing.Optional[bool] = None,
2608
+ script_to_evaluate_on_load: typing.Optional[str] = None,
2609
+ loader_id: typing.Optional[network.LoaderId] = None
2610
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2611
+ '''
2612
+ Reloads given page optionally ignoring the cache.
2613
+
2614
+ :param ignore_cache: *(Optional)* If true, browser cache is ignored (as if the user pressed Shift+refresh).
2615
+ :param script_to_evaluate_on_load: *(Optional)* If set, the script will be injected into all frames of the inspected page after reload. Argument will be ignored if reloading dataURL origin.
2616
+ :param loader_id: **(EXPERIMENTAL)** *(Optional)* If set, an error will be thrown if the target page's main frame's loader id does not match the provided id. This prevents accidentally reloading an unintended target in case there's a racing navigation.
2617
+ '''
2618
+ params: T_JSON_DICT = dict()
2619
+ if ignore_cache is not None:
2620
+ params['ignoreCache'] = ignore_cache
2621
+ if script_to_evaluate_on_load is not None:
2622
+ params['scriptToEvaluateOnLoad'] = script_to_evaluate_on_load
2623
+ if loader_id is not None:
2624
+ params['loaderId'] = loader_id.to_json()
2625
+ cmd_dict: T_JSON_DICT = {
2626
+ 'method': 'Page.reload',
2627
+ 'params': params,
2628
+ }
2629
+ json = yield cmd_dict
2630
+
2631
+
2632
+ @deprecated(version="1.3")
2633
+ def remove_script_to_evaluate_on_load(
2634
+ identifier: ScriptIdentifier
2635
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2636
+ '''
2637
+ Deprecated, please use removeScriptToEvaluateOnNewDocument instead.
2638
+
2639
+ .. deprecated:: 1.3
2640
+
2641
+ **EXPERIMENTAL**
2642
+
2643
+ :param identifier:
2644
+ '''
2645
+ params: T_JSON_DICT = dict()
2646
+ params['identifier'] = identifier.to_json()
2647
+ cmd_dict: T_JSON_DICT = {
2648
+ 'method': 'Page.removeScriptToEvaluateOnLoad',
2649
+ 'params': params,
2650
+ }
2651
+ json = yield cmd_dict
2652
+
2653
+
2654
+ def remove_script_to_evaluate_on_new_document(
2655
+ identifier: ScriptIdentifier
2656
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2657
+ '''
2658
+ Removes given script from the list.
2659
+
2660
+ :param identifier:
2661
+ '''
2662
+ params: T_JSON_DICT = dict()
2663
+ params['identifier'] = identifier.to_json()
2664
+ cmd_dict: T_JSON_DICT = {
2665
+ 'method': 'Page.removeScriptToEvaluateOnNewDocument',
2666
+ 'params': params,
2667
+ }
2668
+ json = yield cmd_dict
2669
+
2670
+
2671
+ def screencast_frame_ack(
2672
+ session_id: int
2673
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2674
+ '''
2675
+ Acknowledges that a screencast frame has been received by the frontend.
2676
+
2677
+ **EXPERIMENTAL**
2678
+
2679
+ :param session_id: Frame number.
2680
+ '''
2681
+ params: T_JSON_DICT = dict()
2682
+ params['sessionId'] = session_id
2683
+ cmd_dict: T_JSON_DICT = {
2684
+ 'method': 'Page.screencastFrameAck',
2685
+ 'params': params,
2686
+ }
2687
+ json = yield cmd_dict
2688
+
2689
+
2690
+ def search_in_resource(
2691
+ frame_id: FrameId,
2692
+ url: str,
2693
+ query: str,
2694
+ case_sensitive: typing.Optional[bool] = None,
2695
+ is_regex: typing.Optional[bool] = None
2696
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[debugger.SearchMatch]]:
2697
+ '''
2698
+ Searches for given string in resource content.
2699
+
2700
+ **EXPERIMENTAL**
2701
+
2702
+ :param frame_id: Frame id for resource to search in.
2703
+ :param url: URL of the resource to search in.
2704
+ :param query: String to search for.
2705
+ :param case_sensitive: *(Optional)* If true, search is case sensitive.
2706
+ :param is_regex: *(Optional)* If true, treats string parameter as regex.
2707
+ :returns: List of search matches.
2708
+ '''
2709
+ params: T_JSON_DICT = dict()
2710
+ params['frameId'] = frame_id.to_json()
2711
+ params['url'] = url
2712
+ params['query'] = query
2713
+ if case_sensitive is not None:
2714
+ params['caseSensitive'] = case_sensitive
2715
+ if is_regex is not None:
2716
+ params['isRegex'] = is_regex
2717
+ cmd_dict: T_JSON_DICT = {
2718
+ 'method': 'Page.searchInResource',
2719
+ 'params': params,
2720
+ }
2721
+ json = yield cmd_dict
2722
+ return [debugger.SearchMatch.from_json(i) for i in json['result']]
2723
+
2724
+
2725
+ def set_ad_blocking_enabled(
2726
+ enabled: bool
2727
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2728
+ '''
2729
+ Enable Chrome's experimental ad filter on all sites.
2730
+
2731
+ **EXPERIMENTAL**
2732
+
2733
+ :param enabled: Whether to block ads.
2734
+ '''
2735
+ params: T_JSON_DICT = dict()
2736
+ params['enabled'] = enabled
2737
+ cmd_dict: T_JSON_DICT = {
2738
+ 'method': 'Page.setAdBlockingEnabled',
2739
+ 'params': params,
2740
+ }
2741
+ json = yield cmd_dict
2742
+
2743
+
2744
+ def set_bypass_csp(
2745
+ enabled: bool
2746
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2747
+ '''
2748
+ Enable page Content Security Policy by-passing.
2749
+
2750
+ :param enabled: Whether to bypass page CSP.
2751
+ '''
2752
+ params: T_JSON_DICT = dict()
2753
+ params['enabled'] = enabled
2754
+ cmd_dict: T_JSON_DICT = {
2755
+ 'method': 'Page.setBypassCSP',
2756
+ 'params': params,
2757
+ }
2758
+ json = yield cmd_dict
2759
+
2760
+
2761
+ def get_permissions_policy_state(
2762
+ frame_id: FrameId
2763
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[PermissionsPolicyFeatureState]]:
2764
+ '''
2765
+ Get Permissions Policy state on given frame.
2766
+
2767
+ **EXPERIMENTAL**
2768
+
2769
+ :param frame_id:
2770
+ :returns:
2771
+ '''
2772
+ params: T_JSON_DICT = dict()
2773
+ params['frameId'] = frame_id.to_json()
2774
+ cmd_dict: T_JSON_DICT = {
2775
+ 'method': 'Page.getPermissionsPolicyState',
2776
+ 'params': params,
2777
+ }
2778
+ json = yield cmd_dict
2779
+ return [PermissionsPolicyFeatureState.from_json(i) for i in json['states']]
2780
+
2781
+
2782
+ def get_origin_trials(
2783
+ frame_id: FrameId
2784
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[OriginTrial]]:
2785
+ '''
2786
+ Get Origin Trials on given frame.
2787
+
2788
+ **EXPERIMENTAL**
2789
+
2790
+ :param frame_id:
2791
+ :returns:
2792
+ '''
2793
+ params: T_JSON_DICT = dict()
2794
+ params['frameId'] = frame_id.to_json()
2795
+ cmd_dict: T_JSON_DICT = {
2796
+ 'method': 'Page.getOriginTrials',
2797
+ 'params': params,
2798
+ }
2799
+ json = yield cmd_dict
2800
+ return [OriginTrial.from_json(i) for i in json['originTrials']]
2801
+
2802
+
2803
+ @deprecated(version="1.3")
2804
+ def set_device_metrics_override(
2805
+ width: int,
2806
+ height: int,
2807
+ device_scale_factor: float,
2808
+ mobile: bool,
2809
+ scale: typing.Optional[float] = None,
2810
+ screen_width: typing.Optional[int] = None,
2811
+ screen_height: typing.Optional[int] = None,
2812
+ position_x: typing.Optional[int] = None,
2813
+ position_y: typing.Optional[int] = None,
2814
+ dont_set_visible_size: typing.Optional[bool] = None,
2815
+ screen_orientation: typing.Optional[emulation.ScreenOrientation] = None,
2816
+ viewport: typing.Optional[Viewport] = None
2817
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2818
+ '''
2819
+ Overrides the values of device screen dimensions (window.screen.width, window.screen.height,
2820
+ window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media
2821
+ query results).
2822
+
2823
+ .. deprecated:: 1.3
2824
+
2825
+ **EXPERIMENTAL**
2826
+
2827
+ :param width: Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
2828
+ :param height: Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
2829
+ :param device_scale_factor: Overriding device scale factor value. 0 disables the override.
2830
+ :param mobile: Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more.
2831
+ :param scale: *(Optional)* Scale to apply to resulting view image.
2832
+ :param screen_width: *(Optional)* Overriding screen width value in pixels (minimum 0, maximum 10000000).
2833
+ :param screen_height: *(Optional)* Overriding screen height value in pixels (minimum 0, maximum 10000000).
2834
+ :param position_x: *(Optional)* Overriding view X position on screen in pixels (minimum 0, maximum 10000000).
2835
+ :param position_y: *(Optional)* Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
2836
+ :param dont_set_visible_size: *(Optional)* Do not set visible view size, rely upon explicit setVisibleSize call.
2837
+ :param screen_orientation: *(Optional)* Screen orientation override.
2838
+ :param viewport: *(Optional)* The viewport dimensions and scale. If not set, the override is cleared.
2839
+ '''
2840
+ params: T_JSON_DICT = dict()
2841
+ params['width'] = width
2842
+ params['height'] = height
2843
+ params['deviceScaleFactor'] = device_scale_factor
2844
+ params['mobile'] = mobile
2845
+ if scale is not None:
2846
+ params['scale'] = scale
2847
+ if screen_width is not None:
2848
+ params['screenWidth'] = screen_width
2849
+ if screen_height is not None:
2850
+ params['screenHeight'] = screen_height
2851
+ if position_x is not None:
2852
+ params['positionX'] = position_x
2853
+ if position_y is not None:
2854
+ params['positionY'] = position_y
2855
+ if dont_set_visible_size is not None:
2856
+ params['dontSetVisibleSize'] = dont_set_visible_size
2857
+ if screen_orientation is not None:
2858
+ params['screenOrientation'] = screen_orientation.to_json()
2859
+ if viewport is not None:
2860
+ params['viewport'] = viewport.to_json()
2861
+ cmd_dict: T_JSON_DICT = {
2862
+ 'method': 'Page.setDeviceMetricsOverride',
2863
+ 'params': params,
2864
+ }
2865
+ json = yield cmd_dict
2866
+
2867
+
2868
+ @deprecated(version="1.3")
2869
+ def set_device_orientation_override(
2870
+ alpha: float,
2871
+ beta: float,
2872
+ gamma: float
2873
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2874
+ '''
2875
+ Overrides the Device Orientation.
2876
+
2877
+ .. deprecated:: 1.3
2878
+
2879
+ **EXPERIMENTAL**
2880
+
2881
+ :param alpha: Mock alpha
2882
+ :param beta: Mock beta
2883
+ :param gamma: Mock gamma
2884
+ '''
2885
+ params: T_JSON_DICT = dict()
2886
+ params['alpha'] = alpha
2887
+ params['beta'] = beta
2888
+ params['gamma'] = gamma
2889
+ cmd_dict: T_JSON_DICT = {
2890
+ 'method': 'Page.setDeviceOrientationOverride',
2891
+ 'params': params,
2892
+ }
2893
+ json = yield cmd_dict
2894
+
2895
+
2896
+ def set_font_families(
2897
+ font_families: FontFamilies,
2898
+ for_scripts: typing.Optional[typing.List[ScriptFontFamilies]] = None
2899
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2900
+ '''
2901
+ Set generic font families.
2902
+
2903
+ **EXPERIMENTAL**
2904
+
2905
+ :param font_families: Specifies font families to set. If a font family is not specified, it won't be changed.
2906
+ :param for_scripts: *(Optional)* Specifies font families to set for individual scripts.
2907
+ '''
2908
+ params: T_JSON_DICT = dict()
2909
+ params['fontFamilies'] = font_families.to_json()
2910
+ if for_scripts is not None:
2911
+ params['forScripts'] = [i.to_json() for i in for_scripts]
2912
+ cmd_dict: T_JSON_DICT = {
2913
+ 'method': 'Page.setFontFamilies',
2914
+ 'params': params,
2915
+ }
2916
+ json = yield cmd_dict
2917
+
2918
+
2919
+ def set_font_sizes(
2920
+ font_sizes: FontSizes
2921
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2922
+ '''
2923
+ Set default font sizes.
2924
+
2925
+ **EXPERIMENTAL**
2926
+
2927
+ :param font_sizes: Specifies font sizes to set. If a font size is not specified, it won't be changed.
2928
+ '''
2929
+ params: T_JSON_DICT = dict()
2930
+ params['fontSizes'] = font_sizes.to_json()
2931
+ cmd_dict: T_JSON_DICT = {
2932
+ 'method': 'Page.setFontSizes',
2933
+ 'params': params,
2934
+ }
2935
+ json = yield cmd_dict
2936
+
2937
+
2938
+ def set_document_content(
2939
+ frame_id: FrameId,
2940
+ html: str
2941
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2942
+ '''
2943
+ Sets given markup as the document's HTML.
2944
+
2945
+ :param frame_id: Frame id to set HTML for.
2946
+ :param html: HTML content to set.
2947
+ '''
2948
+ params: T_JSON_DICT = dict()
2949
+ params['frameId'] = frame_id.to_json()
2950
+ params['html'] = html
2951
+ cmd_dict: T_JSON_DICT = {
2952
+ 'method': 'Page.setDocumentContent',
2953
+ 'params': params,
2954
+ }
2955
+ json = yield cmd_dict
2956
+
2957
+
2958
+ @deprecated(version="1.3")
2959
+ def set_download_behavior(
2960
+ behavior: str,
2961
+ download_path: typing.Optional[str] = None
2962
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2963
+ '''
2964
+ Set the behavior when downloading a file.
2965
+
2966
+ .. deprecated:: 1.3
2967
+
2968
+ **EXPERIMENTAL**
2969
+
2970
+ :param behavior: Whether to allow all or deny all download requests, or use default Chrome behavior if available (otherwise deny).
2971
+ :param download_path: *(Optional)* The default path to save downloaded files to. This is required if behavior is set to 'allow'
2972
+ '''
2973
+ params: T_JSON_DICT = dict()
2974
+ params['behavior'] = behavior
2975
+ if download_path is not None:
2976
+ params['downloadPath'] = download_path
2977
+ cmd_dict: T_JSON_DICT = {
2978
+ 'method': 'Page.setDownloadBehavior',
2979
+ 'params': params,
2980
+ }
2981
+ json = yield cmd_dict
2982
+
2983
+
2984
+ @deprecated(version="1.3")
2985
+ def set_geolocation_override(
2986
+ latitude: typing.Optional[float] = None,
2987
+ longitude: typing.Optional[float] = None,
2988
+ accuracy: typing.Optional[float] = None
2989
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
2990
+ '''
2991
+ Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position
2992
+ unavailable.
2993
+
2994
+ .. deprecated:: 1.3
2995
+
2996
+ :param latitude: *(Optional)* Mock latitude
2997
+ :param longitude: *(Optional)* Mock longitude
2998
+ :param accuracy: *(Optional)* Mock accuracy
2999
+ '''
3000
+ params: T_JSON_DICT = dict()
3001
+ if latitude is not None:
3002
+ params['latitude'] = latitude
3003
+ if longitude is not None:
3004
+ params['longitude'] = longitude
3005
+ if accuracy is not None:
3006
+ params['accuracy'] = accuracy
3007
+ cmd_dict: T_JSON_DICT = {
3008
+ 'method': 'Page.setGeolocationOverride',
3009
+ 'params': params,
3010
+ }
3011
+ json = yield cmd_dict
3012
+
3013
+
3014
+ def set_lifecycle_events_enabled(
3015
+ enabled: bool
3016
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3017
+ '''
3018
+ Controls whether page will emit lifecycle events.
3019
+
3020
+ :param enabled: If true, starts emitting lifecycle events.
3021
+ '''
3022
+ params: T_JSON_DICT = dict()
3023
+ params['enabled'] = enabled
3024
+ cmd_dict: T_JSON_DICT = {
3025
+ 'method': 'Page.setLifecycleEventsEnabled',
3026
+ 'params': params,
3027
+ }
3028
+ json = yield cmd_dict
3029
+
3030
+
3031
+ @deprecated(version="1.3")
3032
+ def set_touch_emulation_enabled(
3033
+ enabled: bool,
3034
+ configuration: typing.Optional[str] = None
3035
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3036
+ '''
3037
+ Toggles mouse event-based touch event emulation.
3038
+
3039
+ .. deprecated:: 1.3
3040
+
3041
+ **EXPERIMENTAL**
3042
+
3043
+ :param enabled: Whether the touch event emulation should be enabled.
3044
+ :param configuration: *(Optional)* Touch/gesture events configuration. Default: current platform.
3045
+ '''
3046
+ params: T_JSON_DICT = dict()
3047
+ params['enabled'] = enabled
3048
+ if configuration is not None:
3049
+ params['configuration'] = configuration
3050
+ cmd_dict: T_JSON_DICT = {
3051
+ 'method': 'Page.setTouchEmulationEnabled',
3052
+ 'params': params,
3053
+ }
3054
+ json = yield cmd_dict
3055
+
3056
+
3057
+ def start_screencast(
3058
+ format_: typing.Optional[str] = None,
3059
+ quality: typing.Optional[int] = None,
3060
+ max_width: typing.Optional[int] = None,
3061
+ max_height: typing.Optional[int] = None,
3062
+ every_nth_frame: typing.Optional[int] = None
3063
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3064
+ '''
3065
+ Starts sending each frame using the ``screencastFrame`` event.
3066
+
3067
+ **EXPERIMENTAL**
3068
+
3069
+ :param format_: *(Optional)* Image compression format.
3070
+ :param quality: *(Optional)* Compression quality from range [0..100].
3071
+ :param max_width: *(Optional)* Maximum screenshot width.
3072
+ :param max_height: *(Optional)* Maximum screenshot height.
3073
+ :param every_nth_frame: *(Optional)* Send every n-th frame.
3074
+ '''
3075
+ params: T_JSON_DICT = dict()
3076
+ if format_ is not None:
3077
+ params['format'] = format_
3078
+ if quality is not None:
3079
+ params['quality'] = quality
3080
+ if max_width is not None:
3081
+ params['maxWidth'] = max_width
3082
+ if max_height is not None:
3083
+ params['maxHeight'] = max_height
3084
+ if every_nth_frame is not None:
3085
+ params['everyNthFrame'] = every_nth_frame
3086
+ cmd_dict: T_JSON_DICT = {
3087
+ 'method': 'Page.startScreencast',
3088
+ 'params': params,
3089
+ }
3090
+ json = yield cmd_dict
3091
+
3092
+
3093
+ def stop_loading() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3094
+ '''
3095
+ Force the page stop all navigations and pending resource fetches.
3096
+ '''
3097
+ cmd_dict: T_JSON_DICT = {
3098
+ 'method': 'Page.stopLoading',
3099
+ }
3100
+ json = yield cmd_dict
3101
+
3102
+
3103
+ def crash() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3104
+ '''
3105
+ Crashes renderer on the IO thread, generates minidumps.
3106
+
3107
+ **EXPERIMENTAL**
3108
+ '''
3109
+ cmd_dict: T_JSON_DICT = {
3110
+ 'method': 'Page.crash',
3111
+ }
3112
+ json = yield cmd_dict
3113
+
3114
+
3115
+ def close() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3116
+ '''
3117
+ Tries to close page, running its beforeunload hooks, if any.
3118
+ '''
3119
+ cmd_dict: T_JSON_DICT = {
3120
+ 'method': 'Page.close',
3121
+ }
3122
+ json = yield cmd_dict
3123
+
3124
+
3125
+ def set_web_lifecycle_state(
3126
+ state: str
3127
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3128
+ '''
3129
+ Tries to update the web lifecycle state of the page.
3130
+ It will transition the page to the given state according to:
3131
+ https://github.com/WICG/web-lifecycle/
3132
+
3133
+ **EXPERIMENTAL**
3134
+
3135
+ :param state: Target lifecycle state
3136
+ '''
3137
+ params: T_JSON_DICT = dict()
3138
+ params['state'] = state
3139
+ cmd_dict: T_JSON_DICT = {
3140
+ 'method': 'Page.setWebLifecycleState',
3141
+ 'params': params,
3142
+ }
3143
+ json = yield cmd_dict
3144
+
3145
+
3146
+ def stop_screencast() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3147
+ '''
3148
+ Stops sending each frame in the ``screencastFrame``.
3149
+
3150
+ **EXPERIMENTAL**
3151
+ '''
3152
+ cmd_dict: T_JSON_DICT = {
3153
+ 'method': 'Page.stopScreencast',
3154
+ }
3155
+ json = yield cmd_dict
3156
+
3157
+
3158
+ def produce_compilation_cache(
3159
+ scripts: typing.List[CompilationCacheParams]
3160
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3161
+ '''
3162
+ Requests backend to produce compilation cache for the specified scripts.
3163
+ ``scripts`` are appended to the list of scripts for which the cache
3164
+ would be produced. The list may be reset during page navigation.
3165
+ When script with a matching URL is encountered, the cache is optionally
3166
+ produced upon backend discretion, based on internal heuristics.
3167
+ See also: ``Page.compilationCacheProduced``.
3168
+
3169
+ **EXPERIMENTAL**
3170
+
3171
+ :param scripts:
3172
+ '''
3173
+ params: T_JSON_DICT = dict()
3174
+ params['scripts'] = [i.to_json() for i in scripts]
3175
+ cmd_dict: T_JSON_DICT = {
3176
+ 'method': 'Page.produceCompilationCache',
3177
+ 'params': params,
3178
+ }
3179
+ json = yield cmd_dict
3180
+
3181
+
3182
+ def add_compilation_cache(
3183
+ url: str,
3184
+ data: str
3185
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3186
+ '''
3187
+ Seeds compilation cache for given url. Compilation cache does not survive
3188
+ cross-process navigation.
3189
+
3190
+ **EXPERIMENTAL**
3191
+
3192
+ :param url:
3193
+ :param data: Base64-encoded data (Encoded as a base64 string when passed over JSON)
3194
+ '''
3195
+ params: T_JSON_DICT = dict()
3196
+ params['url'] = url
3197
+ params['data'] = data
3198
+ cmd_dict: T_JSON_DICT = {
3199
+ 'method': 'Page.addCompilationCache',
3200
+ 'params': params,
3201
+ }
3202
+ json = yield cmd_dict
3203
+
3204
+
3205
+ def clear_compilation_cache() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3206
+ '''
3207
+ Clears seeded compilation cache.
3208
+
3209
+ **EXPERIMENTAL**
3210
+ '''
3211
+ cmd_dict: T_JSON_DICT = {
3212
+ 'method': 'Page.clearCompilationCache',
3213
+ }
3214
+ json = yield cmd_dict
3215
+
3216
+
3217
+ def set_spc_transaction_mode(
3218
+ mode: str
3219
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3220
+ '''
3221
+ Sets the Secure Payment Confirmation transaction mode.
3222
+ https://w3c.github.io/secure-payment-confirmation/#sctn-automation-set-spc-transaction-mode
3223
+
3224
+ **EXPERIMENTAL**
3225
+
3226
+ :param mode:
3227
+ '''
3228
+ params: T_JSON_DICT = dict()
3229
+ params['mode'] = mode
3230
+ cmd_dict: T_JSON_DICT = {
3231
+ 'method': 'Page.setSPCTransactionMode',
3232
+ 'params': params,
3233
+ }
3234
+ json = yield cmd_dict
3235
+
3236
+
3237
+ def set_rph_registration_mode(
3238
+ mode: str
3239
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3240
+ '''
3241
+ Extensions for Custom Handlers API:
3242
+ https://html.spec.whatwg.org/multipage/system-state.html#rph-automation
3243
+
3244
+ **EXPERIMENTAL**
3245
+
3246
+ :param mode:
3247
+ '''
3248
+ params: T_JSON_DICT = dict()
3249
+ params['mode'] = mode
3250
+ cmd_dict: T_JSON_DICT = {
3251
+ 'method': 'Page.setRPHRegistrationMode',
3252
+ 'params': params,
3253
+ }
3254
+ json = yield cmd_dict
3255
+
3256
+
3257
+ def generate_test_report(
3258
+ message: str,
3259
+ group: typing.Optional[str] = None
3260
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3261
+ '''
3262
+ Generates a report for testing.
3263
+
3264
+ **EXPERIMENTAL**
3265
+
3266
+ :param message: Message to be displayed in the report.
3267
+ :param group: *(Optional)* Specifies the endpoint group to deliver the report to.
3268
+ '''
3269
+ params: T_JSON_DICT = dict()
3270
+ params['message'] = message
3271
+ if group is not None:
3272
+ params['group'] = group
3273
+ cmd_dict: T_JSON_DICT = {
3274
+ 'method': 'Page.generateTestReport',
3275
+ 'params': params,
3276
+ }
3277
+ json = yield cmd_dict
3278
+
3279
+
3280
+ def wait_for_debugger() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3281
+ '''
3282
+ Pauses page execution. Can be resumed using generic Runtime.runIfWaitingForDebugger.
3283
+
3284
+ **EXPERIMENTAL**
3285
+ '''
3286
+ cmd_dict: T_JSON_DICT = {
3287
+ 'method': 'Page.waitForDebugger',
3288
+ }
3289
+ json = yield cmd_dict
3290
+
3291
+
3292
+ def set_intercept_file_chooser_dialog(
3293
+ enabled: bool,
3294
+ cancel: typing.Optional[bool] = None
3295
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3296
+ '''
3297
+ Intercept file chooser requests and transfer control to protocol clients.
3298
+ When file chooser interception is enabled, native file chooser dialog is not shown.
3299
+ Instead, a protocol event ``Page.fileChooserOpened`` is emitted.
3300
+
3301
+ :param enabled:
3302
+ :param cancel: **(EXPERIMENTAL)** *(Optional)* If true, cancels the dialog by emitting relevant events (if any) in addition to not showing it if the interception is enabled (default: false).
3303
+ '''
3304
+ params: T_JSON_DICT = dict()
3305
+ params['enabled'] = enabled
3306
+ if cancel is not None:
3307
+ params['cancel'] = cancel
3308
+ cmd_dict: T_JSON_DICT = {
3309
+ 'method': 'Page.setInterceptFileChooserDialog',
3310
+ 'params': params,
3311
+ }
3312
+ json = yield cmd_dict
3313
+
3314
+
3315
+ def set_prerendering_allowed(
3316
+ is_allowed: bool
3317
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
3318
+ '''
3319
+ Enable/disable prerendering manually.
3320
+
3321
+ This command is a short-term solution for https://crbug.com/1440085.
3322
+ See https://docs.google.com/document/d/12HVmFxYj5Jc-eJr5OmWsa2bqTJsbgGLKI6ZIyx0_wpA
3323
+ for more details.
3324
+
3325
+ TODO(https://crbug.com/1440085): Remove this once Puppeteer supports tab targets.
3326
+
3327
+ **EXPERIMENTAL**
3328
+
3329
+ :param is_allowed:
3330
+ '''
3331
+ params: T_JSON_DICT = dict()
3332
+ params['isAllowed'] = is_allowed
3333
+ cmd_dict: T_JSON_DICT = {
3334
+ 'method': 'Page.setPrerenderingAllowed',
3335
+ 'params': params,
3336
+ }
3337
+ json = yield cmd_dict
3338
+
3339
+
3340
+ def get_annotated_page_content(
3341
+ include_actionable_information: typing.Optional[bool] = None
3342
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
3343
+ '''
3344
+ Get the annotated page content for the main frame.
3345
+ This is an experimental command that is subject to change.
3346
+
3347
+ **EXPERIMENTAL**
3348
+
3349
+ :param include_actionable_information: *(Optional)* Whether to include actionable information. Defaults to true.
3350
+ :returns: The annotated page content as a base64 encoded protobuf. The format is defined by the ``AnnotatedPageContent`` message in components/optimization_guide/proto/features/common_quality_data.proto (Encoded as a base64 string when passed over JSON)
3351
+ '''
3352
+ params: T_JSON_DICT = dict()
3353
+ if include_actionable_information is not None:
3354
+ params['includeActionableInformation'] = include_actionable_information
3355
+ cmd_dict: T_JSON_DICT = {
3356
+ 'method': 'Page.getAnnotatedPageContent',
3357
+ 'params': params,
3358
+ }
3359
+ json = yield cmd_dict
3360
+ return str(json['content'])
3361
+
3362
+
3363
+ @event_class('Page.domContentEventFired')
3364
+ @dataclass
3365
+ class DomContentEventFired:
3366
+ timestamp: network.MonotonicTime
3367
+
3368
+ @classmethod
3369
+ def from_json(cls, json: T_JSON_DICT) -> DomContentEventFired:
3370
+ return cls(
3371
+ timestamp=network.MonotonicTime.from_json(json['timestamp'])
3372
+ )
3373
+
3374
+
3375
+ @event_class('Page.fileChooserOpened')
3376
+ @dataclass
3377
+ class FileChooserOpened:
3378
+ '''
3379
+ Emitted only when ``page.interceptFileChooser`` is enabled.
3380
+ '''
3381
+ #: Id of the frame containing input node.
3382
+ frame_id: FrameId
3383
+ #: Input mode.
3384
+ mode: str
3385
+ #: Input node id. Only present for file choosers opened via an ``<input type="file">`` element.
3386
+ backend_node_id: typing.Optional[dom.BackendNodeId]
3387
+
3388
+ @classmethod
3389
+ def from_json(cls, json: T_JSON_DICT) -> FileChooserOpened:
3390
+ return cls(
3391
+ frame_id=FrameId.from_json(json['frameId']),
3392
+ mode=str(json['mode']),
3393
+ backend_node_id=dom.BackendNodeId.from_json(json['backendNodeId']) if json.get('backendNodeId', None) is not None else None
3394
+ )
3395
+
3396
+
3397
+ @event_class('Page.frameAttached')
3398
+ @dataclass
3399
+ class FrameAttached:
3400
+ '''
3401
+ Fired when frame has been attached to its parent.
3402
+ '''
3403
+ #: Id of the frame that has been attached.
3404
+ frame_id: FrameId
3405
+ #: Parent frame identifier.
3406
+ parent_frame_id: FrameId
3407
+ #: JavaScript stack trace of when frame was attached, only set if frame initiated from script.
3408
+ stack: typing.Optional[runtime.StackTrace]
3409
+
3410
+ @classmethod
3411
+ def from_json(cls, json: T_JSON_DICT) -> FrameAttached:
3412
+ return cls(
3413
+ frame_id=FrameId.from_json(json['frameId']),
3414
+ parent_frame_id=FrameId.from_json(json['parentFrameId']),
3415
+ stack=runtime.StackTrace.from_json(json['stack']) if json.get('stack', None) is not None else None
3416
+ )
3417
+
3418
+
3419
+ @deprecated(version="1.3")
3420
+ @event_class('Page.frameClearedScheduledNavigation')
3421
+ @dataclass
3422
+ class FrameClearedScheduledNavigation:
3423
+ '''
3424
+ Fired when frame no longer has a scheduled navigation.
3425
+ '''
3426
+ #: Id of the frame that has cleared its scheduled navigation.
3427
+ frame_id: FrameId
3428
+
3429
+ @classmethod
3430
+ def from_json(cls, json: T_JSON_DICT) -> FrameClearedScheduledNavigation:
3431
+ return cls(
3432
+ frame_id=FrameId.from_json(json['frameId'])
3433
+ )
3434
+
3435
+
3436
+ @event_class('Page.frameDetached')
3437
+ @dataclass
3438
+ class FrameDetached:
3439
+ '''
3440
+ Fired when frame has been detached from its parent.
3441
+ '''
3442
+ #: Id of the frame that has been detached.
3443
+ frame_id: FrameId
3444
+ reason: str
3445
+
3446
+ @classmethod
3447
+ def from_json(cls, json: T_JSON_DICT) -> FrameDetached:
3448
+ return cls(
3449
+ frame_id=FrameId.from_json(json['frameId']),
3450
+ reason=str(json['reason'])
3451
+ )
3452
+
3453
+
3454
+ @event_class('Page.frameSubtreeWillBeDetached')
3455
+ @dataclass
3456
+ class FrameSubtreeWillBeDetached:
3457
+ '''
3458
+ **EXPERIMENTAL**
3459
+
3460
+ Fired before frame subtree is detached. Emitted before any frame of the
3461
+ subtree is actually detached.
3462
+ '''
3463
+ #: Id of the frame that is the root of the subtree that will be detached.
3464
+ frame_id: FrameId
3465
+
3466
+ @classmethod
3467
+ def from_json(cls, json: T_JSON_DICT) -> FrameSubtreeWillBeDetached:
3468
+ return cls(
3469
+ frame_id=FrameId.from_json(json['frameId'])
3470
+ )
3471
+
3472
+
3473
+ @event_class('Page.frameNavigated')
3474
+ @dataclass
3475
+ class FrameNavigated:
3476
+ '''
3477
+ Fired once navigation of the frame has completed. Frame is now associated with the new loader.
3478
+ '''
3479
+ #: Frame object.
3480
+ frame: Frame
3481
+ type_: NavigationType
3482
+
3483
+ @classmethod
3484
+ def from_json(cls, json: T_JSON_DICT) -> FrameNavigated:
3485
+ return cls(
3486
+ frame=Frame.from_json(json['frame']),
3487
+ type_=NavigationType.from_json(json['type'])
3488
+ )
3489
+
3490
+
3491
+ @event_class('Page.documentOpened')
3492
+ @dataclass
3493
+ class DocumentOpened:
3494
+ '''
3495
+ **EXPERIMENTAL**
3496
+
3497
+ Fired when opening document to write to.
3498
+ '''
3499
+ #: Frame object.
3500
+ frame: Frame
3501
+
3502
+ @classmethod
3503
+ def from_json(cls, json: T_JSON_DICT) -> DocumentOpened:
3504
+ return cls(
3505
+ frame=Frame.from_json(json['frame'])
3506
+ )
3507
+
3508
+
3509
+ @event_class('Page.frameResized')
3510
+ @dataclass
3511
+ class FrameResized:
3512
+ '''
3513
+ **EXPERIMENTAL**
3514
+
3515
+
3516
+ '''
3517
+
3518
+
3519
+ @classmethod
3520
+ def from_json(cls, json: T_JSON_DICT) -> FrameResized:
3521
+ return cls(
3522
+
3523
+ )
3524
+
3525
+
3526
+ @event_class('Page.frameStartedNavigating')
3527
+ @dataclass
3528
+ class FrameStartedNavigating:
3529
+ '''
3530
+ **EXPERIMENTAL**
3531
+
3532
+ Fired when a navigation starts. This event is fired for both
3533
+ renderer-initiated and browser-initiated navigations. For renderer-initiated
3534
+ navigations, the event is fired after ``frameRequestedNavigation``.
3535
+ Navigation may still be cancelled after the event is issued. Multiple events
3536
+ can be fired for a single navigation, for example, when a same-document
3537
+ navigation becomes a cross-document navigation (such as in the case of a
3538
+ frameset).
3539
+ '''
3540
+ #: ID of the frame that is being navigated.
3541
+ frame_id: FrameId
3542
+ #: The URL the navigation started with. The final URL can be different.
3543
+ url: str
3544
+ #: Loader identifier. Even though it is present in case of same-document
3545
+ #: navigation, the previously committed loaderId would not change unless
3546
+ #: the navigation changes from a same-document to a cross-document
3547
+ #: navigation.
3548
+ loader_id: network.LoaderId
3549
+ navigation_type: str
3550
+
3551
+ @classmethod
3552
+ def from_json(cls, json: T_JSON_DICT) -> FrameStartedNavigating:
3553
+ return cls(
3554
+ frame_id=FrameId.from_json(json['frameId']),
3555
+ url=str(json['url']),
3556
+ loader_id=network.LoaderId.from_json(json['loaderId']),
3557
+ navigation_type=str(json['navigationType'])
3558
+ )
3559
+
3560
+
3561
+ @event_class('Page.frameRequestedNavigation')
3562
+ @dataclass
3563
+ class FrameRequestedNavigation:
3564
+ '''
3565
+ **EXPERIMENTAL**
3566
+
3567
+ Fired when a renderer-initiated navigation is requested.
3568
+ Navigation may still be cancelled after the event is issued.
3569
+ '''
3570
+ #: Id of the frame that is being navigated.
3571
+ frame_id: FrameId
3572
+ #: The reason for the navigation.
3573
+ reason: ClientNavigationReason
3574
+ #: The destination URL for the requested navigation.
3575
+ url: str
3576
+ #: The disposition for the navigation.
3577
+ disposition: ClientNavigationDisposition
3578
+
3579
+ @classmethod
3580
+ def from_json(cls, json: T_JSON_DICT) -> FrameRequestedNavigation:
3581
+ return cls(
3582
+ frame_id=FrameId.from_json(json['frameId']),
3583
+ reason=ClientNavigationReason.from_json(json['reason']),
3584
+ url=str(json['url']),
3585
+ disposition=ClientNavigationDisposition.from_json(json['disposition'])
3586
+ )
3587
+
3588
+
3589
+ @deprecated(version="1.3")
3590
+ @event_class('Page.frameScheduledNavigation')
3591
+ @dataclass
3592
+ class FrameScheduledNavigation:
3593
+ '''
3594
+ Fired when frame schedules a potential navigation.
3595
+ '''
3596
+ #: Id of the frame that has scheduled a navigation.
3597
+ frame_id: FrameId
3598
+ #: Delay (in seconds) until the navigation is scheduled to begin. The navigation is not
3599
+ #: guaranteed to start.
3600
+ delay: float
3601
+ #: The reason for the navigation.
3602
+ reason: ClientNavigationReason
3603
+ #: The destination URL for the scheduled navigation.
3604
+ url: str
3605
+
3606
+ @classmethod
3607
+ def from_json(cls, json: T_JSON_DICT) -> FrameScheduledNavigation:
3608
+ return cls(
3609
+ frame_id=FrameId.from_json(json['frameId']),
3610
+ delay=float(json['delay']),
3611
+ reason=ClientNavigationReason.from_json(json['reason']),
3612
+ url=str(json['url'])
3613
+ )
3614
+
3615
+
3616
+ @event_class('Page.frameStartedLoading')
3617
+ @dataclass
3618
+ class FrameStartedLoading:
3619
+ '''
3620
+ **EXPERIMENTAL**
3621
+
3622
+ Fired when frame has started loading.
3623
+ '''
3624
+ #: Id of the frame that has started loading.
3625
+ frame_id: FrameId
3626
+
3627
+ @classmethod
3628
+ def from_json(cls, json: T_JSON_DICT) -> FrameStartedLoading:
3629
+ return cls(
3630
+ frame_id=FrameId.from_json(json['frameId'])
3631
+ )
3632
+
3633
+
3634
+ @event_class('Page.frameStoppedLoading')
3635
+ @dataclass
3636
+ class FrameStoppedLoading:
3637
+ '''
3638
+ **EXPERIMENTAL**
3639
+
3640
+ Fired when frame has stopped loading.
3641
+ '''
3642
+ #: Id of the frame that has stopped loading.
3643
+ frame_id: FrameId
3644
+
3645
+ @classmethod
3646
+ def from_json(cls, json: T_JSON_DICT) -> FrameStoppedLoading:
3647
+ return cls(
3648
+ frame_id=FrameId.from_json(json['frameId'])
3649
+ )
3650
+
3651
+
3652
+ @deprecated(version="1.3")
3653
+ @event_class('Page.downloadWillBegin')
3654
+ @dataclass
3655
+ class DownloadWillBegin:
3656
+ '''
3657
+ **EXPERIMENTAL**
3658
+
3659
+ Fired when page is about to start a download.
3660
+ Deprecated. Use Browser.downloadWillBegin instead.
3661
+ '''
3662
+ #: Id of the frame that caused download to begin.
3663
+ frame_id: FrameId
3664
+ #: Global unique identifier of the download.
3665
+ guid: str
3666
+ #: URL of the resource being downloaded.
3667
+ url: str
3668
+ #: Suggested file name of the resource (the actual name of the file saved on disk may differ).
3669
+ suggested_filename: str
3670
+
3671
+ @classmethod
3672
+ def from_json(cls, json: T_JSON_DICT) -> DownloadWillBegin:
3673
+ return cls(
3674
+ frame_id=FrameId.from_json(json['frameId']),
3675
+ guid=str(json['guid']),
3676
+ url=str(json['url']),
3677
+ suggested_filename=str(json['suggestedFilename'])
3678
+ )
3679
+
3680
+
3681
+ @deprecated(version="1.3")
3682
+ @event_class('Page.downloadProgress')
3683
+ @dataclass
3684
+ class DownloadProgress:
3685
+ '''
3686
+ **EXPERIMENTAL**
3687
+
3688
+ Fired when download makes progress. Last call has ``done`` == true.
3689
+ Deprecated. Use Browser.downloadProgress instead.
3690
+ '''
3691
+ #: Global unique identifier of the download.
3692
+ guid: str
3693
+ #: Total expected bytes to download.
3694
+ total_bytes: float
3695
+ #: Total bytes received.
3696
+ received_bytes: float
3697
+ #: Download status.
3698
+ state: str
3699
+
3700
+ @classmethod
3701
+ def from_json(cls, json: T_JSON_DICT) -> DownloadProgress:
3702
+ return cls(
3703
+ guid=str(json['guid']),
3704
+ total_bytes=float(json['totalBytes']),
3705
+ received_bytes=float(json['receivedBytes']),
3706
+ state=str(json['state'])
3707
+ )
3708
+
3709
+
3710
+ @event_class('Page.interstitialHidden')
3711
+ @dataclass
3712
+ class InterstitialHidden:
3713
+ '''
3714
+ Fired when interstitial page was hidden
3715
+ '''
3716
+
3717
+
3718
+ @classmethod
3719
+ def from_json(cls, json: T_JSON_DICT) -> InterstitialHidden:
3720
+ return cls(
3721
+
3722
+ )
3723
+
3724
+
3725
+ @event_class('Page.interstitialShown')
3726
+ @dataclass
3727
+ class InterstitialShown:
3728
+ '''
3729
+ Fired when interstitial page was shown
3730
+ '''
3731
+
3732
+
3733
+ @classmethod
3734
+ def from_json(cls, json: T_JSON_DICT) -> InterstitialShown:
3735
+ return cls(
3736
+
3737
+ )
3738
+
3739
+
3740
+ @event_class('Page.javascriptDialogClosed')
3741
+ @dataclass
3742
+ class JavascriptDialogClosed:
3743
+ '''
3744
+ Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) has been
3745
+ closed.
3746
+ '''
3747
+ #: Frame id.
3748
+ frame_id: FrameId
3749
+ #: Whether dialog was confirmed.
3750
+ result: bool
3751
+ #: User input in case of prompt.
3752
+ user_input: str
3753
+
3754
+ @classmethod
3755
+ def from_json(cls, json: T_JSON_DICT) -> JavascriptDialogClosed:
3756
+ return cls(
3757
+ frame_id=FrameId.from_json(json['frameId']),
3758
+ result=bool(json['result']),
3759
+ user_input=str(json['userInput'])
3760
+ )
3761
+
3762
+
3763
+ @event_class('Page.javascriptDialogOpening')
3764
+ @dataclass
3765
+ class JavascriptDialogOpening:
3766
+ '''
3767
+ Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) is about to
3768
+ open.
3769
+ '''
3770
+ #: Frame url.
3771
+ url: str
3772
+ #: Frame id.
3773
+ frame_id: FrameId
3774
+ #: Message that will be displayed by the dialog.
3775
+ message: str
3776
+ #: Dialog type.
3777
+ type_: DialogType
3778
+ #: True iff browser is capable showing or acting on the given dialog. When browser has no
3779
+ #: dialog handler for given target, calling alert while Page domain is engaged will stall
3780
+ #: the page execution. Execution can be resumed via calling Page.handleJavaScriptDialog.
3781
+ has_browser_handler: bool
3782
+ #: Default dialog prompt.
3783
+ default_prompt: typing.Optional[str]
3784
+
3785
+ @classmethod
3786
+ def from_json(cls, json: T_JSON_DICT) -> JavascriptDialogOpening:
3787
+ return cls(
3788
+ url=str(json['url']),
3789
+ frame_id=FrameId.from_json(json['frameId']),
3790
+ message=str(json['message']),
3791
+ type_=DialogType.from_json(json['type']),
3792
+ has_browser_handler=bool(json['hasBrowserHandler']),
3793
+ default_prompt=str(json['defaultPrompt']) if json.get('defaultPrompt', None) is not None else None
3794
+ )
3795
+
3796
+
3797
+ @event_class('Page.lifecycleEvent')
3798
+ @dataclass
3799
+ class LifecycleEvent:
3800
+ '''
3801
+ Fired for lifecycle events (navigation, load, paint, etc) in the current
3802
+ target (including local frames).
3803
+ '''
3804
+ #: Id of the frame.
3805
+ frame_id: FrameId
3806
+ #: Loader identifier. Empty string if the request is fetched from worker.
3807
+ loader_id: network.LoaderId
3808
+ name: str
3809
+ timestamp: network.MonotonicTime
3810
+
3811
+ @classmethod
3812
+ def from_json(cls, json: T_JSON_DICT) -> LifecycleEvent:
3813
+ return cls(
3814
+ frame_id=FrameId.from_json(json['frameId']),
3815
+ loader_id=network.LoaderId.from_json(json['loaderId']),
3816
+ name=str(json['name']),
3817
+ timestamp=network.MonotonicTime.from_json(json['timestamp'])
3818
+ )
3819
+
3820
+
3821
+ @event_class('Page.backForwardCacheNotUsed')
3822
+ @dataclass
3823
+ class BackForwardCacheNotUsed:
3824
+ '''
3825
+ **EXPERIMENTAL**
3826
+
3827
+ Fired for failed bfcache history navigations if BackForwardCache feature is enabled. Do
3828
+ not assume any ordering with the Page.frameNavigated event. This event is fired only for
3829
+ main-frame history navigation where the document changes (non-same-document navigations),
3830
+ when bfcache navigation fails.
3831
+ '''
3832
+ #: The loader id for the associated navigation.
3833
+ loader_id: network.LoaderId
3834
+ #: The frame id of the associated frame.
3835
+ frame_id: FrameId
3836
+ #: Array of reasons why the page could not be cached. This must not be empty.
3837
+ not_restored_explanations: typing.List[BackForwardCacheNotRestoredExplanation]
3838
+ #: Tree structure of reasons why the page could not be cached for each frame.
3839
+ not_restored_explanations_tree: typing.Optional[BackForwardCacheNotRestoredExplanationTree]
3840
+
3841
+ @classmethod
3842
+ def from_json(cls, json: T_JSON_DICT) -> BackForwardCacheNotUsed:
3843
+ return cls(
3844
+ loader_id=network.LoaderId.from_json(json['loaderId']),
3845
+ frame_id=FrameId.from_json(json['frameId']),
3846
+ not_restored_explanations=[BackForwardCacheNotRestoredExplanation.from_json(i) for i in json['notRestoredExplanations']],
3847
+ not_restored_explanations_tree=BackForwardCacheNotRestoredExplanationTree.from_json(json['notRestoredExplanationsTree']) if json.get('notRestoredExplanationsTree', None) is not None else None
3848
+ )
3849
+
3850
+
3851
+ @event_class('Page.loadEventFired')
3852
+ @dataclass
3853
+ class LoadEventFired:
3854
+ timestamp: network.MonotonicTime
3855
+
3856
+ @classmethod
3857
+ def from_json(cls, json: T_JSON_DICT) -> LoadEventFired:
3858
+ return cls(
3859
+ timestamp=network.MonotonicTime.from_json(json['timestamp'])
3860
+ )
3861
+
3862
+
3863
+ @event_class('Page.navigatedWithinDocument')
3864
+ @dataclass
3865
+ class NavigatedWithinDocument:
3866
+ '''
3867
+ **EXPERIMENTAL**
3868
+
3869
+ Fired when same-document navigation happens, e.g. due to history API usage or anchor navigation.
3870
+ '''
3871
+ #: Id of the frame.
3872
+ frame_id: FrameId
3873
+ #: Frame's new url.
3874
+ url: str
3875
+ #: Navigation type
3876
+ navigation_type: str
3877
+
3878
+ @classmethod
3879
+ def from_json(cls, json: T_JSON_DICT) -> NavigatedWithinDocument:
3880
+ return cls(
3881
+ frame_id=FrameId.from_json(json['frameId']),
3882
+ url=str(json['url']),
3883
+ navigation_type=str(json['navigationType'])
3884
+ )
3885
+
3886
+
3887
+ @event_class('Page.screencastFrame')
3888
+ @dataclass
3889
+ class ScreencastFrame:
3890
+ '''
3891
+ **EXPERIMENTAL**
3892
+
3893
+ Compressed image data requested by the ``startScreencast``.
3894
+ '''
3895
+ #: Base64-encoded compressed image. (Encoded as a base64 string when passed over JSON)
3896
+ data: str
3897
+ #: Screencast frame metadata.
3898
+ metadata: ScreencastFrameMetadata
3899
+ #: Frame number.
3900
+ session_id: int
3901
+
3902
+ @classmethod
3903
+ def from_json(cls, json: T_JSON_DICT) -> ScreencastFrame:
3904
+ return cls(
3905
+ data=str(json['data']),
3906
+ metadata=ScreencastFrameMetadata.from_json(json['metadata']),
3907
+ session_id=int(json['sessionId'])
3908
+ )
3909
+
3910
+
3911
+ @event_class('Page.screencastVisibilityChanged')
3912
+ @dataclass
3913
+ class ScreencastVisibilityChanged:
3914
+ '''
3915
+ **EXPERIMENTAL**
3916
+
3917
+ Fired when the page with currently enabled screencast was shown or hidden .
3918
+ '''
3919
+ #: True if the page is visible.
3920
+ visible: bool
3921
+
3922
+ @classmethod
3923
+ def from_json(cls, json: T_JSON_DICT) -> ScreencastVisibilityChanged:
3924
+ return cls(
3925
+ visible=bool(json['visible'])
3926
+ )
3927
+
3928
+
3929
+ @event_class('Page.windowOpen')
3930
+ @dataclass
3931
+ class WindowOpen:
3932
+ '''
3933
+ Fired when a new window is going to be opened, via window.open(), link click, form submission,
3934
+ etc.
3935
+ '''
3936
+ #: The URL for the new window.
3937
+ url: str
3938
+ #: Window name.
3939
+ window_name: str
3940
+ #: An array of enabled window features.
3941
+ window_features: typing.List[str]
3942
+ #: Whether or not it was triggered by user gesture.
3943
+ user_gesture: bool
3944
+
3945
+ @classmethod
3946
+ def from_json(cls, json: T_JSON_DICT) -> WindowOpen:
3947
+ return cls(
3948
+ url=str(json['url']),
3949
+ window_name=str(json['windowName']),
3950
+ window_features=[str(i) for i in json['windowFeatures']],
3951
+ user_gesture=bool(json['userGesture'])
3952
+ )
3953
+
3954
+
3955
+ @event_class('Page.compilationCacheProduced')
3956
+ @dataclass
3957
+ class CompilationCacheProduced:
3958
+ '''
3959
+ **EXPERIMENTAL**
3960
+
3961
+ Issued for every compilation cache generated.
3962
+ '''
3963
+ url: str
3964
+ #: Base64-encoded data (Encoded as a base64 string when passed over JSON)
3965
+ data: str
3966
+
3967
+ @classmethod
3968
+ def from_json(cls, json: T_JSON_DICT) -> CompilationCacheProduced:
3969
+ return cls(
3970
+ url=str(json['url']),
3971
+ data=str(json['data'])
3972
+ )