From b02dd4f742ec79a9e885a01579c15a151f5f9ebc Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 25 Nov 2023 14:53:19 +0100 Subject: swextreload: Explain MV2 vs. MV3 tab reload handling --- internal/swextreload.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'internal/swextreload.go') diff --git a/internal/swextreload.go b/internal/swextreload.go index 1d5af22..ffa083d 100644 --- a/internal/swextreload.go +++ b/internal/swextreload.go @@ -158,8 +158,14 @@ func reloadTab( logDebugf("Reload tab (Manifest V2: %t)", isExtensionManifestV2) + // If the extension is Manifest V3, its `targetId` reset after we reloaded + // the extension from the service worker, presumably because it was + // reinstalled. In that case, we need to get targets again, find the new + // `targetId`, and connect to it. + // + // If the extension is Manifest V2, we can just reconnect to the existing + // target. if !isExtensionManifestV2 { - // TODO: If MV2, then don't re-attach, only do it if "service_worker" targets, err := chromedp.Targets(ctx) if err != nil { return fmt.Errorf( -- cgit v1.2.3