microsoft / microsoft/WindowsAppSDK

WebView2: Cannot suppress (Camera) permission prompt

Open
#5,539 2 comments 0 reactions 0 assignees View on GitHub
area-WebView needs-triage
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

![Image](https://github.com/user-attachments/assets/4a3eb07f-d051-40c6-a2e3-48d90b14c233)

### 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.