use listeners for all command responses

Adding command response messages to the Listen API has one big
advantage; we can drop all the respByID code, and instead have both
Execute functions set up a listener to wait for the right response.

This also greatly simplifies cmdQueue, as it can now simply contain the
message to write over the transport.

This change does make the Execute functions slightly more expensive, as
they need to set up a context and a listener. However, we don't expect
that users will run thousands of actions at once on a single target, so
that's a non-issue.

Finally, this change requires listeners to be run asynchronously, as
otherwise the target handler can deadlock itself. That's an OK change to
make, as the documentation makes no promises about how Listen callbacks
work.
2 files changed
tree: 195f34db5deb0643e0f2b2b1eb7cc0b5e79eda8a
  1. .github/
  2. kb/
  3. testdata/
  4. .gitignore
  5. .travis.yml
  6. allocate.go
  7. allocate_linux.go
  8. allocate_other.go
  9. allocate_test.go
  10. browser.go
  11. browser_easyjson.go
  12. chromedp.go
  13. chromedp_test.go
  14. conn.go
  15. errors.go
  16. eval.go
  17. event_test.go
  18. example_test.go
  19. go.mod
  20. go.sum
  21. input.go
  22. input_test.go
  23. js.go
  24. LICENSE
  25. nav.go
  26. nav_test.go
  27. query.go
  28. query_test.go
  29. README.md
  30. sel.go
  31. sel_test.go
  32. target.go
  33. util.go
README.md

About chromedp GoDoc Build Status

Package chromedp is a faster, simpler way to drive browsers supporting the Chrome DevTools Protocol in Go using the without external dependencies (like Selenium or PhantomJS).

Installing

Install in the usual Go way:

go get -u github.com/chromedp/chromedp

Examples

Refer to the GoDoc page for the documentation and examples. The examples repository contains more complex scenarios.

Resources