From 6b898fbd54b4f486660bb4af699dd7e4dbc837ff Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 17 Nov 2023 20:47:44 +0100 Subject: swextreload: Fix MV2 extension reload There was a problem reloading the tab from an MV2 extension, and reloading the extension after the first time. Looks like I needed to cancel the context in order to be able to evaluate other statements in the background page. --- internal/swextreload.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'internal/swextreload.go') diff --git a/internal/swextreload.go b/internal/swextreload.go index 2f333a3..d31e82d 100644 --- a/internal/swextreload.go +++ b/internal/swextreload.go @@ -107,8 +107,8 @@ func reloadExtension( log.Printf("Target: %#v", target) } - targetCtx, _ := chromedp.NewContext(ctx, chromedp.WithTargetID(target.TargetID)) - // defer cancel() + targetCtx, cancel := chromedp.NewContext(ctx, chromedp.WithTargetID(target.TargetID)) + defer cancel() log.Printf("Connected to target '%s'", target.TargetID) @@ -182,6 +182,10 @@ func reloadTab( defer cancel() } + if isDebug { + log.Printf("Connecting to target %s", letarget.TargetID) + } + ctx, cancel = chromedp.NewContext(ctx, chromedp.WithTargetID(letarget.TargetID)) // defer cancel() -- cgit v1.2.3