Skip to content

Commit

Permalink
actually download new protocol files, fix flakey test
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Oct 16, 2024
1 parent 8ac64a5 commit 7f44d39
Show file tree
Hide file tree
Showing 37 changed files with 2,550 additions and 462 deletions.
32 changes: 5 additions & 27 deletions v2/gcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,35 +481,13 @@ func TestConnectToInstance(t *testing.T) {
testDefaultStartup(t)
defer debugger.ExitProcess()

doneCh := make(chan error)

go testTimeoutListener(doneCh, 15, "timed out waiting for remote connection")

go func() {
remoteDebugger := NewChromeDebugger()
remoteDebugger.ConnectToInstance(debugger.host, debugger.port)

_, err := remoteDebugger.NewTab()
if err != nil {
t.Fatalf("error creating new tab")
}
remoteDebugger := NewChromeDebugger()
t.Logf("connecting to %s:%s", debugger.host, debugger.port)
remoteDebugger.ConnectToInstance(debugger.host, debugger.port)

targets, error := remoteDebugger.GetTargets()
if error != nil {
t.Fatalf("cannot get targets: %s \n", error)
}
if len(targets) <= 0 {
t.Fatalf("invalid number of targets, got: %d\n", len(targets))
}
for _, target := range targets {
t.Logf("page: %s\n", target.Target.Url)
}
close(doneCh)
}()

err := <-doneCh
_, err := remoteDebugger.NewTab()
if err != nil {
t.Fatal(err)
t.Fatalf("error creating new tab")
}
}

Expand Down
12 changes: 6 additions & 6 deletions v2/gcdapi/accessibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type AccessibilityAXValueSource struct {
Attribute string `json:"attribute,omitempty"` // The name of the relevant attribute, if any.
AttributeValue *AccessibilityAXValue `json:"attributeValue,omitempty"` // The value of the relevant attribute, if any.
Superseded bool `json:"superseded,omitempty"` // Whether this source is superseded by a higher priority source.
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
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
NativeSourceValue *AccessibilityAXValue `json:"nativeSourceValue,omitempty"` // The value, such as a node or node list, of the native source.
Invalid bool `json:"invalid,omitempty"` // Whether the value for this property is invalid.
InvalidReason string `json:"invalidReason,omitempty"` // Reason for the value being invalid, if it is.
Expand All @@ -31,7 +31,7 @@ type AccessibilityAXRelatedNode struct {

// No Description.
type AccessibilityAXProperty struct {
Name string `json:"name"` // The name of this property. enum values: busy, disabled, editable, focusable, focused, hidden, hiddenRoot, invalid, keyshortcuts, settable, roledescription, live, atomic, relevant, root, autocomplete, hasPopup, level, multiselectable, orientation, multiline, readonly, required, valuemin, valuemax, valuetext, checked, expanded, modal, pressed, selected, activedescendant, controls, describedby, details, errormessage, flowto, labelledby, owns
Name string `json:"name"` // The name of this property. enum values: busy, disabled, editable, focusable, focused, hidden, hiddenRoot, invalid, keyshortcuts, settable, roledescription, live, atomic, relevant, root, autocomplete, hasPopup, level, multiselectable, orientation, multiline, readonly, required, valuemin, valuemax, valuetext, checked, expanded, modal, pressed, selected, activedescendant, controls, describedby, details, errormessage, flowto, labelledby, owns, url
Value *AccessibilityAXValue `json:"value"` // The value of this property.
}

Expand Down Expand Up @@ -154,7 +154,7 @@ func (c *Accessibility) GetPartialAXTree(ctx context.Context, nodeId int, backen
type AccessibilityGetFullAXTreeParams struct {
// The maximum depth at which descendants of the root node should be retrieved. If omitted, the full tree is returned.
Depth int `json:"depth,omitempty"`
// The frame for whose document the AX tree should be retrieved. If omited, the root frame is used.
// The frame for whose document the AX tree should be retrieved. If omitted, the root frame is used.
FrameId string `json:"frameId,omitempty"`
}

Expand Down Expand Up @@ -190,7 +190,7 @@ func (c *Accessibility) GetFullAXTreeWithParams(ctx context.Context, v *Accessib

// GetFullAXTree - Fetches the entire accessibility tree for the root Document
// depth - The maximum depth at which descendants of the root node should be retrieved. If omitted, the full tree is returned.
// frameId - The frame for whose document the AX tree should be retrieved. If omited, the root frame is used.
// frameId - The frame for whose document the AX tree should be retrieved. If omitted, the root frame is used.
// Returns - nodes -
func (c *Accessibility) GetFullAXTree(ctx context.Context, depth int, frameId string) ([]*AccessibilityAXNode, error) {
var v AccessibilityGetFullAXTreeParams
Expand Down Expand Up @@ -356,7 +356,7 @@ type AccessibilityQueryAXTreeParams struct {
Role string `json:"role,omitempty"`
}

// QueryAXTreeWithParams - Query a DOM node's accessibility subtree for accessible name and role. This command computes the name and role for all nodes in the subtree, including those that are ignored for accessibility, and returns those that mactch the specified name and role. If no DOM node is specified, or the DOM node does not exist, the command returns an error. If neither `accessibleName` or `role` is specified, it returns all the accessibility nodes in the subtree.
// QueryAXTreeWithParams - Query a DOM node's accessibility subtree for accessible name and role. This command computes the name and role for all nodes in the subtree, including those that are ignored for accessibility, and returns those that match the specified name and role. If no DOM node is specified, or the DOM node does not exist, the command returns an error. If neither `accessibleName` or `role` is specified, it returns all the accessibility nodes in the subtree.
// Returns - nodes - A list of `Accessibility.AXNode` matching the specified attributes, including nodes that are ignored for accessibility.
func (c *Accessibility) QueryAXTreeWithParams(ctx context.Context, v *AccessibilityQueryAXTreeParams) ([]*AccessibilityAXNode, error) {
resp, err := c.target.SendCustomReturn(ctx, &gcdmessage.ParamRequest{Id: c.target.GetId(), Method: "Accessibility.queryAXTree", Params: v})
Expand Down Expand Up @@ -386,7 +386,7 @@ func (c *Accessibility) QueryAXTreeWithParams(ctx context.Context, v *Accessibil
return chromeData.Result.Nodes, nil
}

// QueryAXTree - Query a DOM node's accessibility subtree for accessible name and role. This command computes the name and role for all nodes in the subtree, including those that are ignored for accessibility, and returns those that mactch the specified name and role. If no DOM node is specified, or the DOM node does not exist, the command returns an error. If neither `accessibleName` or `role` is specified, it returns all the accessibility nodes in the subtree.
// QueryAXTree - Query a DOM node's accessibility subtree for accessible name and role. This command computes the name and role for all nodes in the subtree, including those that are ignored for accessibility, and returns those that match the specified name and role. If no DOM node is specified, or the DOM node does not exist, the command returns an error. If neither `accessibleName` or `role` is specified, it returns all the accessibility nodes in the subtree.
// nodeId - Identifier of the node for the root to query.
// backendNodeId - Identifier of the backend node for the root to query.
// objectId - JavaScript object id of the node wrapper for the root to query.
Expand Down
40 changes: 29 additions & 11 deletions v2/gcdapi/animation.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,26 @@ import (

// Animation instance.
type AnimationAnimation struct {
Id string `json:"id"` // `Animation`'s id.
Name string `json:"name"` // `Animation`'s name.
PausedState bool `json:"pausedState"` // `Animation`'s internal paused state.
PlayState string `json:"playState"` // `Animation`'s play state.
PlaybackRate float64 `json:"playbackRate"` // `Animation`'s playback rate.
StartTime float64 `json:"startTime"` // `Animation`'s start time.
CurrentTime float64 `json:"currentTime"` // `Animation`'s current time.
Type string `json:"type"` // Animation type of `Animation`.
Source *AnimationAnimationEffect `json:"source,omitempty"` // `Animation`'s source animation node.
CssId string `json:"cssId,omitempty"` // A unique ID for `Animation` representing the sources that triggered this CSS animation/transition.
Id string `json:"id"` // `Animation`'s id.
Name string `json:"name"` // `Animation`'s name.
PausedState bool `json:"pausedState"` // `Animation`'s internal paused state.
PlayState string `json:"playState"` // `Animation`'s play state.
PlaybackRate float64 `json:"playbackRate"` // `Animation`'s playback rate.
StartTime float64 `json:"startTime"` // `Animation`'s start time. Milliseconds for time based animations and percentage [0 - 100] for scroll driven animations (i.e. when viewOrScrollTimeline exists).
CurrentTime float64 `json:"currentTime"` // `Animation`'s current time.
Type string `json:"type"` // Animation type of `Animation`.
Source *AnimationAnimationEffect `json:"source,omitempty"` // `Animation`'s source animation node.
CssId string `json:"cssId,omitempty"` // A unique ID for `Animation` representing the sources that triggered this CSS animation/transition.
ViewOrScrollTimeline *AnimationViewOrScrollTimeline `json:"viewOrScrollTimeline,omitempty"` // View or scroll timeline
}

// Timeline instance
type AnimationViewOrScrollTimeline struct {
SourceNodeId int `json:"sourceNodeId,omitempty"` // Scroll container node
StartOffset float64 `json:"startOffset,omitempty"` // Represents the starting scroll position of the timeline as a length offset in pixels from scroll origin.
EndOffset float64 `json:"endOffset,omitempty"` // Represents the ending scroll position of the timeline as a length offset in pixels from scroll origin.
SubjectNodeId int `json:"subjectNodeId,omitempty"` // The element whose principal box's visibility in the scrollport defined the progress of the timeline. Does not exist for animations with ScrollTimeline
Axis string `json:"axis"` // Orientation of the scroll enum values: horizontal, vertical
}

// AnimationEffect instance
Expand All @@ -29,7 +39,7 @@ type AnimationAnimationEffect struct {
EndDelay float64 `json:"endDelay"` // `AnimationEffect`'s end delay.
IterationStart float64 `json:"iterationStart"` // `AnimationEffect`'s iteration start.
Iterations float64 `json:"iterations"` // `AnimationEffect`'s iterations.
Duration float64 `json:"duration"` // `AnimationEffect`'s iteration duration.
Duration float64 `json:"duration"` // `AnimationEffect`'s iteration duration. Milliseconds for time based animations and percentage [0 - 100] for scroll driven animations (i.e. when viewOrScrollTimeline exists).
Direction string `json:"direction"` // `AnimationEffect`'s playback direction.
Fill string `json:"fill"` // `AnimationEffect`'s fill mode.
BackendNodeId int `json:"backendNodeId,omitempty"` // `AnimationEffect`'s target node.
Expand Down Expand Up @@ -73,6 +83,14 @@ type AnimationAnimationStartedEvent struct {
} `json:"Params,omitempty"`
}

// Event for animation that has been updated.
type AnimationAnimationUpdatedEvent struct {
Method string `json:"method"`
Params struct {
Animation *AnimationAnimation `json:"animation"` // Animation that was updated.
} `json:"Params,omitempty"`
}

type Animation struct {
target gcdmessage.ChromeTargeter
}
Expand Down
Loading

0 comments on commit 7f44d39

Please sign in to comment.