Add integration test for App Shim launching Chrome and testing infrastructure enhancements

Commit: c11b2d1c | 2025-11-25 18:53:03+00:00

← Back to List

Add integration test for App Shim launching Chrome and testing infrastructure enhancements

Minor
Commit Hash: c11b2d1c5325f5cbc56333da3d128eab6263ca35
Commit Time: 2025-11-25 18:53:03+00:00
Impact Level: Minor
Generated By: webview2-upstream-sentry
Upstream Review: View Upstream Review 🔗

📋 Summary

This commit primarily adds integration tests for App Shim to verify the scenario where Chrome is launched by an App Shim while Chrome is not running. To support these tests, several infrastructure improvements were made:
1. Added support for overriding MainBundle in base/apple/bundle_locations, allowing test environments to customize the main bundle
2. Added AllowShadowingForTesting() method to AtExitManager, allowing the AtExitManager created by test harness to be shadowed when production code creates a new one
3. Added kDoNotCreateNSAppForTests flag to ChromeTestSuite to allow skipping initialization of shared NSApplication instance, enabling app shim code to initialize NSApp itself
4. Added SetNSWindowCreatedCallbackForTesting() test callback interface in remote_cocoa::ApplicationBridge for monitoring window creation in tests
5. Added OnWindowSetForTesting() method and related callback support in NativeWidgetNSWindowBridge
6. Added AppShimController::TestDelegate interface and related test support
7. Added kAllowAppShimSignatureMismatchForTests flag in app shim signature validation to allow signature-mismatched app shims in tests

🎯 Impact Analysis

This commit has a minor impact on WebView2Mac, mainly enhancing testing infrastructure. Specific impact analysis:

1. **Test-only Interface Additions (Low Risk)**: Test callback methods added to ApplicationBridge and NativeWidgetNSWindowBridge (SetNSWindowCreatedCallbackForTesting, OnWindowSetForTesting) are for testing purposes only and do not affect production code functionality. These methods are protected with CHECK_IS_TEST macro to ensure they are only used in test environments.

2. **Minor Window Creation Flow Change (Low Risk)**: Added invocation of window_set_callback_ in NativeWidgetNSWindowBridge::CreateWindow(), but this callback is only set in tests and is null in production, so it does not affect WebView2Mac's normal window creation flow.

3. **ApplicationBridge Test Callback (Low Risk)**: The test callback support added in ApplicationBridge::CreateNativeWidgetNSWindow() allows test code to monitor window creation without changing creation logic. WebView2Mac's HostingApplicationBridge, which inherits from ApplicationBridge, is not affected.

4. **Infrastructure Improvements Have No Direct Impact**: Modifications to bundle_locations, AtExitManager, and ChromeTestSuite are all for improving test infrastructure and do not affect WebView2Mac's runtime behavior.

5. **App Shim Specific Functionality**: The new app shim test code and related flags (such as signature verification bypass) are PWA/App Shim specific and unrelated to WebView2Mac's embedded control usage scenarios.

Overall, these changes are primarily for enhancing App Shim testing capabilities and have no impact on WebView2Mac's core functionality. WebView2Mac can continue to use Remote Cocoa's window bridging functionality normally without any adjustments.

Impacted Classes:

remote_cocoa::ApplicationBridge remote_cocoa::NativeWidgetNSWindowBridge