Align webview console and tab lifecycle
This commit is contained in:
parent
4069bbe263
commit
6759f42a4c
2 changed files with 7 additions and 6 deletions
6
cdp.go
6
cdp.go
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue