@@ -2447,19 +2447,42 @@ final class BrowserPanel: Panel, ObservableObject {
24472447 websiteDataStore: WKWebsiteDataStore ? = nil
24482448 ) -> CmuxWebView {
24492449 let config = WKWebViewConfiguration ( )
2450- config. processPool = BrowserPanel . sharedProcessPool
2451- config. mediaTypesRequiringUserActionForPlayback = [ ]
2450+ configureWebViewConfiguration (
2451+ config,
2452+ websiteDataStore: websiteDataStore ?? BrowserProfileStore . shared. websiteDataStore ( for: profileID)
2453+ )
2454+
2455+ let webView = CmuxWebView ( frame: . zero, configuration: config)
2456+ webView. allowsBackForwardNavigationGestures = true
2457+ if #available( macOS 13 . 3 , * ) {
2458+ webView. isInspectable = true
2459+ }
2460+ // Match the empty-page background to the terminal theme so newly-created browsers
2461+ // don't flash white before content loads.
2462+ webView. underPageBackgroundColor = GhosttyBackgroundTheme . currentColor ( )
2463+ // Always present as Safari.
2464+ webView. customUserAgent = BrowserUserAgentSettings . safariUserAgent
2465+ return webView
2466+ }
2467+
2468+ static func configureWebViewConfiguration(
2469+ _ configuration: WKWebViewConfiguration ,
2470+ websiteDataStore: WKWebsiteDataStore ,
2471+ processPool: WKProcessPool = BrowserPanel . sharedProcessPool
2472+ ) {
2473+ configuration. processPool = processPool
2474+ configuration. mediaTypesRequiringUserActionForPlayback = [ ]
24522475 // Ensure browser cookies/storage persist across navigations and launches.
24532476 // This reduces repeated consent/bot-challenge flows on sites like Google.
2454- config . websiteDataStore = websiteDataStore ?? BrowserProfileStore . shared . websiteDataStore ( for : profileID )
2477+ configuration . websiteDataStore = websiteDataStore
24552478
24562479 // Enable developer extras (DevTools)
2457- config . preferences. setValue ( true , forKey: " developerExtrasEnabled " )
2480+ configuration . preferences. setValue ( true , forKey: " developerExtrasEnabled " )
24582481
24592482 // Enable JavaScript
2460- config . defaultWebpagePreferences. allowsContentJavaScript = true
2483+ configuration . defaultWebpagePreferences. allowsContentJavaScript = true
24612484 // Keep browser console/error/dialog telemetry active from document start on every navigation.
2462- config . userContentController. addUserScript (
2485+ configuration . userContentController. addUserScript (
24632486 WKUserScript (
24642487 source: Self . telemetryHookBootstrapScriptSource,
24652488 injectionTime: . atDocumentStart,
@@ -2468,25 +2491,13 @@ final class BrowserPanel: Panel, ObservableObject {
24682491 )
24692492 // Track the last editable focused element continuously so omnibar exit can
24702493 // restore page input focus even if capture runs after first-responder handoff.
2471- config . userContentController. addUserScript (
2494+ configuration . userContentController. addUserScript (
24722495 WKUserScript (
24732496 source: Self . addressBarFocusTrackingBootstrapScript,
24742497 injectionTime: . atDocumentStart,
24752498 forMainFrameOnly: false
24762499 )
24772500 )
2478-
2479- let webView = CmuxWebView ( frame: . zero, configuration: config)
2480- webView. allowsBackForwardNavigationGestures = true
2481- if #available( macOS 13 . 3 , * ) {
2482- webView. isInspectable = true
2483- }
2484- // Match the empty-page background to the terminal theme so newly-created browsers
2485- // don't flash white before content loads.
2486- webView. underPageBackgroundColor = GhosttyBackgroundTheme . currentColor ( )
2487- // Always present as Safari.
2488- webView. customUserAgent = BrowserUserAgentSettings . safariUserAgent
2489- return webView
24902501 }
24912502
24922503 private func bindWebView( _ webView: CmuxWebView ) {
0 commit comments