The first would fail as we'd decrement the WaitGroup before adding to
it, and the escond would fail with a nil pointer dereference panic.
Add tests to reproduce both, and fix them.
For example, this can be useful if a user wants to simply add one flag
of their own, without otherwise messing with the default flags. In the
old codebase, they'd either have to build their own list from scratch,
or copy ours from source, needing to keep it in sync.
The correct way to use Run is after NewContext. Using NewExecAllocator
only, which also gives a context, almost worked. This confused some
users into thinking it was a bug in chromedp.
Instead, error immediately with an invalid context error.
Fixes#299.
That way, cancelling a context while checking the error is much simpler.
The context data already holds onto the cancel func, so this requires no
internal changes.
This renders the Browser.Shutdown API obsolete, even though it doesn't
do exactly the same. If we want Cancel to do a proper shutdown action
before cancelling a browser context and killing the process, we could do
that change within the cancel logic.
Adds the high level WithDebugf() context option, and associated lower
level browser and dial options for setting a protocol wire debugger.
Additionally changes the conn.Conn.Read/Write implementations to be more
efficient, using direct easyjson.{Marshal,Unmarshal} calls and logging
to debug func when available.
While at it, remove the error return from BrowserOption, to make it
consistent with all the other option func types.
We don't have a good test for this feature yet, but at least we check
that it doesn't crash or error via an example.
Fixes#292.
First, we want all of the functionality in a single package; this means
collapsing whatever is useful into the root chromedp package.
The runner package is being replaced by the Allocator interface, with a
default implementation which starts browser processes.
The client package doesn't really have a place in the new design. The
context, allocator, and browser types will handle the connection with
each browser.
Finally, the new API is context-based, hence the addition of context.go.
The tests have been modified to build and run against the new API.
There's no need to put the error variables in a larger scope, nor define
them earlier than necessary. If anything, it makes the code harder to
follow, such as figuring out when nil errors are returned.
1. Changes travis configuration to use the chrome addon
2. Adds more command line options to runner package
3. Removes grab-headless_shell.sh script
4. Cleans up and adds some environment variables for controlling how
unit tests are ran
5. Fixes a minor issue in chromedp-gen on comment output (for working
with latest protocol definition)