From 41e913e571c1c245b6c1684daf26e473e9802c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 1 Apr 2019 17:12:17 +0100 Subject: [PATCH] various minor cleanups Remove the log option lines from testAllocate; right now, we don't have these options for Target, and Target doesn't log much anyway. We can always revisit this in the future. While at it, simplify some code. --- chromedp_test.go | 12 +----------- context.go | 6 ++---- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/chromedp_test.go b/chromedp_test.go index cd343de..b36a7b8 100644 --- a/chromedp_test.go +++ b/chromedp_test.go @@ -33,16 +33,6 @@ func testAllocate(t *testing.T, path string) (_ context.Context, cancel func()) } } - //if err := WithLogf(t.Logf)(c.c); err != nil { - // t.Fatalf("could not set logf: %v", err) - //} - //if err := WithDebugf(t.Logf)(c.c); err != nil { - // t.Fatalf("could not set debugf: %v", err) - //} - //if err := WithErrorf(t.Errorf)(c.c); err != nil { - // t.Fatalf("could not set errorf: %v", err) - //} - return ctx, cancel } @@ -67,7 +57,7 @@ func TestMain(m *testing.M) { // start the browser browserCtx, _ = NewContext(allocCtx) - if err := Run(browserCtx, Tasks{}); err != nil { + if err := Run(browserCtx); err != nil { panic(err) } diff --git a/context.go b/context.go index 089fc18..e3a8514 100644 --- a/context.go +++ b/context.go @@ -81,14 +81,12 @@ func Run(ctx context.Context, actions ...Action) error { } func (c *Context) newSession(ctx context.Context) error { - create := target.CreateTarget("about:blank") - targetID, err := create.Do(ctx, c.Browser) + targetID, err := target.CreateTarget("about:blank").Do(ctx, c.Browser) if err != nil { return err } - attach := target.AttachToTarget(targetID) - sessionID, err := attach.Do(ctx, c.Browser) + sessionID, err := target.AttachToTarget(targetID).Do(ctx, c.Browser) if err != nil { return err }