Skip to content

Commit cb9cfd1

Browse files
Copilothyp3ri0n-ng
andcommitted
Update CDP to latest protocol with new domains and security enhancements
Co-authored-by: hyp3ri0n-ng <3106718+hyp3ri0n-ng@users.noreply.github.com>
1 parent 12f8fee commit cb9cfd1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+33822
-13400
lines changed

cdp/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import cdp.accessibility
99
import cdp.animation
1010
import cdp.audits
11+
import cdp.autofill
1112
import cdp.background_service
13+
import cdp.bluetooth_emulation
1214
import cdp.browser
1315
import cdp.css
1416
import cdp.cache_storage
@@ -18,12 +20,15 @@
1820
import cdp.dom_debugger
1921
import cdp.dom_snapshot
2022
import cdp.dom_storage
21-
import cdp.database
2223
import cdp.debugger
24+
import cdp.device_access
2325
import cdp.device_orientation
2426
import cdp.emulation
2527
import cdp.event_breakpoints
28+
import cdp.extensions
29+
import cdp.fed_cm
2630
import cdp.fetch
31+
import cdp.file_system
2732
import cdp.headless_experimental
2833
import cdp.heap_profiler
2934
import cdp.io
@@ -36,9 +41,11 @@
3641
import cdp.memory
3742
import cdp.network
3843
import cdp.overlay
44+
import cdp.pwa
3945
import cdp.page
4046
import cdp.performance
4147
import cdp.performance_timeline
48+
import cdp.preload
4249
import cdp.profiler
4350
import cdp.runtime
4451
import cdp.schema

cdp/accessibility.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class AXValueSource:
123123
#: Whether this source is superseded by a higher priority source.
124124
superseded: typing.Optional[bool] = None
125125

126-
#: The native markup source for this value, e.g. a <label> element.
126+
#: The native markup source for this value, e.g. a ``<label>`` element.
127127
native_source: typing.Optional[AXValueNativeSourceType] = None
128128

129129
#: The value, such as a node or node list, of the native source.
@@ -267,8 +267,10 @@ class AXPropertyName(enum.Enum):
267267
- from 'live' to 'root': attributes which apply to nodes in live regions
268268
- from 'autocomplete' to 'valuetext': attributes which apply to widgets
269269
- from 'checked' to 'selected': states which apply to widgets
270-
- from 'activedescendant' to 'owns' - relationships between elements other than parent/child/sibling.
270+
- from 'activedescendant' to 'owns': relationships between elements other than parent/child/sibling
271+
- from 'activeFullscreenElement' to 'uninteresting': reasons why this noode is hidden
271272
'''
273+
ACTIONS = "actions"
272274
BUSY = "busy"
273275
DISABLED = "disabled"
274276
EDITABLE = "editable"
@@ -308,6 +310,24 @@ class AXPropertyName(enum.Enum):
308310
FLOWTO = "flowto"
309311
LABELLEDBY = "labelledby"
310312
OWNS = "owns"
313+
URL = "url"
314+
ACTIVE_FULLSCREEN_ELEMENT = "activeFullscreenElement"
315+
ACTIVE_MODAL_DIALOG = "activeModalDialog"
316+
ACTIVE_ARIA_MODAL_DIALOG = "activeAriaModalDialog"
317+
ARIA_HIDDEN_ELEMENT = "ariaHiddenElement"
318+
ARIA_HIDDEN_SUBTREE = "ariaHiddenSubtree"
319+
EMPTY_ALT = "emptyAlt"
320+
EMPTY_TEXT = "emptyText"
321+
INERT_ELEMENT = "inertElement"
322+
INERT_SUBTREE = "inertSubtree"
323+
LABEL_CONTAINER = "labelContainer"
324+
LABEL_FOR = "labelFor"
325+
NOT_RENDERED = "notRendered"
326+
NOT_VISIBLE = "notVisible"
327+
PRESENTATIONAL_ROLE = "presentationalRole"
328+
PROBABLY_PRESENTATIONAL = "probablyPresentational"
329+
INACTIVE_CAROUSEL_TAB_CONTENT = "inactiveCarouselTabContent"
330+
UNINTERESTING = "uninteresting"
311331

312332
def to_json(self) -> str:
313333
return self.value
@@ -334,6 +354,9 @@ class AXNode:
334354
#: This ``Node``'s role, whether explicit or implicit.
335355
role: typing.Optional[AXValue] = None
336356

357+
#: This ``Node``'s Chrome raw role.
358+
chrome_role: typing.Optional[AXValue] = None
359+
337360
#: The accessible name for this ``Node``.
338361
name: typing.Optional[AXValue] = None
339362

@@ -366,6 +389,8 @@ def to_json(self) -> T_JSON_DICT:
366389
json['ignoredReasons'] = [i.to_json() for i in self.ignored_reasons]
367390
if self.role is not None:
368391
json['role'] = self.role.to_json()
392+
if self.chrome_role is not None:
393+
json['chromeRole'] = self.chrome_role.to_json()
369394
if self.name is not None:
370395
json['name'] = self.name.to_json()
371396
if self.description is not None:
@@ -391,6 +416,7 @@ def from_json(cls, json: T_JSON_DICT) -> AXNode:
391416
ignored=bool(json['ignored']),
392417
ignored_reasons=[AXProperty.from_json(i) for i in json['ignoredReasons']] if 'ignoredReasons' in json else None,
393418
role=AXValue.from_json(json['role']) if 'role' in json else None,
419+
chrome_role=AXValue.from_json(json['chromeRole']) if 'chromeRole' in json else None,
394420
name=AXValue.from_json(json['name']) if 'name' in json else None,
395421
description=AXValue.from_json(json['description']) if 'description' in json else None,
396422
value=AXValue.from_json(json['value']) if 'value' in json else None,
@@ -437,7 +463,7 @@ def get_partial_ax_tree(
437463
:param node_id: *(Optional)* Identifier of the node to get the partial accessibility tree for.
438464
:param backend_node_id: *(Optional)* Identifier of the backend node to get the partial accessibility tree for.
439465
:param object_id: *(Optional)* JavaScript object id of the node wrapper to get the partial accessibility tree for.
440-
:param fetch_relatives: *(Optional)* Whether to fetch this nodes ancestors, siblings and children. Defaults to true.
466+
:param fetch_relatives: *(Optional)* Whether to fetch this node's ancestors, siblings and children. Defaults to true.
441467
:returns: The ``Accessibility.AXNode`` for this DOM node, if it exists, plus its ancestors, siblings and children, if requested.
442468
'''
443469
params: T_JSON_DICT = dict()
@@ -459,7 +485,6 @@ def get_partial_ax_tree(
459485

460486
def get_full_ax_tree(
461487
depth: typing.Optional[int] = None,
462-
max_depth: typing.Optional[int] = None,
463488
frame_id: typing.Optional[page.FrameId] = None
464489
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[AXNode]]:
465490
r'''
@@ -468,15 +493,12 @@ def get_full_ax_tree(
468493
**EXPERIMENTAL**
469494
470495
:param depth: *(Optional)* The maximum depth at which descendants of the root node should be retrieved. If omitted, the full tree is returned.
471-
:param max_depth: **(DEPRECATED)** *(Optional)* Deprecated. This parameter has been renamed to ```depth```. If depth is not provided, max_depth will be used.
472-
:param frame_id: *(Optional)* The frame for whose document the AX tree should be retrieved. If omited, the root frame is used.
496+
:param frame_id: *(Optional)* The frame for whose document the AX tree should be retrieved. If omitted, the root frame is used.
473497
:returns:
474498
'''
475499
params: T_JSON_DICT = dict()
476500
if depth is not None:
477501
params['depth'] = depth
478-
if max_depth is not None:
479-
params['max_depth'] = max_depth
480502
if frame_id is not None:
481503
params['frameId'] = frame_id.to_json()
482504
cmd_dict: T_JSON_DICT = {
@@ -577,7 +599,7 @@ def query_ax_tree(
577599
r'''
578600
Query a DOM node's accessibility subtree for accessible name and role.
579601
This command computes the name and role for all nodes in the subtree, including those that are
580-
ignored for accessibility, and returns those that mactch the specified name and role. If no DOM
602+
ignored for accessibility, and returns those that match the specified name and role. If no DOM
581603
node is specified, or the DOM node does not exist, the command returns an error. If neither
582604
``accessibleName`` or ``role`` is specified, it returns all the accessibility nodes in the subtree.
583605

cdp/animation.py

Lines changed: 82 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class Animation:
3636
playback_rate: float
3737

3838
#: ``Animation``'s start time.
39+
#: Milliseconds for time based animations and
40+
#: percentage [0 - 100] for scroll driven animations
41+
#: (i.e. when viewOrScrollTimeline exists).
3942
start_time: float
4043

4144
#: ``Animation``'s current time.
@@ -51,6 +54,9 @@ class Animation:
5154
#: animation/transition.
5255
css_id: typing.Optional[str] = None
5356

57+
#: View or scroll timeline
58+
view_or_scroll_timeline: typing.Optional[ViewOrScrollTimeline] = None
59+
5460
def to_json(self) -> T_JSON_DICT:
5561
json: T_JSON_DICT = dict()
5662
json['id'] = self.id_
@@ -65,6 +71,8 @@ def to_json(self) -> T_JSON_DICT:
6571
json['source'] = self.source.to_json()
6672
if self.css_id is not None:
6773
json['cssId'] = self.css_id
74+
if self.view_or_scroll_timeline is not None:
75+
json['viewOrScrollTimeline'] = self.view_or_scroll_timeline.to_json()
6876
return json
6977

7078
@classmethod
@@ -80,6 +88,55 @@ def from_json(cls, json: T_JSON_DICT) -> Animation:
8088
type_=str(json['type']),
8189
source=AnimationEffect.from_json(json['source']) if 'source' in json else None,
8290
css_id=str(json['cssId']) if 'cssId' in json else None,
91+
view_or_scroll_timeline=ViewOrScrollTimeline.from_json(json['viewOrScrollTimeline']) if 'viewOrScrollTimeline' in json else None,
92+
)
93+
94+
95+
@dataclass
96+
class ViewOrScrollTimeline:
97+
r'''
98+
Timeline instance
99+
'''
100+
#: Orientation of the scroll
101+
axis: dom.ScrollOrientation
102+
103+
#: Scroll container node
104+
source_node_id: typing.Optional[dom.BackendNodeId] = None
105+
106+
#: Represents the starting scroll position of the timeline
107+
#: as a length offset in pixels from scroll origin.
108+
start_offset: typing.Optional[float] = None
109+
110+
#: Represents the ending scroll position of the timeline
111+
#: as a length offset in pixels from scroll origin.
112+
end_offset: typing.Optional[float] = None
113+
114+
#: The element whose principal box's visibility in the
115+
#: scrollport defined the progress of the timeline.
116+
#: Does not exist for animations with ScrollTimeline
117+
subject_node_id: typing.Optional[dom.BackendNodeId] = None
118+
119+
def to_json(self) -> T_JSON_DICT:
120+
json: T_JSON_DICT = dict()
121+
json['axis'] = self.axis.to_json()
122+
if self.source_node_id is not None:
123+
json['sourceNodeId'] = self.source_node_id.to_json()
124+
if self.start_offset is not None:
125+
json['startOffset'] = self.start_offset
126+
if self.end_offset is not None:
127+
json['endOffset'] = self.end_offset
128+
if self.subject_node_id is not None:
129+
json['subjectNodeId'] = self.subject_node_id.to_json()
130+
return json
131+
132+
@classmethod
133+
def from_json(cls, json: T_JSON_DICT) -> ViewOrScrollTimeline:
134+
return cls(
135+
axis=dom.ScrollOrientation.from_json(json['axis']),
136+
source_node_id=dom.BackendNodeId.from_json(json['sourceNodeId']) if 'sourceNodeId' in json else None,
137+
start_offset=float(json['startOffset']) if 'startOffset' in json else None,
138+
end_offset=float(json['endOffset']) if 'endOffset' in json else None,
139+
subject_node_id=dom.BackendNodeId.from_json(json['subjectNodeId']) if 'subjectNodeId' in json else None,
83140
)
84141

85142

@@ -97,10 +154,10 @@ class AnimationEffect:
97154
#: ``AnimationEffect``'s iteration start.
98155
iteration_start: float
99156

100-
#: ``AnimationEffect``'s iterations.
101-
iterations: float
102-
103157
#: ``AnimationEffect``'s iteration duration.
158+
#: Milliseconds for time based animations and
159+
#: percentage [0 - 100] for scroll driven animations
160+
#: (i.e. when viewOrScrollTimeline exists).
104161
duration: float
105162

106163
#: ``AnimationEffect``'s playback direction.
@@ -112,6 +169,9 @@ class AnimationEffect:
112169
#: ``AnimationEffect``'s timing function.
113170
easing: str
114171

172+
#: ``AnimationEffect``'s iterations. Omitted if the value is infinite.
173+
iterations: typing.Optional[float] = None
174+
115175
#: ``AnimationEffect``'s target node.
116176
backend_node_id: typing.Optional[dom.BackendNodeId] = None
117177

@@ -123,11 +183,12 @@ def to_json(self) -> T_JSON_DICT:
123183
json['delay'] = self.delay
124184
json['endDelay'] = self.end_delay
125185
json['iterationStart'] = self.iteration_start
126-
json['iterations'] = self.iterations
127186
json['duration'] = self.duration
128187
json['direction'] = self.direction
129188
json['fill'] = self.fill
130189
json['easing'] = self.easing
190+
if self.iterations is not None:
191+
json['iterations'] = self.iterations
131192
if self.backend_node_id is not None:
132193
json['backendNodeId'] = self.backend_node_id.to_json()
133194
if self.keyframes_rule is not None:
@@ -140,11 +201,11 @@ def from_json(cls, json: T_JSON_DICT) -> AnimationEffect:
140201
delay=float(json['delay']),
141202
end_delay=float(json['endDelay']),
142203
iteration_start=float(json['iterationStart']),
143-
iterations=float(json['iterations']),
144204
duration=float(json['duration']),
145205
direction=str(json['direction']),
146206
fill=str(json['fill']),
147207
easing=str(json['easing']),
208+
iterations=float(json['iterations']) if 'iterations' in json else None,
148209
backend_node_id=dom.BackendNodeId.from_json(json['backendNodeId']) if 'backendNodeId' in json else None,
149210
keyframes_rule=KeyframesRule.from_json(json['keyframesRule']) if 'keyframesRule' in json else None,
150211
)
@@ -415,3 +476,19 @@ def from_json(cls, json: T_JSON_DICT) -> AnimationStarted:
415476
return cls(
416477
animation=Animation.from_json(json['animation'])
417478
)
479+
480+
481+
@event_class('Animation.animationUpdated')
482+
@dataclass
483+
class AnimationUpdated:
484+
r'''
485+
Event for animation that has been updated.
486+
'''
487+
#: Animation that was updated.
488+
animation: Animation
489+
490+
@classmethod
491+
def from_json(cls, json: T_JSON_DICT) -> AnimationUpdated:
492+
return cls(
493+
animation=Animation.from_json(json['animation'])
494+
)

0 commit comments

Comments
 (0)