microsoft / microsoft/WindowsAppSDK
WebView2: Cannot suppress (Camera) permission prompt
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 471
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 28
Description
### Describe the bug
Using WebView2, it appears like certain websites can prompt for permissions, like Camera permissions. I need to deny those permissions on behalf of the users - no permission prompt should be shown.
The `CoreWebView2.PermissionRequested` event handler is not called.
### Steps to reproduce the bug
```
webView.CoreWebView2Initialized += (c, e) =>
{
c.CoreWebView2.PermissionRequested += (sender, args) =>
{
args.Handled = true;
args.State = CoreWebView2PermissionState.Deny;
};
};
webView.Source = new Uri("https://webcamtests.com/");
```
### Expected behavior
No permission dialog is shown or I can deny the permission prompt using the `PermissionRequested` event handler
### Screenshots

### NuGet package version
Windows App SDK 1.8 Experimental 2: 1.8.250515001-experimental2
### Packaging type
Packaged (MSIX)
### Windows version
Windows 11 version 24H2 (22621, October 2024 Update)
### IDE
Visual Studio 2022
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the issue with the CoreWebView2Initialized and CoreWebView2.PermissionRequested handlers against https://webcamtests.com/. Check whether the event is raised for camera permissions in the reported Windows App SDK and WebView2 setup. Done means the permission can be denied without showing a prompt, or the limitation and supported workaround are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100