fix: init missing maps in NewCoordinator, log GoBack error, safe test assertion
- Initialize pendingScriptRefresh and pendingThemePanes maps in NewCoordinator to prevent nil-map panics on write - Log error from wv.GoBack() in external URL handler instead of discarding - Use checked type assertion in migrate_engine_test.go to avoid panic
- commit
- 71664a35b35cabdd1932787641924505b2eb4563
- author
- brice · · 2026-03-15 19:40 UTC
- parent
- ac967b8
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +22 -15
M internal/infrastructure/config/migrate_engine_test.go +4 -1
| @@ -276,6 +276,9 @@ show_fps = true | |||
| 276 | 276 | err = toml.Unmarshal(data, &raw) | |
| 277 | 277 | require.NoError(t, err) | |
| 278 | 278 | ||
| 279 | - | engine := raw["engine"].(map[string]any) | |
| 279 | + | engineAny, ok := raw["engine"] | |
| 280 | + | require.True(t, ok, "raw[\"engine\"] should exist") | |
| 281 | + | engine, ok := engineAny.(map[string]any) | |
| 282 | + | require.True(t, ok, "raw[\"engine\"] should be map[string]any, got %T", engineAny) | |
| 280 | 283 | assert.Equal(t, "webkit", engine["type"], "engine.type should default to webkit") | |
| 281 | 284 | } | |
| @@ -276,6 +276,9 @@ show_fps = true | |||||
| 276 | err = toml.Unmarshal(data, &raw) | 276 | err = toml.Unmarshal(data, &raw) | ||
| 277 | require.NoError(t, err) | 277 | require.NoError(t, err) | ||
| 278 | 278 | ||||
| 279 | - | engine := raw["engine"].(map[string]any) | 279 | + | engineAny, ok := raw["engine"] |
| 280 | + | require.True(t, ok, "raw[\"engine\"] should exist") | |||
| 281 | + | engine, ok := engineAny.(map[string]any) | |||
| 282 | + | require.True(t, ok, "raw[\"engine\"] should be map[string]any, got %T", engineAny) | |||
| 280 | assert.Equal(t, "webkit", engine["type"], "engine.type should default to webkit") | 283 | assert.Equal(t, "webkit", engine["type"], "engine.type should default to webkit") | ||
| 281 | } | 284 | } | ||
M internal/ui/coordinator/content/coordinator.go +15 -13
| @@ -144,19 +144,21 @@ func NewCoordinator( | |||
| 144 | 144 | log.Debug().Msg("creating content coordinator") | |
| 145 | 145 | ||
| 146 | 146 | return &Coordinator{ | |
| 147 | - | pool: pool, | |
| 148 | - | widgetFactory: widgetFactory, | |
| 149 | - | faviconAdapter: faviconAdapter, | |
| 150 | - | zoomUC: zoomUC, | |
| 151 | - | permissionUC: permissionUC, | |
| 152 | - | webViews: make(map[entity.PaneID]port.WebView), | |
| 153 | - | paneTitles: make(map[entity.PaneID]string), | |
| 154 | - | navOrigins: make(map[entity.PaneID]string), | |
| 155 | - | pendingReveal: make(map[entity.PaneID]bool), | |
| 156 | - | getActiveWS: getActiveWS, | |
| 157 | - | pendingPopups: make(map[port.WebViewID]*PendingPopup), | |
| 158 | - | popupOAuth: make(map[port.WebViewID]*popupOAuthState), | |
| 159 | - | popupRefresh: make(map[entity.PaneID]*time.Timer), | |
| 147 | + | pool: pool, | |
| 148 | + | widgetFactory: widgetFactory, | |
| 149 | + | faviconAdapter: faviconAdapter, | |
| 150 | + | zoomUC: zoomUC, | |
| 151 | + | permissionUC: permissionUC, | |
| 152 | + | webViews: make(map[entity.PaneID]port.WebView), | |
| 153 | + | paneTitles: make(map[entity.PaneID]string), | |
| 154 | + | navOrigins: make(map[entity.PaneID]string), | |
| 155 | + | pendingReveal: make(map[entity.PaneID]bool), | |
| 156 | + | pendingScriptRefresh: make(map[entity.PaneID]bool), | |
| 157 | + | pendingThemePanes: make(map[entity.PaneID]bool), | |
| 158 | + | getActiveWS: getActiveWS, | |
| 159 | + | pendingPopups: make(map[port.WebViewID]*PendingPopup), | |
| 160 | + | popupOAuth: make(map[port.WebViewID]*popupOAuthState), | |
| 161 | + | popupRefresh: make(map[entity.PaneID]*time.Timer), | |
| 160 | 162 | } | |
| 161 | 163 | } | |
| 162 | 164 | ||
| @@ -144,19 +144,21 @@ func NewCoordinator( | |||||
| 144 | log.Debug().Msg("creating content coordinator") | 144 | log.Debug().Msg("creating content coordinator") | ||
| 145 | 145 | ||||
| 146 | return &Coordinator{ | 146 | return &Coordinator{ | ||
| 147 | - | pool: pool, | 147 | + | pool: pool, |
| 148 | - | widgetFactory: widgetFactory, | 148 | + | widgetFactory: widgetFactory, |
| 149 | - | faviconAdapter: faviconAdapter, | 149 | + | faviconAdapter: faviconAdapter, |
| 150 | - | zoomUC: zoomUC, | 150 | + | zoomUC: zoomUC, |
| 151 | - | permissionUC: permissionUC, | 151 | + | permissionUC: permissionUC, |
| 152 | - | webViews: make(map[entity.PaneID]port.WebView), | 152 | + | webViews: make(map[entity.PaneID]port.WebView), |
| 153 | - | paneTitles: make(map[entity.PaneID]string), | 153 | + | paneTitles: make(map[entity.PaneID]string), |
| 154 | - | navOrigins: make(map[entity.PaneID]string), | 154 | + | navOrigins: make(map[entity.PaneID]string), |
| 155 | - | pendingReveal: make(map[entity.PaneID]bool), | 155 | + | pendingReveal: make(map[entity.PaneID]bool), |
| 156 | - | getActiveWS: getActiveWS, | 156 | + | pendingScriptRefresh: make(map[entity.PaneID]bool), |
| 157 | - | pendingPopups: make(map[port.WebViewID]*PendingPopup), | 157 | + | pendingThemePanes: make(map[entity.PaneID]bool), |
| 158 | - | popupOAuth: make(map[port.WebViewID]*popupOAuthState), | 158 | + | getActiveWS: getActiveWS, |
| 159 | - | popupRefresh: make(map[entity.PaneID]*time.Timer), | 159 | + | pendingPopups: make(map[port.WebViewID]*PendingPopup), |
| 160 | + | popupOAuth: make(map[port.WebViewID]*popupOAuthState), | |||
| 161 | + | popupRefresh: make(map[entity.PaneID]*time.Timer), | |||
| 160 | } | 162 | } | ||
| 161 | } | 163 | } | ||
| 162 | 164 | ||||
M internal/ui/coordinator/content/navigation.go +3 -1
| @@ -327,7 +327,9 @@ func (c *Coordinator) handleURIChanged(ctx context.Context, paneID entity.PaneID | |||
| 327 | 327 | ||
| 328 | 328 | // Navigate back to avoid stale URI in omnibox/history | |
| 329 | 329 | if wv.CanGoBack() { | |
| 330 | - | _ = wv.GoBack(ctx) | |
| 330 | + | if err := wv.GoBack(ctx); err != nil { | |
| 331 | + | log.Warn().Str("pane_id", string(paneID)).Err(err).Msg("GoBack after external URL") | |
| 332 | + | } | |
| 331 | 333 | } | |
| 332 | 334 | return | |
| 333 | 335 | } | |
| @@ -327,7 +327,9 @@ func (c *Coordinator) handleURIChanged(ctx context.Context, paneID entity.PaneID | |||||
| 327 | 327 | ||||
| 328 | // Navigate back to avoid stale URI in omnibox/history | 328 | // Navigate back to avoid stale URI in omnibox/history | ||
| 329 | if wv.CanGoBack() { | 329 | if wv.CanGoBack() { | ||
| 330 | - | _ = wv.GoBack(ctx) | 330 | + | if err := wv.GoBack(ctx); err != nil { |
| 331 | + | log.Warn().Str("pane_id", string(paneID)).Err(err).Msg("GoBack after external URL") | |||
| 332 | + | } | |||
| 331 | } | 333 | } | ||
| 332 | return | 334 | return | ||
| 333 | } | 335 | } | ||