From b136a6267ed3ad80e98776a2e13bae0cc599846c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 21 Mar 2019 15:20:27 +0000 Subject: [PATCH] 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. --- chromedp_test.go | 2 +- context.go | 8 -------- example_test.go | 4 ++-- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/chromedp_test.go b/chromedp_test.go index 8db5965..e2baa44 100644 --- a/chromedp_test.go +++ b/chromedp_test.go @@ -67,6 +67,6 @@ func TestMain(m *testing.M) { code := m.Run() cancel() - FromContext(ctx).Wait() + FromContext(ctx).Allocator.Wait() os.Exit(code) } diff --git a/context.go b/context.go index 44399a7..703b1fb 100644 --- a/context.go +++ b/context.go @@ -28,14 +28,6 @@ type Context struct { sessionID target.SessionID } -// Wait can be called after cancelling the context containing Context, to block -// until all the underlying resources have been cleaned up. -func (c *Context) Wait() { - if c.Allocator != nil { - c.Allocator.Wait() - } -} - // NewContext creates a browser context using the parent context. func NewContext(parent context.Context, opts ...ContextOption) (context.Context, context.CancelFunc) { ctx, cancel := context.WithCancel(parent) diff --git a/example_test.go b/example_test.go index b9516f4..baff57b 100644 --- a/example_test.go +++ b/example_test.go @@ -26,7 +26,7 @@ func ExampleTitle() { // wait for the resources to be cleaned up cancel() - chromedp.FromContext(ctx).Wait() + chromedp.FromContext(ctx).Allocator.Wait() // Output: // Issues · chromedp/chromedp · GitHub @@ -70,7 +70,7 @@ func ExampleExecAllocatorOption() { // wait for the resources to be cleaned up cancel() - chromedp.FromContext(allocCtx).Wait() + chromedp.FromContext(allocCtx).Allocator.Wait() // Output: // Files in UserDataDir: