From e9aa66f87e8cea7c220822b62e1ca3b90356b9cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 28 Mar 2019 21:44:07 +0000 Subject: [PATCH] fix build breakage with newer cdproto versions This isn't strictly necessary, as one can always build with the earlier cdproto version specified in go.mod. However, many people still install chromedp in GOPATH via 'go get -u', so this workaround makes life easier for a lot of developers. Fixes #285. --- go.mod | 4 ++-- go.sum | 8 ++++---- handler.go | 17 +++++++++++------ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 0038fba..8eb454c 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ module github.com/chromedp/chromedp require ( - github.com/chromedp/cdproto v0.0.0-20190217000753-2d8e8962ceb2 + github.com/chromedp/cdproto v0.0.0-20190327003620-8d5e1d04ce19 github.com/disintegration/imaging v1.6.0 github.com/gorilla/websocket v1.4.0 - github.com/mailru/easyjson v0.0.0-20190221075403-6243d8e04c3f + github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe golang.org/x/image v0.0.0-20190220214146-31aff87c08e9 // indirect ) diff --git a/go.sum b/go.sum index 70d89e4..1e45e99 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/chromedp/cdproto v0.0.0-20190217000753-2d8e8962ceb2 h1:4Ck8YOuS0G3+0xMb80cDSff7QpUolhSc0PGyfagbcdA= -github.com/chromedp/cdproto v0.0.0-20190217000753-2d8e8962ceb2/go.mod h1:xquOK9dIGFlLaIGI4c6IyfLI/Gz0LiYYuJtzhsUODgI= +github.com/chromedp/cdproto v0.0.0-20190327003620-8d5e1d04ce19 h1:KOdZXVcB8L3zR4ZsMAnviYJFIgfRP/iYSEzXl7rYXhc= +github.com/chromedp/cdproto v0.0.0-20190327003620-8d5e1d04ce19/go.mod h1:xquOK9dIGFlLaIGI4c6IyfLI/Gz0LiYYuJtzhsUODgI= github.com/disintegration/imaging v1.6.0 h1:nVPXRUUQ36Z7MNf0O77UzgnOb1mkMMor7lmJMJXc/mA= github.com/disintegration/imaging v1.6.0/go.mod h1:xuIt+sRxDFrHS0drzXUlCJthkJ8k7lkkUojDSR247MQ= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= @@ -7,8 +7,8 @@ github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoA github.com/knq/sysutil v0.0.0-20181215143952-f05b59f0f307 h1:vl4eIlySbjertFaNwiMjXsGrFVK25aOWLq7n+3gh2ls= github.com/knq/sysutil v0.0.0-20181215143952-f05b59f0f307/go.mod h1:BjPj+aVjl9FW/cCGiF3nGh5v+9Gd3VCgBQbod/GlMaQ= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190221075403-6243d8e04c3f h1:B6PQkurxGG1rqEX96oE14gbj8bqvYC5dtks9r5uGmlE= -github.com/mailru/easyjson v0.0.0-20190221075403-6243d8e04c3f/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe h1:W/GaMY0y69G4cFlmsC6B9sbuo2fP8OFP1ABjt4kPz+w= +github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81 h1:00VmoueYNlNz/aHIilyyQz/MHSqGoWJzpFv/HW8xpzI= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190220214146-31aff87c08e9 h1:+vH8qNweCrORN49012OX3h0oWEXO3p+rRnpAGQinddk= diff --git a/handler.go b/handler.go index fd87234..250cacf 100644 --- a/handler.go +++ b/handler.go @@ -226,6 +226,15 @@ func (h *TargetHandler) processEvent(ctxt context.Context, msg *cdproto.Message) if msg == nil { return ErrChannelClosed } + switch msg.Method { + case "Page.frameClearedScheduledNavigation", + "Page.frameScheduledNavigation": + // These events are now deprecated, and UnmarshalMessage panics + // when they are received from Chrome. For now, to avoid panics + // and compile errors, and to fix chromedp v0 when installed via + // 'go get -u', skip the events here. + return nil + } // unmarshal ev, err := cdproto.UnmarshalMessage(msg) @@ -530,13 +539,9 @@ func (h *TargetHandler) pageEvent(ctxt context.Context, ev interface{}) { case *page.EventFrameStoppedLoading: id, op = e.FrameID, frameStoppedLoading - case *page.EventFrameScheduledNavigation: - id, op = e.FrameID, frameScheduledNavigation - - case *page.EventFrameClearedScheduledNavigation: - id, op = e.FrameID, frameClearedScheduledNavigation - // ignored events + case *page.EventFrameRequestedNavigation: + return case *page.EventDomContentEventFired: return case *page.EventLoadEventFired: