Commit Graph

5 Commits

Author SHA1 Message Date
Daniel Martí
939d377090 avoid hanging when Chrome is closed separately
It's Run that actually starts a Browser, not NewContext. If the browser
is closed or crashes, the browser handler will fail to read from the
websocket, and its goroutines will stop.

However, the target handler's goroutines may not stop. The browser
handler uses a separate cancel function to stop itself when encountering
a websocket error, so that doesn't propagate to the original context
children, like the target handler.

To fix this, make it so that NewContext can keep the cancel function
around, for Run to use it in this scenario. And add a test case that
tests this very edge case, which used to time out before the fix.

Fixes #289.
2019-04-07 19:28:41 +02:00
Daniel Martí
b977e305d2 fix regression when using Run twice on the first ctx
We don't want to always set c.first, as that can change the field from
true to false.
2019-04-07 18:49:53 +02:00
Daniel Martí
c41ed01b6a close a page when cancelling its context
For all contexts except the first browser context, as in that case the
allocator and browser handler already take care of shutting down the
process and goroutines, respectively.

Fixes #293.
2019-04-07 14:22:07 +02:00
Daniel Martí
c313fa1c1d add TargetID to Target
This will be useful later on, for example to be able to close a target
(a page) once it gets cancelled.
2019-04-07 13:37:32 +02:00
Daniel Martí
b647c708b4 don't create an extra tab when starting a browser
Chrome already starts with a blank page, so use that for the first
target context instead of creating a new tab.

Add the first version of the Targets API, which is useful to test this
feature.

Fixes #291.
2019-04-07 01:18:15 +02:00