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.
- mithwire/__init__.py +32 -0
- mithwire/cdp/README.md +4 -0
- mithwire/cdp/__init__.py +6 -0
- mithwire/cdp/accessibility.py +668 -0
- mithwire/cdp/animation.py +494 -0
- mithwire/cdp/audits.py +1995 -0
- mithwire/cdp/autofill.py +292 -0
- mithwire/cdp/background_service.py +215 -0
- mithwire/cdp/bluetooth_emulation.py +626 -0
- mithwire/cdp/browser.py +821 -0
- mithwire/cdp/cache_storage.py +311 -0
- mithwire/cdp/cast.py +172 -0
- mithwire/cdp/console.py +107 -0
- mithwire/cdp/crash_report_context.py +55 -0
- mithwire/cdp/css.py +2750 -0
- mithwire/cdp/database.py +179 -0
- mithwire/cdp/debugger.py +1405 -0
- mithwire/cdp/device_access.py +141 -0
- mithwire/cdp/device_orientation.py +45 -0
- mithwire/cdp/dom.py +2257 -0
- mithwire/cdp/dom_debugger.py +321 -0
- mithwire/cdp/dom_snapshot.py +876 -0
- mithwire/cdp/dom_storage.py +222 -0
- mithwire/cdp/emulation.py +1779 -0
- mithwire/cdp/event_breakpoints.py +56 -0
- mithwire/cdp/extensions.py +238 -0
- mithwire/cdp/fed_cm.py +283 -0
- mithwire/cdp/fetch.py +507 -0
- mithwire/cdp/file_system.py +115 -0
- mithwire/cdp/headless_experimental.py +115 -0
- mithwire/cdp/heap_profiler.py +401 -0
- mithwire/cdp/indexed_db.py +528 -0
- mithwire/cdp/input_.py +701 -0
- mithwire/cdp/inspector.py +95 -0
- mithwire/cdp/io.py +101 -0
- mithwire/cdp/layer_tree.py +464 -0
- mithwire/cdp/log.py +190 -0
- mithwire/cdp/media.py +313 -0
- mithwire/cdp/memory.py +305 -0
- mithwire/cdp/network.py +5342 -0
- mithwire/cdp/overlay.py +1468 -0
- mithwire/cdp/page.py +3972 -0
- mithwire/cdp/performance.py +124 -0
- mithwire/cdp/performance_timeline.py +200 -0
- mithwire/cdp/preload.py +575 -0
- mithwire/cdp/profiler.py +420 -0
- mithwire/cdp/pwa.py +278 -0
- mithwire/cdp/py.typed +0 -0
- mithwire/cdp/runtime.py +1589 -0
- mithwire/cdp/schema.py +50 -0
- mithwire/cdp/security.py +518 -0
- mithwire/cdp/service_worker.py +401 -0
- mithwire/cdp/smart_card_emulation.py +891 -0
- mithwire/cdp/storage.py +1573 -0
- mithwire/cdp/system_info.py +327 -0
- mithwire/cdp/target.py +829 -0
- mithwire/cdp/tethering.py +65 -0
- mithwire/cdp/tracing.py +377 -0
- mithwire/cdp/util.py +18 -0
- mithwire/cdp/web_audio.py +606 -0
- mithwire/cdp/web_authn.py +598 -0
- mithwire/cdp/web_mcp.py +293 -0
- mithwire/core/_contradict.py +142 -0
- mithwire/core/browser.py +923 -0
- mithwire/core/cf_templates/cf_dark_checkbox.png +0 -0
- mithwire/core/cf_templates/cf_light_checkbox.png +0 -0
- mithwire/core/config.py +323 -0
- mithwire/core/connection.py +564 -0
- mithwire/core/element.py +1205 -0
- mithwire/core/tab.py +2202 -0
- mithwire/core/util.py +5063 -0
- mithwire-0.50.3.dist-info/METADATA +1049 -0
- mithwire-0.50.3.dist-info/RECORD +76 -0
- mithwire-0.50.3.dist-info/WHEEL +5 -0
- mithwire-0.50.3.dist-info/licenses/LICENSE.txt +619 -0
- mithwire-0.50.3.dist-info/top_level.txt +1 -0
mithwire/cdp/memory.py
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
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: Memory (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
|
+
class PressureLevel(enum.Enum):
|
|
16
|
+
'''
|
|
17
|
+
Memory pressure level.
|
|
18
|
+
'''
|
|
19
|
+
MODERATE = "moderate"
|
|
20
|
+
CRITICAL = "critical"
|
|
21
|
+
|
|
22
|
+
def to_json(self) -> str:
|
|
23
|
+
return self.value
|
|
24
|
+
|
|
25
|
+
@classmethod
|
|
26
|
+
def from_json(cls, json: str) -> PressureLevel:
|
|
27
|
+
return cls(json)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class SamplingProfileNode:
|
|
32
|
+
'''
|
|
33
|
+
Heap profile sample.
|
|
34
|
+
'''
|
|
35
|
+
#: Size of the sampled allocation.
|
|
36
|
+
size: float
|
|
37
|
+
|
|
38
|
+
#: Total bytes attributed to this sample.
|
|
39
|
+
total: float
|
|
40
|
+
|
|
41
|
+
#: Execution stack at the point of allocation.
|
|
42
|
+
stack: typing.List[str]
|
|
43
|
+
|
|
44
|
+
def to_json(self) -> T_JSON_DICT:
|
|
45
|
+
json: T_JSON_DICT = dict()
|
|
46
|
+
json['size'] = self.size
|
|
47
|
+
json['total'] = self.total
|
|
48
|
+
json['stack'] = [i for i in self.stack]
|
|
49
|
+
return json
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def from_json(cls, json: T_JSON_DICT) -> SamplingProfileNode:
|
|
53
|
+
return cls(
|
|
54
|
+
size=float(json['size']),
|
|
55
|
+
total=float(json['total']),
|
|
56
|
+
stack=[str(i) for i in json['stack']],
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@dataclass
|
|
61
|
+
class SamplingProfile:
|
|
62
|
+
'''
|
|
63
|
+
Array of heap profile samples.
|
|
64
|
+
'''
|
|
65
|
+
samples: typing.List[SamplingProfileNode]
|
|
66
|
+
|
|
67
|
+
modules: typing.List[Module]
|
|
68
|
+
|
|
69
|
+
def to_json(self) -> T_JSON_DICT:
|
|
70
|
+
json: T_JSON_DICT = dict()
|
|
71
|
+
json['samples'] = [i.to_json() for i in self.samples]
|
|
72
|
+
json['modules'] = [i.to_json() for i in self.modules]
|
|
73
|
+
return json
|
|
74
|
+
|
|
75
|
+
@classmethod
|
|
76
|
+
def from_json(cls, json: T_JSON_DICT) -> SamplingProfile:
|
|
77
|
+
return cls(
|
|
78
|
+
samples=[SamplingProfileNode.from_json(i) for i in json['samples']],
|
|
79
|
+
modules=[Module.from_json(i) for i in json['modules']],
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@dataclass
|
|
84
|
+
class Module:
|
|
85
|
+
'''
|
|
86
|
+
Executable module information
|
|
87
|
+
'''
|
|
88
|
+
#: Name of the module.
|
|
89
|
+
name: str
|
|
90
|
+
|
|
91
|
+
#: UUID of the module.
|
|
92
|
+
uuid: str
|
|
93
|
+
|
|
94
|
+
#: Base address where the module is loaded into memory. Encoded as a decimal
|
|
95
|
+
#: or hexadecimal (0x prefixed) string.
|
|
96
|
+
base_address: str
|
|
97
|
+
|
|
98
|
+
#: Size of the module in bytes.
|
|
99
|
+
size: float
|
|
100
|
+
|
|
101
|
+
def to_json(self) -> T_JSON_DICT:
|
|
102
|
+
json: T_JSON_DICT = dict()
|
|
103
|
+
json['name'] = self.name
|
|
104
|
+
json['uuid'] = self.uuid
|
|
105
|
+
json['baseAddress'] = self.base_address
|
|
106
|
+
json['size'] = self.size
|
|
107
|
+
return json
|
|
108
|
+
|
|
109
|
+
@classmethod
|
|
110
|
+
def from_json(cls, json: T_JSON_DICT) -> Module:
|
|
111
|
+
return cls(
|
|
112
|
+
name=str(json['name']),
|
|
113
|
+
uuid=str(json['uuid']),
|
|
114
|
+
base_address=str(json['baseAddress']),
|
|
115
|
+
size=float(json['size']),
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@dataclass
|
|
120
|
+
class DOMCounter:
|
|
121
|
+
'''
|
|
122
|
+
DOM object counter data.
|
|
123
|
+
'''
|
|
124
|
+
#: Object name. Note: object names should be presumed volatile and clients should not expect
|
|
125
|
+
#: the returned names to be consistent across runs.
|
|
126
|
+
name: str
|
|
127
|
+
|
|
128
|
+
#: Object count.
|
|
129
|
+
count: int
|
|
130
|
+
|
|
131
|
+
def to_json(self) -> T_JSON_DICT:
|
|
132
|
+
json: T_JSON_DICT = dict()
|
|
133
|
+
json['name'] = self.name
|
|
134
|
+
json['count'] = self.count
|
|
135
|
+
return json
|
|
136
|
+
|
|
137
|
+
@classmethod
|
|
138
|
+
def from_json(cls, json: T_JSON_DICT) -> DOMCounter:
|
|
139
|
+
return cls(
|
|
140
|
+
name=str(json['name']),
|
|
141
|
+
count=int(json['count']),
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def get_dom_counters() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.Tuple[int, int, int]]:
|
|
146
|
+
'''
|
|
147
|
+
Retruns current DOM object counters.
|
|
148
|
+
|
|
149
|
+
:returns: A tuple with the following items:
|
|
150
|
+
|
|
151
|
+
0. **documents** -
|
|
152
|
+
1. **nodes** -
|
|
153
|
+
2. **jsEventListeners** -
|
|
154
|
+
'''
|
|
155
|
+
cmd_dict: T_JSON_DICT = {
|
|
156
|
+
'method': 'Memory.getDOMCounters',
|
|
157
|
+
}
|
|
158
|
+
json = yield cmd_dict
|
|
159
|
+
return (
|
|
160
|
+
int(json['documents']),
|
|
161
|
+
int(json['nodes']),
|
|
162
|
+
int(json['jsEventListeners'])
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def get_dom_counters_for_leak_detection() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[DOMCounter]]:
|
|
167
|
+
'''
|
|
168
|
+
Retruns DOM object counters after preparing renderer for leak detection.
|
|
169
|
+
|
|
170
|
+
:returns: DOM object counters.
|
|
171
|
+
'''
|
|
172
|
+
cmd_dict: T_JSON_DICT = {
|
|
173
|
+
'method': 'Memory.getDOMCountersForLeakDetection',
|
|
174
|
+
}
|
|
175
|
+
json = yield cmd_dict
|
|
176
|
+
return [DOMCounter.from_json(i) for i in json['counters']]
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def prepare_for_leak_detection() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
180
|
+
'''
|
|
181
|
+
Prepares for leak detection by terminating workers, stopping spellcheckers,
|
|
182
|
+
dropping non-essential internal caches, running garbage collections, etc.
|
|
183
|
+
'''
|
|
184
|
+
cmd_dict: T_JSON_DICT = {
|
|
185
|
+
'method': 'Memory.prepareForLeakDetection',
|
|
186
|
+
}
|
|
187
|
+
json = yield cmd_dict
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def forcibly_purge_java_script_memory() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
191
|
+
'''
|
|
192
|
+
Simulate OomIntervention by purging V8 memory.
|
|
193
|
+
'''
|
|
194
|
+
cmd_dict: T_JSON_DICT = {
|
|
195
|
+
'method': 'Memory.forciblyPurgeJavaScriptMemory',
|
|
196
|
+
}
|
|
197
|
+
json = yield cmd_dict
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def set_pressure_notifications_suppressed(
|
|
201
|
+
suppressed: bool
|
|
202
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
203
|
+
'''
|
|
204
|
+
Enable/disable suppressing memory pressure notifications in all processes.
|
|
205
|
+
|
|
206
|
+
:param suppressed: If true, memory pressure notifications will be suppressed.
|
|
207
|
+
'''
|
|
208
|
+
params: T_JSON_DICT = dict()
|
|
209
|
+
params['suppressed'] = suppressed
|
|
210
|
+
cmd_dict: T_JSON_DICT = {
|
|
211
|
+
'method': 'Memory.setPressureNotificationsSuppressed',
|
|
212
|
+
'params': params,
|
|
213
|
+
}
|
|
214
|
+
json = yield cmd_dict
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def simulate_pressure_notification(
|
|
218
|
+
level: PressureLevel
|
|
219
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
220
|
+
'''
|
|
221
|
+
Simulate a memory pressure notification in all processes.
|
|
222
|
+
|
|
223
|
+
:param level: Memory pressure level of the notification.
|
|
224
|
+
'''
|
|
225
|
+
params: T_JSON_DICT = dict()
|
|
226
|
+
params['level'] = level.to_json()
|
|
227
|
+
cmd_dict: T_JSON_DICT = {
|
|
228
|
+
'method': 'Memory.simulatePressureNotification',
|
|
229
|
+
'params': params,
|
|
230
|
+
}
|
|
231
|
+
json = yield cmd_dict
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def start_sampling(
|
|
235
|
+
sampling_interval: typing.Optional[int] = None,
|
|
236
|
+
suppress_randomness: typing.Optional[bool] = None
|
|
237
|
+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
238
|
+
'''
|
|
239
|
+
Start collecting native memory profile.
|
|
240
|
+
|
|
241
|
+
:param sampling_interval: *(Optional)* Average number of bytes between samples.
|
|
242
|
+
:param suppress_randomness: *(Optional)* Do not randomize intervals between samples.
|
|
243
|
+
'''
|
|
244
|
+
params: T_JSON_DICT = dict()
|
|
245
|
+
if sampling_interval is not None:
|
|
246
|
+
params['samplingInterval'] = sampling_interval
|
|
247
|
+
if suppress_randomness is not None:
|
|
248
|
+
params['suppressRandomness'] = suppress_randomness
|
|
249
|
+
cmd_dict: T_JSON_DICT = {
|
|
250
|
+
'method': 'Memory.startSampling',
|
|
251
|
+
'params': params,
|
|
252
|
+
}
|
|
253
|
+
json = yield cmd_dict
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def stop_sampling() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,None]:
|
|
257
|
+
'''
|
|
258
|
+
Stop collecting native memory profile.
|
|
259
|
+
'''
|
|
260
|
+
cmd_dict: T_JSON_DICT = {
|
|
261
|
+
'method': 'Memory.stopSampling',
|
|
262
|
+
}
|
|
263
|
+
json = yield cmd_dict
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def get_all_time_sampling_profile() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SamplingProfile]:
|
|
267
|
+
'''
|
|
268
|
+
Retrieve native memory allocations profile
|
|
269
|
+
collected since renderer process startup.
|
|
270
|
+
|
|
271
|
+
:returns:
|
|
272
|
+
'''
|
|
273
|
+
cmd_dict: T_JSON_DICT = {
|
|
274
|
+
'method': 'Memory.getAllTimeSamplingProfile',
|
|
275
|
+
}
|
|
276
|
+
json = yield cmd_dict
|
|
277
|
+
return SamplingProfile.from_json(json['profile'])
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def get_browser_sampling_profile() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SamplingProfile]:
|
|
281
|
+
'''
|
|
282
|
+
Retrieve native memory allocations profile
|
|
283
|
+
collected since browser process startup.
|
|
284
|
+
|
|
285
|
+
:returns:
|
|
286
|
+
'''
|
|
287
|
+
cmd_dict: T_JSON_DICT = {
|
|
288
|
+
'method': 'Memory.getBrowserSamplingProfile',
|
|
289
|
+
}
|
|
290
|
+
json = yield cmd_dict
|
|
291
|
+
return SamplingProfile.from_json(json['profile'])
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def get_sampling_profile() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,SamplingProfile]:
|
|
295
|
+
'''
|
|
296
|
+
Retrieve native memory allocations profile collected since last
|
|
297
|
+
``startSampling`` call.
|
|
298
|
+
|
|
299
|
+
:returns:
|
|
300
|
+
'''
|
|
301
|
+
cmd_dict: T_JSON_DICT = {
|
|
302
|
+
'method': 'Memory.getSamplingProfile',
|
|
303
|
+
}
|
|
304
|
+
json = yield cmd_dict
|
|
305
|
+
return SamplingProfile.from_json(json['profile'])
|