Align webview console and tab lifecycle
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

This commit is contained in:
Snider 2026-04-15 23:54:06 +01:00
parent 4069bbe263
commit 6759f42a4c
2 changed files with 7 additions and 6 deletions

6
cdp.go
View file

@ -322,6 +322,9 @@ func (c *CDPClient) CloseTab() error {
if err != nil {
return coreerr.E("CDPClient.CloseTab", "failed to determine target ID", err)
}
defer func() {
_ = c.Close()
}()
ctx, cancel := context.WithTimeout(c.ctx, debugEndpointTimeout)
defer cancel()
@ -336,8 +339,7 @@ func (c *CDPClient) CloseTab() error {
if success, ok := result["success"].(bool); ok && !success {
return coreerr.E("CDPClient.CloseTab", "target close was not acknowledged", nil)
}
return c.Close()
return nil
}
// ListTargets returns all available targets.

View file

@ -61,14 +61,13 @@ func NewConsoleWatcher(wv *Webview) *ConsoleWatcher {
return watcher
}
// normalizeConsoleType converts CDP event types to package-level values.
// normalizeConsoleType converts CDP event types to the canonical package value.
//
// This keeps the legacy warn alias for compatibility. Use canonicalConsoleType
// when the exact RFC type names are required.
// It accepts legacy warn aliases but stores the RFC form, warning.
func normalizeConsoleType(raw string) string {
normalized := strings.ToLower(core.Trim(core.Sprint(raw)))
if normalized == "warning" {
return "warn"
return "warning"
}
return normalized
}