Commit Graph

7 Commits

Author SHA1 Message Date
Daniel Martí
0d568ec2a4 change Run to allow many actions
This can simplify some common use cases, like running a few actions
directly, or running no actions at all. It's also an almost entirely
backwards compatible change, as all Run call sites should continue to
compile and work.

Leave Tasks, as it can still be useful for functions to return complex
sequences of actions as a single Action.
2019-04-01 16:59:23 +01:00
Daniel Martí
1decbccd74 store a Target pointer directly in Context
That way, we avoid the racy map access via Browser.executorForTarget. If
a context is attached to a target, the Target field must be non-nil.

The Browser.pages map is still racy, since multiple tabs can be created
concurrently; we'll fix this other data race in another commit.
2019-04-01 14:31:11 +01:00
Daniel Martí
a0a36956a8 add support for opening multiple tabs
On a single browser, that is. And port the example from _example,
proving that it works.
2019-04-01 12:18:16 +01:00
Daniel Martí
f742f327a7 speed up the screenshot tests, and test the images
Using a smaller viewport speeds up both tests, and lets us know what
dimensions to expect in TestCaptureScreenshot.

For TestScreenshot, we can know what dimensions to expect in advance, as
we have the images in testdata.

'go test -run Screenshot' goes from ~0.9s to ~0.5s on my machine.

Finally, don't run ExampleTitle as part of 'go test', as it's slow.
2019-04-01 12:18:16 +01:00
Daniel Martí
0e92de5e65 make ExampleExecAllocatorOption less flaky
The Default folder is created asynchronously to Chrome starting to
listen on the debugging protocol port. So we can't expect it to exist.

Instead, base the example on DevToolsActivePort, which we can rely on.
2019-04-01 12:18:16 +01:00
Daniel Martí
b136a6267e remove Context's Wait method for now
All it did was wait on the entire allocator, which is confusing. From
the user's perspective, this wait method should instead wait for the
resources for its own browser, and not any other browsers sharing the
same allocator.

We haven't decided how to integrate that into our API, so simply replace
it with Allocator.Wait.
2019-04-01 12:18:16 +01:00
Daniel Martí
e698c943b3 make the simple and allocator examples runnable
This way, not only do we ensure that they always build, they're also
verified as part of 'go test'.
2019-04-01 12:18:16 +01:00