-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Android] Add a Platform Specific to allow disable js execution on the WebView #29446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a new Android-specific API to enable or disable JavaScript execution in WebView, supporting a security-hardening initiative.
- Defines a bindable
JavaScriptEnabled
property and fluent extensions on Android platform configuration. - Hooks up handler mapping (
MapJavaScriptEnabled
) and runtime platform extension (UpdateJavaScriptEnabled
). - Updates PublicAPI listings for the newly added methods and properties, and adds a sample toggle in the WebView gallery.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/Controls/src/Core/WebView/WebView.Mapper.cs | Registered the JavaScriptEnabled mapping on the handler |
src/Controls/src/Core/WebView/WebView.Android.cs | Added MapJavaScriptEnabled method for Android handlers |
src/Controls/src/Core/PlatformConfiguration/AndroidSpecific/WebView.cs | Introduced JavaScriptEnabledProperty and related APIs |
src/Controls/src/Core/Platform/Android/Extensions/WebViewExtensions.cs | Implemented UpdateJavaScriptEnabled to toggle settings |
src/Controls/src/Core/PublicAPI/**/PublicAPI.Unshipped.txt | Exposed new Android-specific API signatures for JS control |
src/Controls/samples/Controls.Sample/Pages/Controls/WebViewGalleries/WebViewGallery.xaml(.cs) | Sample UI and event handler for toggling JavaScriptEnabled |
Comments suppressed due to low confidence (1)
src/Controls/src/Core/PlatformConfiguration/AndroidSpecific/WebView.cs:119
- No automated tests have been added for the new JavaScriptEnabled Android platform-specific property; please add relevant UI tests in TestCases.HostApp and shared tests in TestCases.Shared.Tests to cover this behavior.
public static readonly BindableProperty JavaScriptEnabledProperty = BindableProperty.Create("JavaScriptEnabled", typeof(bool), typeof(FormsElement), true);
src/Controls/samples/Controls.Sample/Pages/Controls/WebViewGalleries/WebViewGallery.xaml.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems theres a issue on the sample code.
Is it possible to add a test?
Added a test, could you review it again? |
Description of Change
Introduced a Platform-Specific that provides the ability to disable JavaScript execution within the Android WebView.
This change is part of an ongoing .NET MAUI threat modeling initiative aimed at identifying potential security risks and implementing proactive improvements to enhance application safety. This changes provides flexibility to enforce strict security policies based on app requirements.