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,65 @@
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: Tethering (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
+
15
+ def bind(
16
+ port: int
17
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
18
+ '''
19
+ Request browser port binding.
20
+
21
+ :param port: Port number to bind.
22
+ '''
23
+ params: T_JSON_DICT = dict()
24
+ params['port'] = port
25
+ cmd_dict: T_JSON_DICT = {
26
+ 'method': 'Tethering.bind',
27
+ 'params': params,
28
+ }
29
+ json = yield cmd_dict
30
+
31
+
32
+ def unbind(
33
+ port: int
34
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
35
+ '''
36
+ Request browser port unbinding.
37
+
38
+ :param port: Port number to unbind.
39
+ '''
40
+ params: T_JSON_DICT = dict()
41
+ params['port'] = port
42
+ cmd_dict: T_JSON_DICT = {
43
+ 'method': 'Tethering.unbind',
44
+ 'params': params,
45
+ }
46
+ json = yield cmd_dict
47
+
48
+
49
+ @event_class('Tethering.accepted')
50
+ @dataclass
51
+ class Accepted:
52
+ '''
53
+ Informs that port was successfully bound and got a specified connection id.
54
+ '''
55
+ #: Port number that was successfully bound.
56
+ port: int
57
+ #: Connection id to be used.
58
+ connection_id: str
59
+
60
+ @classmethod
61
+ def from_json(cls, json: T_JSON_DICT) -> Accepted:
62
+ return cls(
63
+ port=int(json['port']),
64
+ connection_id=str(json['connectionId'])
65
+ )
@@ -0,0 +1,377 @@
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: Tracing
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 io
15
+
16
+
17
+ class MemoryDumpConfig(dict):
18
+ '''
19
+ Configuration for memory dump. Used only when "memory-infra" category is enabled.
20
+ '''
21
+ def to_json(self) -> dict:
22
+ return self
23
+
24
+ @classmethod
25
+ def from_json(cls, json: dict) -> MemoryDumpConfig:
26
+ return cls(json)
27
+
28
+ def __repr__(self):
29
+ return 'MemoryDumpConfig({})'.format(super().__repr__())
30
+
31
+
32
+ @dataclass
33
+ class TraceConfig:
34
+ #: Controls how the trace buffer stores data. The default is ``recordUntilFull``.
35
+ record_mode: typing.Optional[str] = None
36
+
37
+ #: Size of the trace buffer in kilobytes. If not specified or zero is passed, a default value
38
+ #: of 200 MB would be used.
39
+ trace_buffer_size_in_kb: typing.Optional[float] = None
40
+
41
+ #: Turns on JavaScript stack sampling.
42
+ enable_sampling: typing.Optional[bool] = None
43
+
44
+ #: Turns on system tracing.
45
+ enable_systrace: typing.Optional[bool] = None
46
+
47
+ #: Turns on argument filter.
48
+ enable_argument_filter: typing.Optional[bool] = None
49
+
50
+ #: Included category filters.
51
+ included_categories: typing.Optional[typing.List[str]] = None
52
+
53
+ #: Excluded category filters.
54
+ excluded_categories: typing.Optional[typing.List[str]] = None
55
+
56
+ #: Configuration to synthesize the delays in tracing.
57
+ synthetic_delays: typing.Optional[typing.List[str]] = None
58
+
59
+ #: Configuration for memory dump triggers. Used only when "memory-infra" category is enabled.
60
+ memory_dump_config: typing.Optional[MemoryDumpConfig] = None
61
+
62
+ def to_json(self) -> T_JSON_DICT:
63
+ json: T_JSON_DICT = dict()
64
+ if self.record_mode is not None:
65
+ json['recordMode'] = self.record_mode
66
+ if self.trace_buffer_size_in_kb is not None:
67
+ json['traceBufferSizeInKb'] = self.trace_buffer_size_in_kb
68
+ if self.enable_sampling is not None:
69
+ json['enableSampling'] = self.enable_sampling
70
+ if self.enable_systrace is not None:
71
+ json['enableSystrace'] = self.enable_systrace
72
+ if self.enable_argument_filter is not None:
73
+ json['enableArgumentFilter'] = self.enable_argument_filter
74
+ if self.included_categories is not None:
75
+ json['includedCategories'] = [i for i in self.included_categories]
76
+ if self.excluded_categories is not None:
77
+ json['excludedCategories'] = [i for i in self.excluded_categories]
78
+ if self.synthetic_delays is not None:
79
+ json['syntheticDelays'] = [i for i in self.synthetic_delays]
80
+ if self.memory_dump_config is not None:
81
+ json['memoryDumpConfig'] = self.memory_dump_config.to_json()
82
+ return json
83
+
84
+ @classmethod
85
+ def from_json(cls, json: T_JSON_DICT) -> TraceConfig:
86
+ return cls(
87
+ record_mode=str(json['recordMode']) if json.get('recordMode', None) is not None else None,
88
+ trace_buffer_size_in_kb=float(json['traceBufferSizeInKb']) if json.get('traceBufferSizeInKb', None) is not None else None,
89
+ enable_sampling=bool(json['enableSampling']) if json.get('enableSampling', None) is not None else None,
90
+ enable_systrace=bool(json['enableSystrace']) if json.get('enableSystrace', None) is not None else None,
91
+ enable_argument_filter=bool(json['enableArgumentFilter']) if json.get('enableArgumentFilter', None) is not None else None,
92
+ included_categories=[str(i) for i in json['includedCategories']] if json.get('includedCategories', None) is not None else None,
93
+ excluded_categories=[str(i) for i in json['excludedCategories']] if json.get('excludedCategories', None) is not None else None,
94
+ synthetic_delays=[str(i) for i in json['syntheticDelays']] if json.get('syntheticDelays', None) is not None else None,
95
+ memory_dump_config=MemoryDumpConfig.from_json(json['memoryDumpConfig']) if json.get('memoryDumpConfig', None) is not None else None,
96
+ )
97
+
98
+
99
+ class StreamFormat(enum.Enum):
100
+ '''
101
+ Data format of a trace. Can be either the legacy JSON format or the
102
+ protocol buffer format. Note that the JSON format will be deprecated soon.
103
+ '''
104
+ JSON = "json"
105
+ PROTO = "proto"
106
+
107
+ def to_json(self) -> str:
108
+ return self.value
109
+
110
+ @classmethod
111
+ def from_json(cls, json: str) -> StreamFormat:
112
+ return cls(json)
113
+
114
+
115
+ class StreamCompression(enum.Enum):
116
+ '''
117
+ Compression type to use for traces returned via streams.
118
+ '''
119
+ NONE = "none"
120
+ GZIP = "gzip"
121
+
122
+ def to_json(self) -> str:
123
+ return self.value
124
+
125
+ @classmethod
126
+ def from_json(cls, json: str) -> StreamCompression:
127
+ return cls(json)
128
+
129
+
130
+ class MemoryDumpLevelOfDetail(enum.Enum):
131
+ '''
132
+ Details exposed when memory request explicitly declared.
133
+ Keep consistent with memory_dump_request_args.h and
134
+ memory_instrumentation.mojom
135
+ '''
136
+ BACKGROUND = "background"
137
+ LIGHT = "light"
138
+ DETAILED = "detailed"
139
+
140
+ def to_json(self) -> str:
141
+ return self.value
142
+
143
+ @classmethod
144
+ def from_json(cls, json: str) -> MemoryDumpLevelOfDetail:
145
+ return cls(json)
146
+
147
+
148
+ class TracingBackend(enum.Enum):
149
+ '''
150
+ Backend type to use for tracing. ``chrome`` uses the Chrome-integrated
151
+ tracing service and is supported on all platforms. ``system`` is only
152
+ supported on Chrome OS and uses the Perfetto system tracing service.
153
+ ``auto`` chooses ``system`` when the perfettoConfig provided to Tracing.start
154
+ specifies at least one non-Chrome data source; otherwise uses ``chrome``.
155
+ '''
156
+ AUTO = "auto"
157
+ CHROME = "chrome"
158
+ SYSTEM = "system"
159
+
160
+ def to_json(self) -> str:
161
+ return self.value
162
+
163
+ @classmethod
164
+ def from_json(cls, json: str) -> TracingBackend:
165
+ return cls(json)
166
+
167
+
168
+ def end() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
169
+ '''
170
+ Stop trace events collection.
171
+ '''
172
+ cmd_dict: T_JSON_DICT = {
173
+ 'method': 'Tracing.end',
174
+ }
175
+ json = yield cmd_dict
176
+
177
+
178
+ def get_categories() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[str]]:
179
+ '''
180
+ Gets supported tracing categories.
181
+
182
+ **EXPERIMENTAL**
183
+
184
+ :returns: A list of supported tracing categories.
185
+ '''
186
+ cmd_dict: T_JSON_DICT = {
187
+ 'method': 'Tracing.getCategories',
188
+ }
189
+ json = yield cmd_dict
190
+ return [str(i) for i in json['categories']]
191
+
192
+
193
+ def get_track_event_descriptor() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,str]:
194
+ '''
195
+ Return a descriptor for all available tracing categories.
196
+
197
+ **EXPERIMENTAL**
198
+
199
+ :returns: Base64-encoded serialized perfetto.protos.TrackEventDescriptor protobuf message. (Encoded as a base64 string when passed over JSON)
200
+ '''
201
+ cmd_dict: T_JSON_DICT = {
202
+ 'method': 'Tracing.getTrackEventDescriptor',
203
+ }
204
+ json = yield cmd_dict
205
+ return str(json['descriptor'])
206
+
207
+
208
+ def record_clock_sync_marker(
209
+ sync_id: str
210
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
211
+ '''
212
+ Record a clock sync marker in the trace.
213
+
214
+ **EXPERIMENTAL**
215
+
216
+ :param sync_id: The ID of this clock sync marker
217
+ '''
218
+ params: T_JSON_DICT = dict()
219
+ params['syncId'] = sync_id
220
+ cmd_dict: T_JSON_DICT = {
221
+ 'method': 'Tracing.recordClockSyncMarker',
222
+ 'params': params,
223
+ }
224
+ json = yield cmd_dict
225
+
226
+
227
+ def request_memory_dump(
228
+ deterministic: typing.Optional[bool] = None,
229
+ level_of_detail: typing.Optional[MemoryDumpLevelOfDetail] = None
230
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[str, bool]]:
231
+ '''
232
+ Request a global memory dump.
233
+
234
+ **EXPERIMENTAL**
235
+
236
+ :param deterministic: *(Optional)* Enables more deterministic results by forcing garbage collection
237
+ :param level_of_detail: *(Optional)* Specifies level of details in memory dump. Defaults to "detailed".
238
+ :returns: A tuple with the following items:
239
+
240
+ 0. **dumpGuid** - GUID of the resulting global memory dump.
241
+ 1. **success** - True iff the global memory dump succeeded.
242
+ '''
243
+ params: T_JSON_DICT = dict()
244
+ if deterministic is not None:
245
+ params['deterministic'] = deterministic
246
+ if level_of_detail is not None:
247
+ params['levelOfDetail'] = level_of_detail.to_json()
248
+ cmd_dict: T_JSON_DICT = {
249
+ 'method': 'Tracing.requestMemoryDump',
250
+ 'params': params,
251
+ }
252
+ json = yield cmd_dict
253
+ return (
254
+ str(json['dumpGuid']),
255
+ bool(json['success'])
256
+ )
257
+
258
+
259
+ def start(
260
+ categories: typing.Optional[str] = None,
261
+ options: typing.Optional[str] = None,
262
+ buffer_usage_reporting_interval: typing.Optional[float] = None,
263
+ transfer_mode: typing.Optional[str] = None,
264
+ stream_format: typing.Optional[StreamFormat] = None,
265
+ stream_compression: typing.Optional[StreamCompression] = None,
266
+ trace_config: typing.Optional[TraceConfig] = None,
267
+ perfetto_config: typing.Optional[str] = None,
268
+ tracing_backend: typing.Optional[TracingBackend] = None
269
+ ) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
270
+ '''
271
+ Start trace events collection.
272
+
273
+ :param categories: **(DEPRECATED)** **(EXPERIMENTAL)** *(Optional)* Category/tag filter
274
+ :param options: **(DEPRECATED)** **(EXPERIMENTAL)** *(Optional)* Tracing options
275
+ :param buffer_usage_reporting_interval: **(EXPERIMENTAL)** *(Optional)* If set, the agent will issue bufferUsage events at this interval, specified in milliseconds
276
+ :param transfer_mode: *(Optional)* Whether to report trace events as series of dataCollected events or to save trace to a stream (defaults to ```ReportEvents````).
277
+ :param stream_format: *(Optional)* Trace data format to use. This only applies when using ````ReturnAsStream```` transfer mode (defaults to ````json````).
278
+ :param stream_compression: **(EXPERIMENTAL)** *(Optional)* Compression format to use. This only applies when using ````ReturnAsStream```` transfer mode (defaults to ````none````)
279
+ :param trace_config: *(Optional)*
280
+ :param perfetto_config: **(EXPERIMENTAL)** *(Optional)* Base64-encoded serialized perfetto.protos.TraceConfig protobuf message When specified, the parameters ````categories````, ````options````, ````traceConfig```` are ignored. (Encoded as a base64 string when passed over JSON)
281
+ :param tracing_backend: **(EXPERIMENTAL)** *(Optional)* Backend type (defaults to ````auto```)
282
+ '''
283
+ params: T_JSON_DICT = dict()
284
+ if categories is not None:
285
+ params['categories'] = categories
286
+ if options is not None:
287
+ params['options'] = options
288
+ if buffer_usage_reporting_interval is not None:
289
+ params['bufferUsageReportingInterval'] = buffer_usage_reporting_interval
290
+ if transfer_mode is not None:
291
+ params['transferMode'] = transfer_mode
292
+ if stream_format is not None:
293
+ params['streamFormat'] = stream_format.to_json()
294
+ if stream_compression is not None:
295
+ params['streamCompression'] = stream_compression.to_json()
296
+ if trace_config is not None:
297
+ params['traceConfig'] = trace_config.to_json()
298
+ if perfetto_config is not None:
299
+ params['perfettoConfig'] = perfetto_config
300
+ if tracing_backend is not None:
301
+ params['tracingBackend'] = tracing_backend.to_json()
302
+ cmd_dict: T_JSON_DICT = {
303
+ 'method': 'Tracing.start',
304
+ 'params': params,
305
+ }
306
+ json = yield cmd_dict
307
+
308
+
309
+ @event_class('Tracing.bufferUsage')
310
+ @dataclass
311
+ class BufferUsage:
312
+ '''
313
+ **EXPERIMENTAL**
314
+
315
+
316
+ '''
317
+ #: A number in range [0..1] that indicates the used size of event buffer as a fraction of its
318
+ #: total size.
319
+ percent_full: typing.Optional[float]
320
+ #: An approximate number of events in the trace log.
321
+ event_count: typing.Optional[float]
322
+ #: A number in range [0..1] that indicates the used size of event buffer as a fraction of its
323
+ #: total size.
324
+ value: typing.Optional[float]
325
+
326
+ @classmethod
327
+ def from_json(cls, json: T_JSON_DICT) -> BufferUsage:
328
+ return cls(
329
+ percent_full=float(json['percentFull']) if json.get('percentFull', None) is not None else None,
330
+ event_count=float(json['eventCount']) if json.get('eventCount', None) is not None else None,
331
+ value=float(json['value']) if json.get('value', None) is not None else None
332
+ )
333
+
334
+
335
+ @event_class('Tracing.dataCollected')
336
+ @dataclass
337
+ class DataCollected:
338
+ '''
339
+ **EXPERIMENTAL**
340
+
341
+ Contains a bucket of collected trace events. When tracing is stopped collected events will be
342
+ sent as a sequence of dataCollected events followed by tracingComplete event.
343
+ '''
344
+ value: typing.List[dict]
345
+
346
+ @classmethod
347
+ def from_json(cls, json: T_JSON_DICT) -> DataCollected:
348
+ return cls(
349
+ value=[dict(i) for i in json['value']]
350
+ )
351
+
352
+
353
+ @event_class('Tracing.tracingComplete')
354
+ @dataclass
355
+ class TracingComplete:
356
+ '''
357
+ Signals that tracing is stopped and there is no trace buffers pending flush, all data were
358
+ delivered via dataCollected events.
359
+ '''
360
+ #: Indicates whether some trace data is known to have been lost, e.g. because the trace ring
361
+ #: buffer wrapped around.
362
+ data_loss_occurred: bool
363
+ #: A handle of the stream that holds resulting trace data.
364
+ stream: typing.Optional[io.StreamHandle]
365
+ #: Trace data format of returned stream.
366
+ trace_format: typing.Optional[StreamFormat]
367
+ #: Compression format of returned stream.
368
+ stream_compression: typing.Optional[StreamCompression]
369
+
370
+ @classmethod
371
+ def from_json(cls, json: T_JSON_DICT) -> TracingComplete:
372
+ return cls(
373
+ data_loss_occurred=bool(json['dataLossOccurred']),
374
+ stream=io.StreamHandle.from_json(json['stream']) if json.get('stream', None) is not None else None,
375
+ trace_format=StreamFormat.from_json(json['traceFormat']) if json.get('traceFormat', None) is not None else None,
376
+ stream_compression=StreamCompression.from_json(json['streamCompression']) if json.get('streamCompression', None) is not None else None
377
+ )
mithwire/cdp/util.py ADDED
@@ -0,0 +1,18 @@
1
+
2
+ import typing
3
+
4
+ T_JSON_DICT = typing.Dict[str, typing.Any]
5
+ _event_parsers = dict()
6
+
7
+
8
+ def event_class(method):
9
+ ''' A decorator that registers a class as an event class. '''
10
+ def decorate(cls):
11
+ _event_parsers[method] = cls
12
+ return cls
13
+ return decorate
14
+
15
+
16
+ def parse_json_event(json: T_JSON_DICT) -> typing.Any:
17
+ ''' Parse a JSON dictionary into a CDP event. '''
18
+ return _event_parsers[json['method']].from_json(json['params'])