Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ go:
- 1.7.x
- 1.6.x
- 1.5.x
- 1.4.x
# - 1.4.x disabled due to url decode bug in chrome 63

addons:
chrome: stable

before_script:
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 &
- while ! lsof -i :9222; do sleep 1; done

script:
- sleep 20
- go test -v
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# cri - chrome remote interface

[![GoDoc](https://godoc.org/github.com/SKatiyar/cri?status.svg)](https://godoc.org/github.com/SKatiyar/cri)
[![Go Report Card](https://goreportcard.com/badge/github.com/SKatiyar/cri)](https://goreportcard.com/report/github.com/SKatiyar/cri)
[![Go Report Card](https://travis-ci.org/SKatiyar/cri.svg?branch=master)](https://travis-ci.org/SKatiyar/cri)
[![GoDoc](https://godoc.org/github.com/skatiyar/cri?status.svg)](https://godoc.org/github.com/skatiyar/cri)
[![Go Report Card](https://goreportcard.com/badge/github.com/skatiyar/cri)](https://goreportcard.com/report/github.com/skatiyar/cri)
[![Go Report Card](https://travis-ci.org/skatiyar/cri.svg?branch=develop)](https://travis-ci.org/skatiyar/cri)

Package cri provides type-safe bindings for devtools protocol. It can be used with Chrome or any other target that implements the interface.

Expand All @@ -16,7 +16,7 @@ Tested with go1.4 and above.
### Install

```
go get -u github.com/SKatiyar/cri
go get -u github.com/skatiyar/cri
```

### Usage
Expand All @@ -31,9 +31,9 @@ import (
"fmt"
"io/ioutil"

"github.com/SKatiyar/cri"
"github.com/SKatiyar/cri/browser"
"github.com/SKatiyar/cri/page"
"github.com/skatiyar/cri"
"github.com/skatiyar/cri/browser"
"github.com/skatiyar/cri/page"
)

func main() {
Expand Down
16 changes: 10 additions & 6 deletions accessibility/commands.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
* CODE GENERATED AUTOMATICALLY WITH github.com/SKatiyar/cri/cmd/cri-gen
* CODE GENERATED AUTOMATICALLY WITH github.com/skatiyar/cri/cmd/cri-gen
* THIS FILE SHOULD NOT BE EDITED BY HAND
*/

// Package accessibility provides commands and events for Accessibility domain.
package accessibility

import (
"github.com/SKatiyar/cri"
types "github.com/SKatiyar/cri/types"
"github.com/skatiyar/cri"
types "github.com/skatiyar/cri/types"
)

// List of commands in Accessibility domain
Expand All @@ -26,14 +26,18 @@ func New(conn cri.Connector) *Accessibility {
}

type GetPartialAXTreeRequest struct {
// ID of node to get the partial accessibility tree for.
NodeId types.DOM_NodeId `json:"nodeId"`
// Identifier of the node to get the partial accessibility tree for.
NodeId *types.DOM_NodeId `json:"nodeId,omitempty"`
// Identifier of the backend node to get the partial accessibility tree for.
BackendNodeId *types.DOM_BackendNodeId `json:"backendNodeId,omitempty"`
// JavaScript object id of the node wrapper to get the partial accessibility tree for.
ObjectId *types.Runtime_RemoteObjectId `json:"objectId,omitempty"`
// Whether to fetch this nodes ancestors, siblings and children. Defaults to true.
FetchRelatives *bool `json:"fetchRelatives,omitempty"`
}

type GetPartialAXTreeResponse struct {
// The <code>Accessibility.AXNode</code> for this DOM node, if it exists, plus its ancestors, siblings and children, if requested.
// The `Accessibility.AXNode` for this DOM node, if it exists, plus its ancestors, siblings and children, if requested.
Nodes []types.Accessibility_AXNode `json:"nodes"`
}

Expand Down
192 changes: 93 additions & 99 deletions animation/commands.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
/*
* CODE GENERATED AUTOMATICALLY WITH github.com/SKatiyar/cri/cmd/cri-gen
* CODE GENERATED AUTOMATICALLY WITH github.com/skatiyar/cri/cmd/cri-gen
* THIS FILE SHOULD NOT BE EDITED BY HAND
*/

// Package animation provides commands and events for Animation domain.
package animation

import (
"github.com/SKatiyar/cri"
types "github.com/SKatiyar/cri/types"
"github.com/skatiyar/cri"
types "github.com/skatiyar/cri/types"
)

// List of commands in Animation domain
const (
Enable = "Animation.enable"
Disable = "Animation.disable"
GetPlaybackRate = "Animation.getPlaybackRate"
SetPlaybackRate = "Animation.setPlaybackRate"
Enable = "Animation.enable"
GetCurrentTime = "Animation.getCurrentTime"
SetPaused = "Animation.setPaused"
SetTiming = "Animation.setTiming"
SeekAnimations = "Animation.seekAnimations"
GetPlaybackRate = "Animation.getPlaybackRate"
ReleaseAnimations = "Animation.releaseAnimations"
ResolveAnimation = "Animation.resolveAnimation"
SeekAnimations = "Animation.seekAnimations"
SetPaused = "Animation.setPaused"
SetPlaybackRate = "Animation.setPlaybackRate"
SetTiming = "Animation.setTiming"
)

// List of events in Animation domain
const (
AnimationCanceled = "Animation.animationCanceled"
AnimationCreated = "Animation.animationCreated"
AnimationStarted = "Animation.animationStarted"
AnimationCanceled = "Animation.animationCanceled"
)

type Animation struct {
Expand All @@ -41,37 +41,15 @@ func New(conn cri.Connector) *Animation {
return &Animation{conn}
}

// Enables animation domain notifications.
func (obj *Animation) Enable() (err error) {
err = obj.conn.Send(Enable, nil, nil)
return
}

// Disables animation domain notifications.
func (obj *Animation) Disable() (err error) {
err = obj.conn.Send(Disable, nil, nil)
return
}

type GetPlaybackRateResponse struct {
// Playback rate for animations on page.
PlaybackRate float32 `json:"playbackRate"`
}

// Gets the playback rate of the document timeline.
func (obj *Animation) GetPlaybackRate() (response GetPlaybackRateResponse, err error) {
err = obj.conn.Send(GetPlaybackRate, nil, &response)
return
}

type SetPlaybackRateRequest struct {
// Playback rate for animations on page
PlaybackRate float32 `json:"playbackRate"`
}

// Sets the playback rate of the document timeline.
func (obj *Animation) SetPlaybackRate(request *SetPlaybackRateRequest) (err error) {
err = obj.conn.Send(SetPlaybackRate, request, nil)
// Enables animation domain notifications.
func (obj *Animation) Enable() (err error) {
err = obj.conn.Send(Enable, nil, nil)
return
}

Expand All @@ -91,31 +69,41 @@ func (obj *Animation) GetCurrentTime(request *GetCurrentTimeRequest) (response G
return
}

type SetPausedRequest struct {
// Animations to set the pause state of.
type GetPlaybackRateResponse struct {
// Playback rate for animations on page.
PlaybackRate float32 `json:"playbackRate"`
}

// Gets the playback rate of the document timeline.
func (obj *Animation) GetPlaybackRate() (response GetPlaybackRateResponse, err error) {
err = obj.conn.Send(GetPlaybackRate, nil, &response)
return
}

type ReleaseAnimationsRequest struct {
// List of animation ids to seek.
Animations []string `json:"animations"`
// Paused state to set to.
Paused bool `json:"paused"`
}

// Sets the paused state of a set of animations.
func (obj *Animation) SetPaused(request *SetPausedRequest) (err error) {
err = obj.conn.Send(SetPaused, request, nil)
// Releases a set of animations to no longer be manipulated.
func (obj *Animation) ReleaseAnimations(request *ReleaseAnimationsRequest) (err error) {
err = obj.conn.Send(ReleaseAnimations, request, nil)
return
}

type SetTimingRequest struct {
type ResolveAnimationRequest struct {
// Animation id.
AnimationId string `json:"animationId"`
// Duration of the animation.
Duration float32 `json:"duration"`
// Delay of the animation.
Delay float32 `json:"delay"`
}

// Sets the timing of an animation node.
func (obj *Animation) SetTiming(request *SetTimingRequest) (err error) {
err = obj.conn.Send(SetTiming, request, nil)
type ResolveAnimationResponse struct {
// Corresponding remote object.
RemoteObject types.Runtime_RemoteObject `json:"remoteObject"`
}

// Gets the remote object of the Animation.
func (obj *Animation) ResolveAnimation(request *ResolveAnimationRequest) (response ResolveAnimationResponse, err error) {
err = obj.conn.Send(ResolveAnimation, request, &response)
return
}

Expand All @@ -132,91 +120,97 @@ func (obj *Animation) SeekAnimations(request *SeekAnimationsRequest) (err error)
return
}

type ReleaseAnimationsRequest struct {
// List of animation ids to seek.
type SetPausedRequest struct {
// Animations to set the pause state of.
Animations []string `json:"animations"`
// Paused state to set to.
Paused bool `json:"paused"`
}

// Releases a set of animations to no longer be manipulated.
func (obj *Animation) ReleaseAnimations(request *ReleaseAnimationsRequest) (err error) {
err = obj.conn.Send(ReleaseAnimations, request, nil)
// Sets the paused state of a set of animations.
func (obj *Animation) SetPaused(request *SetPausedRequest) (err error) {
err = obj.conn.Send(SetPaused, request, nil)
return
}

type ResolveAnimationRequest struct {
// Animation id.
AnimationId string `json:"animationId"`
type SetPlaybackRateRequest struct {
// Playback rate for animations on page
PlaybackRate float32 `json:"playbackRate"`
}

type ResolveAnimationResponse struct {
// Corresponding remote object.
RemoteObject types.Runtime_RemoteObject `json:"remoteObject"`
// Sets the playback rate of the document timeline.
func (obj *Animation) SetPlaybackRate(request *SetPlaybackRateRequest) (err error) {
err = obj.conn.Send(SetPlaybackRate, request, nil)
return
}

// Gets the remote object of the Animation.
func (obj *Animation) ResolveAnimation(request *ResolveAnimationRequest) (response ResolveAnimationResponse, err error) {
err = obj.conn.Send(ResolveAnimation, request, &response)
type SetTimingRequest struct {
// Animation id.
AnimationId string `json:"animationId"`
// Duration of the animation.
Duration float32 `json:"duration"`
// Delay of the animation.
Delay float32 `json:"delay"`
}

// Sets the timing of an animation node.
func (obj *Animation) SetTiming(request *SetTimingRequest) (err error) {
err = obj.conn.Send(SetTiming, request, nil)
return
}

type AnimationCreatedParams struct {
// Id of the animation that was created.
type AnimationCanceledParams struct {
// Id of the animation that was cancelled.
Id string `json:"id"`
}

// Event for each animation that has been created.
func (obj *Animation) AnimationCreated(fn func(params *AnimationCreatedParams, err error) bool) {
closeChn := make(chan struct{})
decoder := obj.conn.On(AnimationCreated, closeChn)
// Event for when an animation has been cancelled.
func (obj *Animation) AnimationCanceled(fn func(event string, params AnimationCanceledParams, err error) bool) {
listen, closer := obj.conn.On(AnimationCanceled)
go func() {
defer closer()
for {
params := AnimationCreatedParams{}
readErr := decoder(&params)
if !fn(&params, readErr) {
close(closeChn)
break
var params AnimationCanceledParams
if !fn(AnimationCanceled, params, listen(&params)) {
return
}
}
}()
}

type AnimationStartedParams struct {
// Animation that was started.
Animation types.Animation_Animation `json:"animation"`
type AnimationCreatedParams struct {
// Id of the animation that was created.
Id string `json:"id"`
}

// Event for animation that has been started.
func (obj *Animation) AnimationStarted(fn func(params *AnimationStartedParams, err error) bool) {
closeChn := make(chan struct{})
decoder := obj.conn.On(AnimationStarted, closeChn)
// Event for each animation that has been created.
func (obj *Animation) AnimationCreated(fn func(event string, params AnimationCreatedParams, err error) bool) {
listen, closer := obj.conn.On(AnimationCreated)
go func() {
defer closer()
for {
params := AnimationStartedParams{}
readErr := decoder(&params)
if !fn(&params, readErr) {
close(closeChn)
break
var params AnimationCreatedParams
if !fn(AnimationCreated, params, listen(&params)) {
return
}
}
}()
}

type AnimationCanceledParams struct {
// Id of the animation that was cancelled.
Id string `json:"id"`
type AnimationStartedParams struct {
// Animation that was started.
Animation types.Animation_Animation `json:"animation"`
}

// Event for when an animation has been cancelled.
func (obj *Animation) AnimationCanceled(fn func(params *AnimationCanceledParams, err error) bool) {
closeChn := make(chan struct{})
decoder := obj.conn.On(AnimationCanceled, closeChn)
// Event for animation that has been started.
func (obj *Animation) AnimationStarted(fn func(event string, params AnimationStartedParams, err error) bool) {
listen, closer := obj.conn.On(AnimationStarted)
go func() {
defer closer()
for {
params := AnimationCanceledParams{}
readErr := decoder(&params)
if !fn(&params, readErr) {
close(closeChn)
break
var params AnimationStartedParams
if !fn(AnimationStarted, params, listen(&params)) {
return
}
}
}()
Expand Down
Loading