mithwire 0.50.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. mithwire/__init__.py +32 -0
  2. mithwire/cdp/README.md +4 -0
  3. mithwire/cdp/__init__.py +6 -0
  4. mithwire/cdp/accessibility.py +668 -0
  5. mithwire/cdp/animation.py +494 -0
  6. mithwire/cdp/audits.py +1995 -0
  7. mithwire/cdp/autofill.py +292 -0
  8. mithwire/cdp/background_service.py +215 -0
  9. mithwire/cdp/bluetooth_emulation.py +626 -0
  10. mithwire/cdp/browser.py +821 -0
  11. mithwire/cdp/cache_storage.py +311 -0
  12. mithwire/cdp/cast.py +172 -0
  13. mithwire/cdp/console.py +107 -0
  14. mithwire/cdp/crash_report_context.py +55 -0
  15. mithwire/cdp/css.py +2750 -0
  16. mithwire/cdp/database.py +179 -0
  17. mithwire/cdp/debugger.py +1405 -0
  18. mithwire/cdp/device_access.py +141 -0
  19. mithwire/cdp/device_orientation.py +45 -0
  20. mithwire/cdp/dom.py +2257 -0
  21. mithwire/cdp/dom_debugger.py +321 -0
  22. mithwire/cdp/dom_snapshot.py +876 -0
  23. mithwire/cdp/dom_storage.py +222 -0
  24. mithwire/cdp/emulation.py +1779 -0
  25. mithwire/cdp/event_breakpoints.py +56 -0
  26. mithwire/cdp/extensions.py +238 -0
  27. mithwire/cdp/fed_cm.py +283 -0
  28. mithwire/cdp/fetch.py +507 -0
  29. mithwire/cdp/file_system.py +115 -0
  30. mithwire/cdp/headless_experimental.py +115 -0
  31. mithwire/cdp/heap_profiler.py +401 -0
  32. mithwire/cdp/indexed_db.py +528 -0
  33. mithwire/cdp/input_.py +701 -0
  34. mithwire/cdp/inspector.py +95 -0
  35. mithwire/cdp/io.py +101 -0
  36. mithwire/cdp/layer_tree.py +464 -0
  37. mithwire/cdp/log.py +190 -0
  38. mithwire/cdp/media.py +313 -0
  39. mithwire/cdp/memory.py +305 -0
  40. mithwire/cdp/network.py +5342 -0
  41. mithwire/cdp/overlay.py +1468 -0
  42. mithwire/cdp/page.py +3972 -0
  43. mithwire/cdp/performance.py +124 -0
  44. mithwire/cdp/performance_timeline.py +200 -0
  45. mithwire/cdp/preload.py +575 -0
  46. mithwire/cdp/profiler.py +420 -0
  47. mithwire/cdp/pwa.py +278 -0
  48. mithwire/cdp/py.typed +0 -0
  49. mithwire/cdp/runtime.py +1589 -0
  50. mithwire/cdp/schema.py +50 -0
  51. mithwire/cdp/security.py +518 -0
  52. mithwire/cdp/service_worker.py +401 -0
  53. mithwire/cdp/smart_card_emulation.py +891 -0
  54. mithwire/cdp/storage.py +1573 -0
  55. mithwire/cdp/system_info.py +327 -0
  56. mithwire/cdp/target.py +829 -0
  57. mithwire/cdp/tethering.py +65 -0
  58. mithwire/cdp/tracing.py +377 -0
  59. mithwire/cdp/util.py +18 -0
  60. mithwire/cdp/web_audio.py +606 -0
  61. mithwire/cdp/web_authn.py +598 -0
  62. mithwire/cdp/web_mcp.py +293 -0
  63. mithwire/core/_contradict.py +142 -0
  64. mithwire/core/browser.py +923 -0
  65. mithwire/core/cf_templates/cf_dark_checkbox.png +0 -0
  66. mithwire/core/cf_templates/cf_light_checkbox.png +0 -0
  67. mithwire/core/config.py +323 -0
  68. mithwire/core/connection.py +564 -0
  69. mithwire/core/element.py +1205 -0
  70. mithwire/core/tab.py +2202 -0
  71. mithwire/core/util.py +5063 -0
  72. mithwire-0.50.3.dist-info/METADATA +1049 -0
  73. mithwire-0.50.3.dist-info/RECORD +76 -0
  74. mithwire-0.50.3.dist-info/WHEEL +5 -0
  75. mithwire-0.50.3.dist-info/licenses/LICENSE.txt +619 -0
  76. mithwire-0.50.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,575 @@
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: Preload (experimental)
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 dom
15
+ from . import network
16
+ from . import page
17
+
18
+
19
+ class RuleSetId(str):
20
+ '''
21
+ Unique id
22
+ '''
23
+ def to_json(self) -> str:
24
+ return self
25
+
26
+ @classmethod
27
+ def from_json(cls, json: str) -> RuleSetId:
28
+ return cls(json)
29
+
30
+ def __repr__(self):
31
+ return 'RuleSetId({})'.format(super().__repr__())
32
+
33
+
34
+ @dataclass
35
+ class RuleSet:
36
+ '''
37
+ Corresponds to SpeculationRuleSet
38
+ '''
39
+ id_: RuleSetId
40
+
41
+ #: Identifies a document which the rule set is associated with.
42
+ loader_id: network.LoaderId
43
+
44
+ #: Source text of JSON representing the rule set. If it comes from
45
+ #: ``<script>`` tag, it is the textContent of the node. Note that it is
46
+ #: a JSON for valid case.
47
+ #:
48
+ #: See also:
49
+ #: - https://wicg.github.io/nav-speculation/speculation-rules.html
50
+ #: - https://github.com/WICG/nav-speculation/blob/main/triggers.md
51
+ source_text: str
52
+
53
+ #: A speculation rule set is either added through an inline
54
+ #: ``<script>`` tag or through an external resource via the
55
+ #: 'Speculation-Rules' HTTP header. For the first case, we include
56
+ #: the BackendNodeId of the relevant ``<script>`` tag. For the second
57
+ #: case, we include the external URL where the rule set was loaded
58
+ #: from, and also RequestId if Network domain is enabled.
59
+ #:
60
+ #: See also:
61
+ #: - https://wicg.github.io/nav-speculation/speculation-rules.html#speculation-rules-script
62
+ #: - https://wicg.github.io/nav-speculation/speculation-rules.html#speculation-rules-header
63
+ backend_node_id: typing.Optional[dom.BackendNodeId] = None
64
+
65
+ url: typing.Optional[str] = None
66
+
67
+ request_id: typing.Optional[network.RequestId] = None
68
+
69
+ #: Error information
70
+ #: ``errorMessage`` is null iff ``errorType`` is null.
71
+ error_type: typing.Optional[RuleSetErrorType] = None
72
+
73
+ #: TODO(https://crbug.com/1425354): Replace this property with structured error.
74
+ error_message: typing.Optional[str] = None
75
+
76
+ #: For more details, see:
77
+ #: https://github.com/WICG/nav-speculation/blob/main/speculation-rules-tags.md
78
+ tag: typing.Optional[str] = None
79
+
80
+ def to_json(self) -> T_JSON_DICT:
81
+ json: T_JSON_DICT = dict()
82
+ json['id'] = self.id_.to_json()
83
+ json['loaderId'] = self.loader_id.to_json()
84
+ json['sourceText'] = self.source_text
85
+ if self.backend_node_id is not None:
86
+ json['backendNodeId'] = self.backend_node_id.to_json()
87
+ if self.url is not None:
88
+ json['url'] = self.url
89
+ if self.request_id is not None:
90
+ json['requestId'] = self.request_id.to_json()
91
+ if self.error_type is not None:
92
+ json['errorType'] = self.error_type.to_json()
93
+ if self.error_message is not None:
94
+ json['errorMessage'] = self.error_message
95
+ if self.tag is not None:
96
+ json['tag'] = self.tag
97
+ return json
98
+
99
+ @classmethod
100
+ def from_json(cls, json: T_JSON_DICT) -> RuleSet:
101
+ return cls(
102
+ id_=RuleSetId.from_json(json['id']),
103
+ loader_id=network.LoaderId.from_json(json['loaderId']),
104
+ source_text=str(json['sourceText']),
105
+ backend_node_id=dom.BackendNodeId.from_json(json['backendNodeId']) if json.get('backendNodeId', None) is not None else None,
106
+ url=str(json['url']) if json.get('url', None) is not None else None,
107
+ request_id=network.RequestId.from_json(json['requestId']) if json.get('requestId', None) is not None else None,
108
+ error_type=RuleSetErrorType.from_json(json['errorType']) if json.get('errorType', None) is not None else None,
109
+ error_message=str(json['errorMessage']) if json.get('errorMessage', None) is not None else None,
110
+ tag=str(json['tag']) if json.get('tag', None) is not None else None,
111
+ )
112
+
113
+
114
+ class RuleSetErrorType(enum.Enum):
115
+ SOURCE_IS_NOT_JSON_OBJECT = "SourceIsNotJsonObject"
116
+ INVALID_RULES_SKIPPED = "InvalidRulesSkipped"
117
+ INVALID_RULESET_LEVEL_TAG = "InvalidRulesetLevelTag"
118
+
119
+ def to_json(self) -> str:
120
+ return self.value
121
+
122
+ @classmethod
123
+ def from_json(cls, json: str) -> RuleSetErrorType:
124
+ return cls(json)
125
+
126
+
127
+ class SpeculationAction(enum.Enum):
128
+ '''
129
+ The type of preloading attempted. It corresponds to
130
+ mojom::SpeculationAction (although PrefetchWithSubresources is omitted as it
131
+ isn't being used by clients).
132
+ '''
133
+ PREFETCH = "Prefetch"
134
+ PRERENDER = "Prerender"
135
+ PRERENDER_UNTIL_SCRIPT = "PrerenderUntilScript"
136
+
137
+ def to_json(self) -> str:
138
+ return self.value
139
+
140
+ @classmethod
141
+ def from_json(cls, json: str) -> SpeculationAction:
142
+ return cls(json)
143
+
144
+
145
+ class SpeculationTargetHint(enum.Enum):
146
+ '''
147
+ Corresponds to mojom::SpeculationTargetHint.
148
+ See https://github.com/WICG/nav-speculation/blob/main/triggers.md#window-name-targeting-hints
149
+ '''
150
+ BLANK = "Blank"
151
+ SELF = "Self"
152
+
153
+ def to_json(self) -> str:
154
+ return self.value
155
+
156
+ @classmethod
157
+ def from_json(cls, json: str) -> SpeculationTargetHint:
158
+ return cls(json)
159
+
160
+
161
+ @dataclass
162
+ class PreloadingAttemptKey:
163
+ '''
164
+ A key that identifies a preloading attempt.
165
+
166
+ The url used is the url specified by the trigger (i.e. the initial URL), and
167
+ not the final url that is navigated to. For example, prerendering allows
168
+ same-origin main frame navigations during the attempt, but the attempt is
169
+ still keyed with the initial URL.
170
+ '''
171
+ loader_id: network.LoaderId
172
+
173
+ action: SpeculationAction
174
+
175
+ url: str
176
+
177
+ form_submission: typing.Optional[bool] = None
178
+
179
+ target_hint: typing.Optional[SpeculationTargetHint] = None
180
+
181
+ def to_json(self) -> T_JSON_DICT:
182
+ json: T_JSON_DICT = dict()
183
+ json['loaderId'] = self.loader_id.to_json()
184
+ json['action'] = self.action.to_json()
185
+ json['url'] = self.url
186
+ if self.form_submission is not None:
187
+ json['formSubmission'] = self.form_submission
188
+ if self.target_hint is not None:
189
+ json['targetHint'] = self.target_hint.to_json()
190
+ return json
191
+
192
+ @classmethod
193
+ def from_json(cls, json: T_JSON_DICT) -> PreloadingAttemptKey:
194
+ return cls(
195
+ loader_id=network.LoaderId.from_json(json['loaderId']),
196
+ action=SpeculationAction.from_json(json['action']),
197
+ url=str(json['url']),
198
+ form_submission=bool(json['formSubmission']) if json.get('formSubmission', None) is not None else None,
199
+ target_hint=SpeculationTargetHint.from_json(json['targetHint']) if json.get('targetHint', None) is not None else None,
200
+ )
201
+
202
+
203
+ @dataclass
204
+ class PreloadingAttemptSource:
205
+ '''
206
+ Lists sources for a preloading attempt, specifically the ids of rule sets
207
+ that had a speculation rule that triggered the attempt, and the
208
+ BackendNodeIds of <a href> or <area href> elements that triggered the
209
+ attempt (in the case of attempts triggered by a document rule). It is
210
+ possible for multiple rule sets and links to trigger a single attempt.
211
+ '''
212
+ key: PreloadingAttemptKey
213
+
214
+ rule_set_ids: typing.List[RuleSetId]
215
+
216
+ node_ids: typing.List[dom.BackendNodeId]
217
+
218
+ def to_json(self) -> T_JSON_DICT:
219
+ json: T_JSON_DICT = dict()
220
+ json['key'] = self.key.to_json()
221
+ json['ruleSetIds'] = [i.to_json() for i in self.rule_set_ids]
222
+ json['nodeIds'] = [i.to_json() for i in self.node_ids]
223
+ return json
224
+
225
+ @classmethod
226
+ def from_json(cls, json: T_JSON_DICT) -> PreloadingAttemptSource:
227
+ return cls(
228
+ key=PreloadingAttemptKey.from_json(json['key']),
229
+ rule_set_ids=[RuleSetId.from_json(i) for i in json['ruleSetIds']],
230
+ node_ids=[dom.BackendNodeId.from_json(i) for i in json['nodeIds']],
231
+ )
232
+
233
+
234
+ class PreloadPipelineId(str):
235
+ '''
236
+ Chrome manages different types of preloads together using a
237
+ concept of preloading pipeline. For example, if a site uses a
238
+ SpeculationRules for prerender, Chrome first starts a prefetch and
239
+ then upgrades it to prerender.
240
+
241
+ CDP events for them are emitted separately but they share
242
+ ``PreloadPipelineId``.
243
+ '''
244
+ def to_json(self) -> str:
245
+ return self
246
+
247
+ @classmethod
248
+ def from_json(cls, json: str) -> PreloadPipelineId:
249
+ return cls(json)
250
+
251
+ def __repr__(self):
252
+ return 'PreloadPipelineId({})'.format(super().__repr__())
253
+
254
+
255
+ class PrerenderFinalStatus(enum.Enum):
256
+ '''
257
+ List of FinalStatus reasons for Prerender2.
258
+ '''
259
+ ACTIVATED = "Activated"
260
+ DESTROYED = "Destroyed"
261
+ LOW_END_DEVICE = "LowEndDevice"
262
+ INVALID_SCHEME_REDIRECT = "InvalidSchemeRedirect"
263
+ INVALID_SCHEME_NAVIGATION = "InvalidSchemeNavigation"
264
+ NAVIGATION_REQUEST_BLOCKED_BY_CSP = "NavigationRequestBlockedByCsp"
265
+ MOJO_BINDER_POLICY = "MojoBinderPolicy"
266
+ RENDERER_PROCESS_CRASHED = "RendererProcessCrashed"
267
+ RENDERER_PROCESS_KILLED = "RendererProcessKilled"
268
+ DOWNLOAD = "Download"
269
+ TRIGGER_DESTROYED = "TriggerDestroyed"
270
+ NAVIGATION_NOT_COMMITTED = "NavigationNotCommitted"
271
+ NAVIGATION_BAD_HTTP_STATUS = "NavigationBadHttpStatus"
272
+ CLIENT_CERT_REQUESTED = "ClientCertRequested"
273
+ NAVIGATION_REQUEST_NETWORK_ERROR = "NavigationRequestNetworkError"
274
+ CANCEL_ALL_HOSTS_FOR_TESTING = "CancelAllHostsForTesting"
275
+ DID_FAIL_LOAD = "DidFailLoad"
276
+ STOP = "Stop"
277
+ SSL_CERTIFICATE_ERROR = "SslCertificateError"
278
+ LOGIN_AUTH_REQUESTED = "LoginAuthRequested"
279
+ UA_CHANGE_REQUIRES_RELOAD = "UaChangeRequiresReload"
280
+ BLOCKED_BY_CLIENT = "BlockedByClient"
281
+ AUDIO_OUTPUT_DEVICE_REQUESTED = "AudioOutputDeviceRequested"
282
+ MIXED_CONTENT = "MixedContent"
283
+ TRIGGER_BACKGROUNDED = "TriggerBackgrounded"
284
+ MEMORY_LIMIT_EXCEEDED = "MemoryLimitExceeded"
285
+ DATA_SAVER_ENABLED = "DataSaverEnabled"
286
+ TRIGGER_URL_HAS_EFFECTIVE_URL = "TriggerUrlHasEffectiveUrl"
287
+ ACTIVATED_BEFORE_STARTED = "ActivatedBeforeStarted"
288
+ INACTIVE_PAGE_RESTRICTION = "InactivePageRestriction"
289
+ START_FAILED = "StartFailed"
290
+ TIMEOUT_BACKGROUNDED = "TimeoutBackgrounded"
291
+ CROSS_SITE_REDIRECT_IN_INITIAL_NAVIGATION = "CrossSiteRedirectInInitialNavigation"
292
+ CROSS_SITE_NAVIGATION_IN_INITIAL_NAVIGATION = "CrossSiteNavigationInInitialNavigation"
293
+ SAME_SITE_CROSS_ORIGIN_REDIRECT_NOT_OPT_IN_IN_INITIAL_NAVIGATION = "SameSiteCrossOriginRedirectNotOptInInInitialNavigation"
294
+ SAME_SITE_CROSS_ORIGIN_NAVIGATION_NOT_OPT_IN_IN_INITIAL_NAVIGATION = "SameSiteCrossOriginNavigationNotOptInInInitialNavigation"
295
+ ACTIVATION_NAVIGATION_PARAMETER_MISMATCH = "ActivationNavigationParameterMismatch"
296
+ ACTIVATED_IN_BACKGROUND = "ActivatedInBackground"
297
+ EMBEDDER_HOST_DISALLOWED = "EmbedderHostDisallowed"
298
+ ACTIVATION_NAVIGATION_DESTROYED_BEFORE_SUCCESS = "ActivationNavigationDestroyedBeforeSuccess"
299
+ TAB_CLOSED_BY_USER_GESTURE = "TabClosedByUserGesture"
300
+ TAB_CLOSED_WITHOUT_USER_GESTURE = "TabClosedWithoutUserGesture"
301
+ PRIMARY_MAIN_FRAME_RENDERER_PROCESS_CRASHED = "PrimaryMainFrameRendererProcessCrashed"
302
+ PRIMARY_MAIN_FRAME_RENDERER_PROCESS_KILLED = "PrimaryMainFrameRendererProcessKilled"
303
+ ACTIVATION_FRAME_POLICY_NOT_COMPATIBLE = "ActivationFramePolicyNotCompatible"
304
+ PRELOADING_DISABLED = "PreloadingDisabled"
305
+ BATTERY_SAVER_ENABLED = "BatterySaverEnabled"
306
+ ACTIVATED_DURING_MAIN_FRAME_NAVIGATION = "ActivatedDuringMainFrameNavigation"
307
+ PRELOADING_UNSUPPORTED_BY_WEB_CONTENTS = "PreloadingUnsupportedByWebContents"
308
+ CROSS_SITE_REDIRECT_IN_MAIN_FRAME_NAVIGATION = "CrossSiteRedirectInMainFrameNavigation"
309
+ CROSS_SITE_NAVIGATION_IN_MAIN_FRAME_NAVIGATION = "CrossSiteNavigationInMainFrameNavigation"
310
+ SAME_SITE_CROSS_ORIGIN_REDIRECT_NOT_OPT_IN_IN_MAIN_FRAME_NAVIGATION = "SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation"
311
+ SAME_SITE_CROSS_ORIGIN_NAVIGATION_NOT_OPT_IN_IN_MAIN_FRAME_NAVIGATION = "SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation"
312
+ MEMORY_PRESSURE_ON_TRIGGER = "MemoryPressureOnTrigger"
313
+ MEMORY_PRESSURE_AFTER_TRIGGERED = "MemoryPressureAfterTriggered"
314
+ PRERENDERING_DISABLED_BY_DEV_TOOLS = "PrerenderingDisabledByDevTools"
315
+ SPECULATION_RULE_REMOVED = "SpeculationRuleRemoved"
316
+ ACTIVATED_WITH_AUXILIARY_BROWSING_CONTEXTS = "ActivatedWithAuxiliaryBrowsingContexts"
317
+ MAX_NUM_OF_RUNNING_EAGER_PRERENDERS_EXCEEDED = "MaxNumOfRunningEagerPrerendersExceeded"
318
+ MAX_NUM_OF_RUNNING_NON_EAGER_PRERENDERS_EXCEEDED = "MaxNumOfRunningNonEagerPrerendersExceeded"
319
+ MAX_NUM_OF_RUNNING_EMBEDDER_PRERENDERS_EXCEEDED = "MaxNumOfRunningEmbedderPrerendersExceeded"
320
+ PRERENDERING_URL_HAS_EFFECTIVE_URL = "PrerenderingUrlHasEffectiveUrl"
321
+ REDIRECTED_PRERENDERING_URL_HAS_EFFECTIVE_URL = "RedirectedPrerenderingUrlHasEffectiveUrl"
322
+ ACTIVATION_URL_HAS_EFFECTIVE_URL = "ActivationUrlHasEffectiveUrl"
323
+ JAVA_SCRIPT_INTERFACE_ADDED = "JavaScriptInterfaceAdded"
324
+ JAVA_SCRIPT_INTERFACE_REMOVED = "JavaScriptInterfaceRemoved"
325
+ ALL_PRERENDERING_CANCELED = "AllPrerenderingCanceled"
326
+ WINDOW_CLOSED = "WindowClosed"
327
+ SLOW_NETWORK = "SlowNetwork"
328
+ OTHER_PRERENDERED_PAGE_ACTIVATED = "OtherPrerenderedPageActivated"
329
+ V8_OPTIMIZER_DISABLED = "V8OptimizerDisabled"
330
+ PRERENDER_FAILED_DURING_PREFETCH = "PrerenderFailedDuringPrefetch"
331
+ BROWSING_DATA_REMOVED = "BrowsingDataRemoved"
332
+ PRERENDER_HOST_REUSED = "PrerenderHostReused"
333
+ FORM_SUBMIT_WHEN_PRERENDERING = "FormSubmitWhenPrerendering"
334
+
335
+ def to_json(self) -> str:
336
+ return self.value
337
+
338
+ @classmethod
339
+ def from_json(cls, json: str) -> PrerenderFinalStatus:
340
+ return cls(json)
341
+
342
+
343
+ class PreloadingStatus(enum.Enum):
344
+ '''
345
+ Preloading status values, see also PreloadingTriggeringOutcome. This
346
+ status is shared by prefetchStatusUpdated and prerenderStatusUpdated.
347
+ '''
348
+ PENDING = "Pending"
349
+ RUNNING = "Running"
350
+ READY = "Ready"
351
+ SUCCESS = "Success"
352
+ FAILURE = "Failure"
353
+ NOT_SUPPORTED = "NotSupported"
354
+
355
+ def to_json(self) -> str:
356
+ return self.value
357
+
358
+ @classmethod
359
+ def from_json(cls, json: str) -> PreloadingStatus:
360
+ return cls(json)
361
+
362
+
363
+ class PrefetchStatus(enum.Enum):
364
+ '''
365
+ TODO(https://crbug.com/1384419): revisit the list of PrefetchStatus and
366
+ filter out the ones that aren't necessary to the developers.
367
+ '''
368
+ PREFETCH_ALLOWED = "PrefetchAllowed"
369
+ PREFETCH_FAILED_INELIGIBLE_REDIRECT = "PrefetchFailedIneligibleRedirect"
370
+ PREFETCH_FAILED_INVALID_REDIRECT = "PrefetchFailedInvalidRedirect"
371
+ PREFETCH_FAILED_MIME_NOT_SUPPORTED = "PrefetchFailedMIMENotSupported"
372
+ PREFETCH_FAILED_NET_ERROR = "PrefetchFailedNetError"
373
+ PREFETCH_FAILED_NON2_XX = "PrefetchFailedNon2XX"
374
+ PREFETCH_EVICTED_AFTER_BROWSING_DATA_REMOVED = "PrefetchEvictedAfterBrowsingDataRemoved"
375
+ PREFETCH_EVICTED_AFTER_CANDIDATE_REMOVED = "PrefetchEvictedAfterCandidateRemoved"
376
+ PREFETCH_EVICTED_FOR_NEWER_PREFETCH = "PrefetchEvictedForNewerPrefetch"
377
+ PREFETCH_HELDBACK = "PrefetchHeldback"
378
+ PREFETCH_INELIGIBLE_RETRY_AFTER = "PrefetchIneligibleRetryAfter"
379
+ PREFETCH_IS_PRIVACY_DECOY = "PrefetchIsPrivacyDecoy"
380
+ PREFETCH_IS_STALE = "PrefetchIsStale"
381
+ PREFETCH_NOT_ELIGIBLE_BROWSER_CONTEXT_OFF_THE_RECORD = "PrefetchNotEligibleBrowserContextOffTheRecord"
382
+ PREFETCH_NOT_ELIGIBLE_DATA_SAVER_ENABLED = "PrefetchNotEligibleDataSaverEnabled"
383
+ PREFETCH_NOT_ELIGIBLE_EXISTING_PROXY = "PrefetchNotEligibleExistingProxy"
384
+ PREFETCH_NOT_ELIGIBLE_HOST_IS_NON_UNIQUE = "PrefetchNotEligibleHostIsNonUnique"
385
+ PREFETCH_NOT_ELIGIBLE_NON_DEFAULT_STORAGE_PARTITION = "PrefetchNotEligibleNonDefaultStoragePartition"
386
+ PREFETCH_NOT_ELIGIBLE_SAME_SITE_CROSS_ORIGIN_PREFETCH_REQUIRED_PROXY = "PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy"
387
+ PREFETCH_NOT_ELIGIBLE_SCHEME_IS_NOT_HTTPS = "PrefetchNotEligibleSchemeIsNotHttps"
388
+ PREFETCH_NOT_ELIGIBLE_USER_HAS_COOKIES = "PrefetchNotEligibleUserHasCookies"
389
+ PREFETCH_NOT_ELIGIBLE_USER_HAS_SERVICE_WORKER = "PrefetchNotEligibleUserHasServiceWorker"
390
+ PREFETCH_NOT_ELIGIBLE_USER_HAS_SERVICE_WORKER_NO_FETCH_HANDLER = "PrefetchNotEligibleUserHasServiceWorkerNoFetchHandler"
391
+ PREFETCH_NOT_ELIGIBLE_REDIRECT_FROM_SERVICE_WORKER = "PrefetchNotEligibleRedirectFromServiceWorker"
392
+ PREFETCH_NOT_ELIGIBLE_REDIRECT_TO_SERVICE_WORKER = "PrefetchNotEligibleRedirectToServiceWorker"
393
+ PREFETCH_NOT_ELIGIBLE_BATTERY_SAVER_ENABLED = "PrefetchNotEligibleBatterySaverEnabled"
394
+ PREFETCH_NOT_ELIGIBLE_PRELOADING_DISABLED = "PrefetchNotEligiblePreloadingDisabled"
395
+ PREFETCH_NOT_FINISHED_IN_TIME = "PrefetchNotFinishedInTime"
396
+ PREFETCH_NOT_STARTED = "PrefetchNotStarted"
397
+ PREFETCH_NOT_USED_COOKIES_CHANGED = "PrefetchNotUsedCookiesChanged"
398
+ PREFETCH_PROXY_NOT_AVAILABLE = "PrefetchProxyNotAvailable"
399
+ PREFETCH_RESPONSE_USED = "PrefetchResponseUsed"
400
+ PREFETCH_SUCCESSFUL_BUT_NOT_USED = "PrefetchSuccessfulButNotUsed"
401
+ PREFETCH_NOT_USED_PROBE_FAILED = "PrefetchNotUsedProbeFailed"
402
+
403
+ def to_json(self) -> str:
404
+ return self.value
405
+
406
+ @classmethod
407
+ def from_json(cls, json: str) -> PrefetchStatus:
408
+ return cls(json)
409
+
410
+
411
+ @dataclass
412
+ class PrerenderMismatchedHeaders:
413
+ '''
414
+ Information of headers to be displayed when the header mismatch occurred.
415
+ '''
416
+ header_name: str
417
+
418
+ initial_value: typing.Optional[str] = None
419
+
420
+ activation_value: typing.Optional[str] = None
421
+
422
+ def to_json(self) -> T_JSON_DICT:
423
+ json: T_JSON_DICT = dict()
424
+ json['headerName'] = self.header_name
425
+ if self.initial_value is not None:
426
+ json['initialValue'] = self.initial_value
427
+ if self.activation_value is not None:
428
+ json['activationValue'] = self.activation_value
429
+ return json
430
+
431
+ @classmethod
432
+ def from_json(cls, json: T_JSON_DICT) -> PrerenderMismatchedHeaders:
433
+ return cls(
434
+ header_name=str(json['headerName']),
435
+ initial_value=str(json['initialValue']) if json.get('initialValue', None) is not None else None,
436
+ activation_value=str(json['activationValue']) if json.get('activationValue', None) is not None else None,
437
+ )
438
+
439
+
440
+ def enable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
441
+
442
+ cmd_dict: T_JSON_DICT = {
443
+ 'method': 'Preload.enable',
444
+ }
445
+ json = yield cmd_dict
446
+
447
+
448
+ def disable() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
449
+
450
+ cmd_dict: T_JSON_DICT = {
451
+ 'method': 'Preload.disable',
452
+ }
453
+ json = yield cmd_dict
454
+
455
+
456
+ @event_class('Preload.ruleSetUpdated')
457
+ @dataclass
458
+ class RuleSetUpdated:
459
+ '''
460
+ Upsert. Currently, it is only emitted when a rule set added.
461
+ '''
462
+ rule_set: RuleSet
463
+
464
+ @classmethod
465
+ def from_json(cls, json: T_JSON_DICT) -> RuleSetUpdated:
466
+ return cls(
467
+ rule_set=RuleSet.from_json(json['ruleSet'])
468
+ )
469
+
470
+
471
+ @event_class('Preload.ruleSetRemoved')
472
+ @dataclass
473
+ class RuleSetRemoved:
474
+ id_: RuleSetId
475
+
476
+ @classmethod
477
+ def from_json(cls, json: T_JSON_DICT) -> RuleSetRemoved:
478
+ return cls(
479
+ id_=RuleSetId.from_json(json['id'])
480
+ )
481
+
482
+
483
+ @event_class('Preload.preloadEnabledStateUpdated')
484
+ @dataclass
485
+ class PreloadEnabledStateUpdated:
486
+ '''
487
+ Fired when a preload enabled state is updated.
488
+ '''
489
+ disabled_by_preference: bool
490
+ disabled_by_data_saver: bool
491
+ disabled_by_battery_saver: bool
492
+ disabled_by_holdback_prefetch_speculation_rules: bool
493
+ disabled_by_holdback_prerender_speculation_rules: bool
494
+
495
+ @classmethod
496
+ def from_json(cls, json: T_JSON_DICT) -> PreloadEnabledStateUpdated:
497
+ return cls(
498
+ disabled_by_preference=bool(json['disabledByPreference']),
499
+ disabled_by_data_saver=bool(json['disabledByDataSaver']),
500
+ disabled_by_battery_saver=bool(json['disabledByBatterySaver']),
501
+ disabled_by_holdback_prefetch_speculation_rules=bool(json['disabledByHoldbackPrefetchSpeculationRules']),
502
+ disabled_by_holdback_prerender_speculation_rules=bool(json['disabledByHoldbackPrerenderSpeculationRules'])
503
+ )
504
+
505
+
506
+ @event_class('Preload.prefetchStatusUpdated')
507
+ @dataclass
508
+ class PrefetchStatusUpdated:
509
+ '''
510
+ Fired when a prefetch attempt is updated.
511
+ '''
512
+ key: PreloadingAttemptKey
513
+ pipeline_id: PreloadPipelineId
514
+ #: The frame id of the frame initiating prefetch.
515
+ initiating_frame_id: page.FrameId
516
+ prefetch_url: str
517
+ status: PreloadingStatus
518
+ prefetch_status: PrefetchStatus
519
+ request_id: network.RequestId
520
+
521
+ @classmethod
522
+ def from_json(cls, json: T_JSON_DICT) -> PrefetchStatusUpdated:
523
+ return cls(
524
+ key=PreloadingAttemptKey.from_json(json['key']),
525
+ pipeline_id=PreloadPipelineId.from_json(json['pipelineId']),
526
+ initiating_frame_id=page.FrameId.from_json(json['initiatingFrameId']),
527
+ prefetch_url=str(json['prefetchUrl']),
528
+ status=PreloadingStatus.from_json(json['status']),
529
+ prefetch_status=PrefetchStatus.from_json(json['prefetchStatus']),
530
+ request_id=network.RequestId.from_json(json['requestId'])
531
+ )
532
+
533
+
534
+ @event_class('Preload.prerenderStatusUpdated')
535
+ @dataclass
536
+ class PrerenderStatusUpdated:
537
+ '''
538
+ Fired when a prerender attempt is updated.
539
+ '''
540
+ key: PreloadingAttemptKey
541
+ pipeline_id: PreloadPipelineId
542
+ status: PreloadingStatus
543
+ prerender_status: typing.Optional[PrerenderFinalStatus]
544
+ #: This is used to give users more information about the name of Mojo interface
545
+ #: that is incompatible with prerender and has caused the cancellation of the attempt.
546
+ disallowed_mojo_interface: typing.Optional[str]
547
+ mismatched_headers: typing.Optional[typing.List[PrerenderMismatchedHeaders]]
548
+
549
+ @classmethod
550
+ def from_json(cls, json: T_JSON_DICT) -> PrerenderStatusUpdated:
551
+ return cls(
552
+ key=PreloadingAttemptKey.from_json(json['key']),
553
+ pipeline_id=PreloadPipelineId.from_json(json['pipelineId']),
554
+ status=PreloadingStatus.from_json(json['status']),
555
+ prerender_status=PrerenderFinalStatus.from_json(json['prerenderStatus']) if json.get('prerenderStatus', None) is not None else None,
556
+ disallowed_mojo_interface=str(json['disallowedMojoInterface']) if json.get('disallowedMojoInterface', None) is not None else None,
557
+ mismatched_headers=[PrerenderMismatchedHeaders.from_json(i) for i in json['mismatchedHeaders']] if json.get('mismatchedHeaders', None) is not None else None
558
+ )
559
+
560
+
561
+ @event_class('Preload.preloadingAttemptSourcesUpdated')
562
+ @dataclass
563
+ class PreloadingAttemptSourcesUpdated:
564
+ '''
565
+ Send a list of sources for all preloading attempts in a document.
566
+ '''
567
+ loader_id: network.LoaderId
568
+ preloading_attempt_sources: typing.List[PreloadingAttemptSource]
569
+
570
+ @classmethod
571
+ def from_json(cls, json: T_JSON_DICT) -> PreloadingAttemptSourcesUpdated:
572
+ return cls(
573
+ loader_id=network.LoaderId.from_json(json['loaderId']),
574
+ preloading_attempt_sources=[PreloadingAttemptSource.from_json(i) for i in json['preloadingAttemptSources']]
575
+ )