aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2023-11-25 15:00:09 +0100
committerTeddy Wing2023-11-25 15:00:09 +0100
commit3c3533d85f55b034333e91edd9968608a1ea98ac (patch)
tree8424fd92975f25567d4c2a95af43a086e9cdac34
parent6d5c4ff7710f37ff75ffaf6465d529a2fce64d38 (diff)
downloadswextreload-3c3533d85f55b034333e91edd9968608a1ea98ac.tar.bz2
swextreload.reloadTab: Remove `isExtensionManifestV2` argument
It was a bit confusing to have a variable and a function with the same name.
-rw-r--r--internal/swextreload.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/internal/swextreload.go b/internal/swextreload.go
index 92dd1b8..5ed8765 100644
--- a/internal/swextreload.go
+++ b/internal/swextreload.go
@@ -84,11 +84,9 @@ func Reload(
return errors.New("swextreload: can't reload tab, no target available")
}
- isMV2 := isExtensionManifestV2(firstExtensionTarget)
-
// In Manifest V3, we need to wait until the service worker reinstalls
// before we can re-attach to it.
- if !isMV2 {
+ if !isExtensionManifestV2(firstExtensionTarget) {
time.Sleep(200 * time.Millisecond)
}
@@ -96,7 +94,6 @@ func Reload(
allocatorContext,
extensionIDs[0],
firstExtensionTarget,
- isMV2,
)
if err != nil {
return err
@@ -151,13 +148,13 @@ func reloadTab(
ctx context.Context,
extensionID string,
letarget *target.Info,
- isExtensionManifestV2 bool,
) error {
// Don't cancel the context. Otherwise, the background page DevTools
// window closes.
ctx, cancel := chromedp.NewContext(ctx)
- logDebugf("Reload tab (Manifest V2: %t)", isExtensionManifestV2)
+ isMV2 := isExtensionManifestV2(letarget)
+ logDebugf("Reload tab (Manifest V2: %t)", isMV2)
// If the extension is Manifest V3, its `targetId` reset after we reloaded
// the extension from the service worker, presumably because it was
@@ -166,7 +163,7 @@ func reloadTab(
//
// If the extension is Manifest V2, we can just reconnect to the existing
// target.
- if !isExtensionManifestV2 {
+ if !isMV2 {
targets, err := chromedp.Targets(ctx)
if err != nil {
return fmt.Errorf(