Skip to content

Commit ea3da70

Browse files
authored
Merge pull request #58 from wirepair/update_protocol_20211127
bump protocol.json
2 parents 099a6ae + d1ef162 commit ea3da70

24 files changed

+912
-287
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Changelog (2021)
2+
- 2.2.4 (November 27th) Upgrade protocol.json to 96.0.4664.45
23
- 2.2.3 (August 23rd) Applied patch from @camswords to allow using custom output writer for chrome process to aid in debugging.
34
- 2.2.2 (August 19th) Applied patch from @camswords to fix the cannot connect to debugger message to print seconds out properly.
45
- 2.2.1 (July 28th) SendDefaultRequests were not returning ChromeErrorResponses

v2/chrome_target.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
The MIT License (MIT)
33
4-
Copyright (c) 2020 isaac dawson
4+
Copyright (c) 2021 isaac dawson
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal
@@ -118,6 +118,7 @@ type ChromeTarget struct {
118118
Media *gcdapi.Media
119119
WebAudio *gcdapi.WebAudio
120120
WebAuthn *gcdapi.WebAuthn
121+
EventBreakpoints *gcdapi.EventBreakpoints
121122

122123
Target *TargetInfo // The target information see, TargetInfo
123124
sendCh chan *gcdmessage.Message // The channel used for API components to send back to use
@@ -207,6 +208,7 @@ func (c *ChromeTarget) Init() {
207208
c.WebAudio = gcdapi.NewWebAudio(c)
208209
c.WebAuthn = gcdapi.NewWebAuthn(c)
209210
c.BackgroundService = gcdapi.NewBackgroundService(c)
211+
c.EventBreakpoints = gcdapi.NewEventBreakpoints(c)
210212
}
211213

212214
// clean up this target

v2/gcd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import (
4545

4646
var json = jsoniter.ConfigCompatibleWithStandardLibrary
4747

48-
var GCDVERSION = "v2.2.3"
48+
var GCDVERSION = "v2.2.4"
4949

5050
var (
5151
ErrNoTabAvailable = errors.New("no available tab found")

v2/gcdapi/accessibility.go

Lines changed: 134 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type AccessibilityAXValueSource struct {
1616
Attribute string `json:"attribute,omitempty"` // The name of the relevant attribute, if any.
1717
AttributeValue *AccessibilityAXValue `json:"attributeValue,omitempty"` // The value of the relevant attribute, if any.
1818
Superseded bool `json:"superseded,omitempty"` // Whether this source is superseded by a higher priority source.
19-
NativeSource string `json:"nativeSource,omitempty"` // The native markup source for this value, e.g. a <label> element. enum values: figcaption, label, labelfor, labelwrapped, legend, rubyannotation, tablecaption, title, other
19+
NativeSource string `json:"nativeSource,omitempty"` // The native markup source for this value, e.g. a <label> element. enum values: description, figcaption, label, labelfor, labelwrapped, legend, rubyannotation, tablecaption, title, other
2020
NativeSourceValue *AccessibilityAXValue `json:"nativeSourceValue,omitempty"` // The value, such as a node or node list, of the native source.
2121
Invalid bool `json:"invalid,omitempty"` // Whether the value for this property is invalid.
2222
InvalidReason string `json:"invalidReason,omitempty"` // Reason for the value being invalid, if it is.
@@ -53,8 +53,26 @@ type AccessibilityAXNode struct {
5353
Description *AccessibilityAXValue `json:"description,omitempty"` // The accessible description for this `Node`.
5454
Value *AccessibilityAXValue `json:"value,omitempty"` // The value for this `Node`.
5555
Properties []*AccessibilityAXProperty `json:"properties,omitempty"` // All other properties
56+
ParentId string `json:"parentId,omitempty"` // ID for this node's parent.
5657
ChildIds []string `json:"childIds,omitempty"` // IDs for each of this node's child nodes.
5758
BackendDOMNodeId int `json:"backendDOMNodeId,omitempty"` // The backend ID for the associated DOM node, if any.
59+
FrameId string `json:"frameId,omitempty"` // The frame ID for the frame associated with this nodes document.
60+
}
61+
62+
// The loadComplete event mirrors the load complete event sent by the browser to assistive technology when the web page has finished loading.
63+
type AccessibilityLoadCompleteEvent struct {
64+
Method string `json:"method"`
65+
Params struct {
66+
Root *AccessibilityAXNode `json:"root"` // New document root node.
67+
} `json:"Params,omitempty"`
68+
}
69+
70+
// The nodesUpdated event is sent every time a previously requested node has changed the in tree.
71+
type AccessibilityNodesUpdatedEvent struct {
72+
Method string `json:"method"`
73+
Params struct {
74+
Nodes []*AccessibilityAXNode `json:"nodes"` // Updated node data.
75+
} `json:"Params,omitempty"`
5876
}
5977

6078
type Accessibility struct {
@@ -136,7 +154,11 @@ func (c *Accessibility) GetPartialAXTree(ctx context.Context, nodeId int, backen
136154

137155
type AccessibilityGetFullAXTreeParams struct {
138156
// The maximum depth at which descendants of the root node should be retrieved. If omitted, the full tree is returned.
157+
Depth int `json:"depth,omitempty"`
158+
// Deprecated. This parameter has been renamed to `depth`. If depth is not provided, max_depth will be used.
139159
Max_depth int `json:"max_depth,omitempty"`
160+
// The frame for whose document the AX tree should be retrieved. If omited, the root frame is used.
161+
FrameId string `json:"frameId,omitempty"`
140162
}
141163

142164
// GetFullAXTreeWithParams - Fetches the entire accessibility tree for the root Document
@@ -172,17 +194,123 @@ func (c *Accessibility) GetFullAXTreeWithParams(ctx context.Context, v *Accessib
172194
}
173195

174196
// GetFullAXTree - Fetches the entire accessibility tree for the root Document
175-
// max_depth - The maximum depth at which descendants of the root node should be retrieved. If omitted, the full tree is returned.
197+
// depth - The maximum depth at which descendants of the root node should be retrieved. If omitted, the full tree is returned.
198+
// max_depth - Deprecated. This parameter has been renamed to `depth`. If depth is not provided, max_depth will be used.
199+
// frameId - The frame for whose document the AX tree should be retrieved. If omited, the root frame is used.
176200
// Returns - nodes -
177-
func (c *Accessibility) GetFullAXTree(ctx context.Context, max_depth int) ([]*AccessibilityAXNode, error) {
201+
func (c *Accessibility) GetFullAXTree(ctx context.Context, depth int, max_depth int, frameId string) ([]*AccessibilityAXNode, error) {
178202
var v AccessibilityGetFullAXTreeParams
203+
v.Depth = depth
179204
v.Max_depth = max_depth
205+
v.FrameId = frameId
180206
return c.GetFullAXTreeWithParams(ctx, &v)
181207
}
182208

209+
type AccessibilityGetRootAXNodeParams struct {
210+
// The frame in whose document the node resides. If omitted, the root frame is used.
211+
FrameId string `json:"frameId,omitempty"`
212+
}
213+
214+
// GetRootAXNodeWithParams - Fetches the root node. Requires `enable()` to have been called previously.
215+
// Returns - node -
216+
func (c *Accessibility) GetRootAXNodeWithParams(ctx context.Context, v *AccessibilityGetRootAXNodeParams) (*AccessibilityAXNode, error) {
217+
resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Accessibility.getRootAXNode", Params: v})
218+
if err != nil {
219+
return nil, err
220+
}
221+
222+
var chromeData struct {
223+
Result struct {
224+
Node *AccessibilityAXNode
225+
}
226+
}
227+
228+
if resp == nil {
229+
return nil, &gcdmessage.ChromeEmptyResponseErr{}
230+
}
231+
232+
// test if error first
233+
cerr := &gcdmessage.ChromeErrorResponse{}
234+
json.Unmarshal(resp.Data, cerr)
235+
if cerr != nil && cerr.Error != nil {
236+
return nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
237+
}
238+
239+
if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
240+
return nil, err
241+
}
242+
243+
return chromeData.Result.Node, nil
244+
}
245+
246+
// GetRootAXNode - Fetches the root node. Requires `enable()` to have been called previously.
247+
// frameId - The frame in whose document the node resides. If omitted, the root frame is used.
248+
// Returns - node -
249+
func (c *Accessibility) GetRootAXNode(ctx context.Context, frameId string) (*AccessibilityAXNode, error) {
250+
var v AccessibilityGetRootAXNodeParams
251+
v.FrameId = frameId
252+
return c.GetRootAXNodeWithParams(ctx, &v)
253+
}
254+
255+
type AccessibilityGetAXNodeAndAncestorsParams struct {
256+
// Identifier of the node to get.
257+
NodeId int `json:"nodeId,omitempty"`
258+
// Identifier of the backend node to get.
259+
BackendNodeId int `json:"backendNodeId,omitempty"`
260+
// JavaScript object id of the node wrapper to get.
261+
ObjectId string `json:"objectId,omitempty"`
262+
}
263+
264+
// GetAXNodeAndAncestorsWithParams - Fetches a node and all ancestors up to and including the root. Requires `enable()` to have been called previously.
265+
// Returns - nodes -
266+
func (c *Accessibility) GetAXNodeAndAncestorsWithParams(ctx context.Context, v *AccessibilityGetAXNodeAndAncestorsParams) ([]*AccessibilityAXNode, error) {
267+
resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Accessibility.getAXNodeAndAncestors", Params: v})
268+
if err != nil {
269+
return nil, err
270+
}
271+
272+
var chromeData struct {
273+
Result struct {
274+
Nodes []*AccessibilityAXNode
275+
}
276+
}
277+
278+
if resp == nil {
279+
return nil, &gcdmessage.ChromeEmptyResponseErr{}
280+
}
281+
282+
// test if error first
283+
cerr := &gcdmessage.ChromeErrorResponse{}
284+
json.Unmarshal(resp.Data, cerr)
285+
if cerr != nil && cerr.Error != nil {
286+
return nil, &gcdmessage.ChromeRequestErr{Resp: cerr}
287+
}
288+
289+
if err := json.Unmarshal(resp.Data, &chromeData); err != nil {
290+
return nil, err
291+
}
292+
293+
return chromeData.Result.Nodes, nil
294+
}
295+
296+
// GetAXNodeAndAncestors - Fetches a node and all ancestors up to and including the root. Requires `enable()` to have been called previously.
297+
// nodeId - Identifier of the node to get.
298+
// backendNodeId - Identifier of the backend node to get.
299+
// objectId - JavaScript object id of the node wrapper to get.
300+
// Returns - nodes -
301+
func (c *Accessibility) GetAXNodeAndAncestors(ctx context.Context, nodeId int, backendNodeId int, objectId string) ([]*AccessibilityAXNode, error) {
302+
var v AccessibilityGetAXNodeAndAncestorsParams
303+
v.NodeId = nodeId
304+
v.BackendNodeId = backendNodeId
305+
v.ObjectId = objectId
306+
return c.GetAXNodeAndAncestorsWithParams(ctx, &v)
307+
}
308+
183309
type AccessibilityGetChildAXNodesParams struct {
184310
//
185311
Id string `json:"id"`
312+
// The frame in whose document the node resides. If omitted, the root frame is used.
313+
FrameId string `json:"frameId,omitempty"`
186314
}
187315

188316
// GetChildAXNodesWithParams - Fetches a particular accessibility node by AXNodeId. Requires `enable()` to have been called previously.
@@ -219,10 +347,12 @@ func (c *Accessibility) GetChildAXNodesWithParams(ctx context.Context, v *Access
219347

220348
// GetChildAXNodes - Fetches a particular accessibility node by AXNodeId. Requires `enable()` to have been called previously.
221349
// id -
350+
// frameId - The frame in whose document the node resides. If omitted, the root frame is used.
222351
// Returns - nodes -
223-
func (c *Accessibility) GetChildAXNodes(ctx context.Context, id string) ([]*AccessibilityAXNode, error) {
352+
func (c *Accessibility) GetChildAXNodes(ctx context.Context, id string, frameId string) ([]*AccessibilityAXNode, error) {
224353
var v AccessibilityGetChildAXNodesParams
225354
v.Id = id
355+
v.FrameId = frameId
226356
return c.GetChildAXNodesWithParams(ctx, &v)
227357
}
228358

0 commit comments

Comments
 (0)