Skip to content

Commit 94e00c4

Browse files
committed
generate code and docs for CPD r953906
1 parent 5463a5f commit 94e00c4

66 files changed

Lines changed: 23433 additions & 8953 deletions

Some content is hidden

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

cdp/__init__.py

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

88
import cdp.accessibility
99
import cdp.animation
10-
import cdp.application_cache
1110
import cdp.audits
1211
import cdp.background_service
1312
import cdp.browser
@@ -23,6 +22,7 @@
2322
import cdp.debugger
2423
import cdp.device_orientation
2524
import cdp.emulation
25+
import cdp.event_breakpoints
2626
import cdp.fetch
2727
import cdp.headless_experimental
2828
import cdp.heap_profiler
@@ -32,11 +32,13 @@
3232
import cdp.inspector
3333
import cdp.layer_tree
3434
import cdp.log
35+
import cdp.media
3536
import cdp.memory
3637
import cdp.network
3738
import cdp.overlay
3839
import cdp.page
3940
import cdp.performance
41+
import cdp.performance_timeline
4042
import cdp.profiler
4143
import cdp.runtime
4244
import cdp.schema

cdp/accessibility.py

Lines changed: 191 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import typing
1313

1414
from . import dom
15+
from . import page
1516
from . import runtime
1617

1718

@@ -83,11 +84,13 @@ class AXValueNativeSourceType(enum.Enum):
8384
'''
8485
Enum of possible native property sources (as a subtype of a particular AXValueSourceType).
8586
'''
87+
DESCRIPTION = "description"
8688
FIGCAPTION = "figcaption"
8789
LABEL = "label"
8890
LABELFOR = "labelfor"
8991
LABELWRAPPED = "labelwrapped"
9092
LEGEND = "legend"
93+
RUBYANNOTATION = "rubyannotation"
9194
TABLECAPTION = "tablecaption"
9295
TITLE = "title"
9396
OTHER = "other"
@@ -343,12 +346,18 @@ class AXNode:
343346
#: All other properties
344347
properties: typing.Optional[typing.List[AXProperty]] = None
345348

349+
#: ID for this node's parent.
350+
parent_id: typing.Optional[AXNodeId] = None
351+
346352
#: IDs for each of this node's child nodes.
347353
child_ids: typing.Optional[typing.List[AXNodeId]] = None
348354

349355
#: The backend ID for the associated DOM node, if any.
350356
backend_dom_node_id: typing.Optional[dom.BackendNodeId] = None
351357

358+
#: The frame ID for the frame associated with this nodes document.
359+
frame_id: typing.Optional[page.FrameId] = None
360+
352361
def to_json(self) -> T_JSON_DICT:
353362
json: T_JSON_DICT = dict()
354363
json['nodeId'] = self.node_id.to_json()
@@ -365,10 +374,14 @@ def to_json(self) -> T_JSON_DICT:
365374
json['value'] = self.value.to_json()
366375
if self.properties is not None:
367376
json['properties'] = [i.to_json() for i in self.properties]
377+
if self.parent_id is not None:
378+
json['parentId'] = self.parent_id.to_json()
368379
if self.child_ids is not None:
369380
json['childIds'] = [i.to_json() for i in self.child_ids]
370381
if self.backend_dom_node_id is not None:
371382
json['backendDOMNodeId'] = self.backend_dom_node_id.to_json()
383+
if self.frame_id is not None:
384+
json['frameId'] = self.frame_id.to_json()
372385
return json
373386

374387
@classmethod
@@ -382,8 +395,10 @@ def from_json(cls, json: T_JSON_DICT) -> AXNode:
382395
description=AXValue.from_json(json['description']) if 'description' in json else None,
383396
value=AXValue.from_json(json['value']) if 'value' in json else None,
384397
properties=[AXProperty.from_json(i) for i in json['properties']] if 'properties' in json else None,
398+
parent_id=AXNodeId.from_json(json['parentId']) if 'parentId' in json else None,
385399
child_ids=[AXNodeId.from_json(i) for i in json['childIds']] if 'childIds' in json else None,
386400
backend_dom_node_id=dom.BackendNodeId.from_json(json['backendDOMNodeId']) if 'backendDOMNodeId' in json else None,
401+
frame_id=page.FrameId.from_json(json['frameId']) if 'frameId' in json else None,
387402
)
388403

389404

@@ -442,16 +457,190 @@ def get_partial_ax_tree(
442457
return [AXNode.from_json(i) for i in json['nodes']]
443458

444459

445-
def get_full_ax_tree() -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[AXNode]]:
460+
def get_full_ax_tree(
461+
depth: typing.Optional[int] = None,
462+
max_depth: typing.Optional[int] = None,
463+
frame_id: typing.Optional[page.FrameId] = None
464+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[AXNode]]:
446465
'''
447-
Fetches the entire accessibility tree
466+
Fetches the entire accessibility tree for the root Document
448467
449468
**EXPERIMENTAL**
450469
470+
: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.
451473
:returns:
452474
'''
475+
params: T_JSON_DICT = dict()
476+
if depth is not None:
477+
params['depth'] = depth
478+
if max_depth is not None:
479+
params['max_depth'] = max_depth
480+
if frame_id is not None:
481+
params['frameId'] = frame_id.to_json()
453482
cmd_dict: T_JSON_DICT = {
454483
'method': 'Accessibility.getFullAXTree',
484+
'params': params,
455485
}
456486
json = yield cmd_dict
457487
return [AXNode.from_json(i) for i in json['nodes']]
488+
489+
490+
def get_root_ax_node(
491+
frame_id: typing.Optional[page.FrameId] = None
492+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,AXNode]:
493+
'''
494+
Fetches the root node.
495+
Requires ``enable()`` to have been called previously.
496+
497+
**EXPERIMENTAL**
498+
499+
:param frame_id: *(Optional)* The frame in whose document the node resides. If omitted, the root frame is used.
500+
:returns:
501+
'''
502+
params: T_JSON_DICT = dict()
503+
if frame_id is not None:
504+
params['frameId'] = frame_id.to_json()
505+
cmd_dict: T_JSON_DICT = {
506+
'method': 'Accessibility.getRootAXNode',
507+
'params': params,
508+
}
509+
json = yield cmd_dict
510+
return AXNode.from_json(json['node'])
511+
512+
513+
def get_ax_node_and_ancestors(
514+
node_id: typing.Optional[dom.NodeId] = None,
515+
backend_node_id: typing.Optional[dom.BackendNodeId] = None,
516+
object_id: typing.Optional[runtime.RemoteObjectId] = None
517+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[AXNode]]:
518+
'''
519+
Fetches a node and all ancestors up to and including the root.
520+
Requires ``enable()`` to have been called previously.
521+
522+
**EXPERIMENTAL**
523+
524+
:param node_id: *(Optional)* Identifier of the node to get.
525+
:param backend_node_id: *(Optional)* Identifier of the backend node to get.
526+
:param object_id: *(Optional)* JavaScript object id of the node wrapper to get.
527+
:returns:
528+
'''
529+
params: T_JSON_DICT = dict()
530+
if node_id is not None:
531+
params['nodeId'] = node_id.to_json()
532+
if backend_node_id is not None:
533+
params['backendNodeId'] = backend_node_id.to_json()
534+
if object_id is not None:
535+
params['objectId'] = object_id.to_json()
536+
cmd_dict: T_JSON_DICT = {
537+
'method': 'Accessibility.getAXNodeAndAncestors',
538+
'params': params,
539+
}
540+
json = yield cmd_dict
541+
return [AXNode.from_json(i) for i in json['nodes']]
542+
543+
544+
def get_child_ax_nodes(
545+
id_: AXNodeId,
546+
frame_id: typing.Optional[page.FrameId] = None
547+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[AXNode]]:
548+
'''
549+
Fetches a particular accessibility node by AXNodeId.
550+
Requires ``enable()`` to have been called previously.
551+
552+
**EXPERIMENTAL**
553+
554+
:param id_:
555+
:param frame_id: *(Optional)* The frame in whose document the node resides. If omitted, the root frame is used.
556+
:returns:
557+
'''
558+
params: T_JSON_DICT = dict()
559+
params['id'] = id_.to_json()
560+
if frame_id is not None:
561+
params['frameId'] = frame_id.to_json()
562+
cmd_dict: T_JSON_DICT = {
563+
'method': 'Accessibility.getChildAXNodes',
564+
'params': params,
565+
}
566+
json = yield cmd_dict
567+
return [AXNode.from_json(i) for i in json['nodes']]
568+
569+
570+
def query_ax_tree(
571+
node_id: typing.Optional[dom.NodeId] = None,
572+
backend_node_id: typing.Optional[dom.BackendNodeId] = None,
573+
object_id: typing.Optional[runtime.RemoteObjectId] = None,
574+
accessible_name: typing.Optional[str] = None,
575+
role: typing.Optional[str] = None
576+
) -> typing.Generator[T_JSON_DICT,T_JSON_DICT,typing.List[AXNode]]:
577+
'''
578+
Query a DOM node's accessibility subtree for accessible name and role.
579+
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
581+
node is specified, or the DOM node does not exist, the command returns an error. If neither
582+
``accessibleName`` or ``role`` is specified, it returns all the accessibility nodes in the subtree.
583+
584+
**EXPERIMENTAL**
585+
586+
:param node_id: *(Optional)* Identifier of the node for the root to query.
587+
:param backend_node_id: *(Optional)* Identifier of the backend node for the root to query.
588+
:param object_id: *(Optional)* JavaScript object id of the node wrapper for the root to query.
589+
:param accessible_name: *(Optional)* Find nodes with this computed name.
590+
:param role: *(Optional)* Find nodes with this computed role.
591+
:returns: A list of ``Accessibility.AXNode`` matching the specified attributes, including nodes that are ignored for accessibility.
592+
'''
593+
params: T_JSON_DICT = dict()
594+
if node_id is not None:
595+
params['nodeId'] = node_id.to_json()
596+
if backend_node_id is not None:
597+
params['backendNodeId'] = backend_node_id.to_json()
598+
if object_id is not None:
599+
params['objectId'] = object_id.to_json()
600+
if accessible_name is not None:
601+
params['accessibleName'] = accessible_name
602+
if role is not None:
603+
params['role'] = role
604+
cmd_dict: T_JSON_DICT = {
605+
'method': 'Accessibility.queryAXTree',
606+
'params': params,
607+
}
608+
json = yield cmd_dict
609+
return [AXNode.from_json(i) for i in json['nodes']]
610+
611+
612+
@event_class('Accessibility.loadComplete')
613+
@dataclass
614+
class LoadComplete:
615+
'''
616+
**EXPERIMENTAL**
617+
618+
The loadComplete event mirrors the load complete event sent by the browser to assistive
619+
technology when the web page has finished loading.
620+
'''
621+
#: New document root node.
622+
root: AXNode
623+
624+
@classmethod
625+
def from_json(cls, json: T_JSON_DICT) -> LoadComplete:
626+
return cls(
627+
root=AXNode.from_json(json['root'])
628+
)
629+
630+
631+
@event_class('Accessibility.nodesUpdated')
632+
@dataclass
633+
class NodesUpdated:
634+
'''
635+
**EXPERIMENTAL**
636+
637+
The nodesUpdated event is sent every time a previously requested node has changed the in tree.
638+
'''
639+
#: Updated node data.
640+
nodes: typing.List[AXNode]
641+
642+
@classmethod
643+
def from_json(cls, json: T_JSON_DICT) -> NodesUpdated:
644+
return cls(
645+
nodes=[AXNode.from_json(i) for i in json['nodes']]
646+
)

0 commit comments

Comments
 (0)