Skip to content

Commit bb0e5ea

Browse files
committed
generate code and docs for CPD r953906
1 parent f41ca68 commit bb0e5ea

40 files changed

Lines changed: 1746 additions & 400 deletions

tests/test_trio_cdp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ async def handler(request):
4747
'title': 'New Tab',
4848
'url': 'about:newtab',
4949
'attached': False,
50+
'canAccessOpener': False,
5051
}],
5152
}
5253
}

trio_cdp/generated/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from . import accessibility
77
from . import animation
8-
from . import application_cache
98
from . import audits
109
from . import background_service
1110
from . import browser
@@ -21,6 +20,7 @@
2120
from . import dom_snapshot
2221
from . import dom_storage
2322
from . import emulation
23+
from . import event_breakpoints
2424
from . import fetch
2525
from . import headless_experimental
2626
from . import heap_profiler
@@ -30,11 +30,13 @@
3030
from . import io
3131
from . import layer_tree
3232
from . import log
33+
from . import media
3334
from . import memory
3435
from . import network
3536
from . import overlay
3637
from . import page
3738
from . import performance
39+
from . import performance_timeline
3840
from . import profiler
3941
from . import runtime
4042
from . import schema

trio_cdp/generated/accessibility.py

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
AXValueNativeSourceType,
2020
AXValueSource,
2121
AXValueSourceType,
22-
AXValueType
22+
AXValueType,
23+
LoadComplete,
24+
NodesUpdated
2325
)
2426

2527

@@ -40,16 +42,61 @@ async def enable() -> None:
4042
return await session.execute(cdp.accessibility.enable())
4143

4244

43-
async def get_full_ax_tree() -> typing.List[AXNode]:
45+
async def get_ax_node_and_ancestors(
46+
node_id: typing.Optional[cdp.dom.NodeId] = None,
47+
backend_node_id: typing.Optional[cdp.dom.BackendNodeId] = None,
48+
object_id: typing.Optional[cdp.runtime.RemoteObjectId] = None
49+
) -> typing.List[AXNode]:
50+
'''
51+
Fetches a node and all ancestors up to and including the root.
52+
Requires ``enable()`` to have been called previously.
53+
54+
**EXPERIMENTAL**
55+
56+
:param node_id: *(Optional)* Identifier of the node to get.
57+
:param backend_node_id: *(Optional)* Identifier of the backend node to get.
58+
:param object_id: *(Optional)* JavaScript object id of the node wrapper to get.
59+
:returns:
60+
'''
61+
session = get_session_context('accessibility.get_ax_node_and_ancestors')
62+
return await session.execute(cdp.accessibility.get_ax_node_and_ancestors(node_id, backend_node_id, object_id))
63+
64+
65+
async def get_child_ax_nodes(
66+
id_: AXNodeId,
67+
frame_id: typing.Optional[cdp.page.FrameId] = None
68+
) -> typing.List[AXNode]:
69+
'''
70+
Fetches a particular accessibility node by AXNodeId.
71+
Requires ``enable()`` to have been called previously.
72+
73+
**EXPERIMENTAL**
74+
75+
:param id_:
76+
:param frame_id: *(Optional)* The frame in whose document the node resides. If omitted, the root frame is used.
77+
:returns:
78+
'''
79+
session = get_session_context('accessibility.get_child_ax_nodes')
80+
return await session.execute(cdp.accessibility.get_child_ax_nodes(id_, frame_id))
81+
82+
83+
async def get_full_ax_tree(
84+
depth: typing.Optional[int] = None,
85+
max_depth: typing.Optional[int] = None,
86+
frame_id: typing.Optional[cdp.page.FrameId] = None
87+
) -> typing.List[AXNode]:
4488
'''
45-
Fetches the entire accessibility tree
89+
Fetches the entire accessibility tree for the root Document
4690
4791
**EXPERIMENTAL**
4892
93+
:param depth: *(Optional)* The maximum depth at which descendants of the root node should be retrieved. If omitted, the full tree is returned.
94+
:param max_depth: **(DEPRECATED)** *(Optional)* Deprecated. This parameter has been renamed to ```depth```. If depth is not provided, max_depth will be used.
95+
:param frame_id: *(Optional)* The frame for whose document the AX tree should be retrieved. If omited, the root frame is used.
4996
:returns:
5097
'''
5198
session = get_session_context('accessibility.get_full_ax_tree')
52-
return await session.execute(cdp.accessibility.get_full_ax_tree())
99+
return await session.execute(cdp.accessibility.get_full_ax_tree(depth, max_depth, frame_id))
53100

54101

55102
async def get_partial_ax_tree(
@@ -71,3 +118,46 @@ async def get_partial_ax_tree(
71118
'''
72119
session = get_session_context('accessibility.get_partial_ax_tree')
73120
return await session.execute(cdp.accessibility.get_partial_ax_tree(node_id, backend_node_id, object_id, fetch_relatives))
121+
122+
123+
async def get_root_ax_node(
124+
frame_id: typing.Optional[cdp.page.FrameId] = None
125+
) -> AXNode:
126+
'''
127+
Fetches the root node.
128+
Requires ``enable()`` to have been called previously.
129+
130+
**EXPERIMENTAL**
131+
132+
:param frame_id: *(Optional)* The frame in whose document the node resides. If omitted, the root frame is used.
133+
:returns:
134+
'''
135+
session = get_session_context('accessibility.get_root_ax_node')
136+
return await session.execute(cdp.accessibility.get_root_ax_node(frame_id))
137+
138+
139+
async def query_ax_tree(
140+
node_id: typing.Optional[cdp.dom.NodeId] = None,
141+
backend_node_id: typing.Optional[cdp.dom.BackendNodeId] = None,
142+
object_id: typing.Optional[cdp.runtime.RemoteObjectId] = None,
143+
accessible_name: typing.Optional[str] = None,
144+
role: typing.Optional[str] = None
145+
) -> typing.List[AXNode]:
146+
'''
147+
Query a DOM node's accessibility subtree for accessible name and role.
148+
This command computes the name and role for all nodes in the subtree, including those that are
149+
ignored for accessibility, and returns those that mactch the specified name and role. If no DOM
150+
node is specified, or the DOM node does not exist, the command returns an error. If neither
151+
``accessibleName`` or ``role`` is specified, it returns all the accessibility nodes in the subtree.
152+
153+
**EXPERIMENTAL**
154+
155+
:param node_id: *(Optional)* Identifier of the node for the root to query.
156+
:param backend_node_id: *(Optional)* Identifier of the backend node for the root to query.
157+
:param object_id: *(Optional)* JavaScript object id of the node wrapper for the root to query.
158+
:param accessible_name: *(Optional)* Find nodes with this computed name.
159+
:param role: *(Optional)* Find nodes with this computed role.
160+
:returns: A list of ``Accessibility.AXNode`` matching the specified attributes, including nodes that are ignored for accessibility.
161+
'''
162+
session = get_session_context('accessibility.query_ax_tree')
163+
return await session.execute(cdp.accessibility.query_ax_tree(node_id, backend_node_id, object_id, accessible_name, role))

trio_cdp/generated/application_cache.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

trio_cdp/generated/audits.py

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,78 @@
99
from ..context import get_connection_context, get_session_context
1010

1111
import cdp.audits
12+
from cdp.audits import (
13+
AffectedCookie,
14+
AffectedFrame,
15+
AffectedRequest,
16+
AttributionReportingIssueDetails,
17+
AttributionReportingIssueType,
18+
BlockedByResponseIssueDetails,
19+
BlockedByResponseReason,
20+
ClientHintIssueDetails,
21+
ClientHintIssueReason,
22+
ContentSecurityPolicyIssueDetails,
23+
ContentSecurityPolicyViolationType,
24+
CorsIssueDetails,
25+
DeprecationIssueDetails,
26+
GenericIssueDetails,
27+
GenericIssueErrorType,
28+
HeavyAdIssueDetails,
29+
HeavyAdReason,
30+
HeavyAdResolutionStatus,
31+
InspectorIssue,
32+
InspectorIssueCode,
33+
InspectorIssueDetails,
34+
IssueAdded,
35+
IssueId,
36+
LowTextContrastIssueDetails,
37+
MixedContentIssueDetails,
38+
MixedContentResolutionStatus,
39+
MixedContentResourceType,
40+
NavigatorUserAgentIssueDetails,
41+
QuirksModeIssueDetails,
42+
SameSiteCookieExclusionReason,
43+
SameSiteCookieIssueDetails,
44+
SameSiteCookieOperation,
45+
SameSiteCookieWarningReason,
46+
SharedArrayBufferIssueDetails,
47+
SharedArrayBufferIssueType,
48+
SourceCodeLocation,
49+
TrustedWebActivityIssueDetails,
50+
TwaQualityEnforcementViolationType,
51+
WasmCrossOriginModuleSharingIssueDetails
52+
)
53+
54+
55+
async def check_contrast(
56+
report_aaa: typing.Optional[bool] = None
57+
) -> None:
58+
'''
59+
Runs the contrast check for the target page. Found issues are reported
60+
using Audits.issueAdded event.
61+
62+
:param report_aaa: *(Optional)* Whether to report WCAG AAA level issues. Default is false.
63+
'''
64+
session = get_session_context('audits.check_contrast')
65+
return await session.execute(cdp.audits.check_contrast(report_aaa))
66+
67+
68+
async def disable() -> None:
69+
'''
70+
Disables issues domain, prevents further issues from being reported to the client.
71+
'''
72+
session = get_session_context('audits.disable')
73+
return await session.execute(cdp.audits.disable())
74+
75+
76+
async def enable() -> None:
77+
'''
78+
Enables issues domain, sends the issues collected so far to the client by means of the
79+
``issueAdded`` event.
80+
'''
81+
session = get_session_context('audits.enable')
82+
return await session.execute(cdp.audits.enable())
83+
1284

1385
async def get_encoded_response(
1486
request_id: cdp.network.RequestId,
@@ -26,9 +98,9 @@ async def get_encoded_response(
2698
:param size_only: *(Optional)* Whether to only return the size information (defaults to false).
2799
:returns: A tuple with the following items:
28100
29-
0. **body** *(Optional)* The encoded body as a base64 string. Omitted if sizeOnly is true.
30-
1. **originalSize** Size before re-encoding.
31-
2. **encodedSize** Size after re-encoding.
101+
0. **body** - *(Optional)* The encoded body as a base64 string. Omitted if sizeOnly is true. (Encoded as a base64 string when passed over JSON)
102+
1. **originalSize** - Size before re-encoding.
103+
2. **encodedSize** - Size after re-encoding.
32104
'''
33105
session = get_session_context('audits.get_encoded_response')
34106
return await session.execute(cdp.audits.get_encoded_response(request_id, encoding, quality, size_only))

0 commit comments

Comments
 (0)