MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
444 stars 53 forks source link

[Problem/Bug]: Download is blocked when subscribed to DownloadStarting #4612

Closed gkerenyi closed 1 month ago

gkerenyi commented 4 months ago

What happened?

Summary

If Smart Screen is disabled, and the user downloads a potentially harmful file (e.g. msixbundle), the displayed message depends on whether a handler is subscribed to the DownloadStarting WebView2 event:

Impact on our application

In our application we have to disable Smart Screen and have to handle the DownloadStarting event. The "file was blocked" message displayed to our users is too strict and we would like to use the "Do you want to keep it?" question instead, because in that case the possible choices are more accessible to users.

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

125.0.2535.79

SDK Version

1.0.2535.41

Framework

WPF

Operating System

Windows 10, Windows 11

OS Version

No response

Repro steps

Sample repo URL: https://github.com/gkerenyi/WebView2SamplesForDownloadTest.

It is a fork of https://github.com/MicrosoftEdge/WebView2Samples with the following changes:

Steps to reproduce When subscribed to DownloadStarting

  1. Build the WebView2WpfBrowser solution from the repo
  2. Start the sample browser
  3. Visit https://gkerenyi.github.io/DownloadLinks
  4. It shows two links. One of them downloads an msixbundle file in the current window, the other one downloads the same file in a new window. Click both.
  5. ➡️ Result: "File was blocked" message is shown in both cases. image

When not subscribed to DownloadStarting

  1. Comment out the following line in MainWindow.InitializeWebView(): webView.CoreWebView2.DownloadStarting += WebView_DownloadStarting;
  2. Rebuild the solution
  3. Start the sample browser
  4. Visit https://gkerenyi.github.io/DownloadLinks
  5. It shows two links. One of them downloads an msixbundle file in the current window, the other one downloads the same file in a new window. Click both.
  6. ➡️ Result: "Do you want to keep it?" message is shown. image

Expected "Do you want to keep it?" message is shown in both cases.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

Don't know

Last working version (if regression)

No response

Master-Ukulele commented 1 month ago

Thanks for reporting. This is a feature request same as #1902, we've tracked.

gkerenyi commented 1 month ago

@Master-Ukulele Thank you, but I think this issue and #1902 are not the same, because #1902 is about disabling the harmful file warning entirely, while this one is about harmful file warning behaving inconsistently. I do not want to disable the warning, but expect it to behave the same way regardless of being subscribed to DownloadStarting or not.

Master-Ukulele commented 1 month ago

We have been working on this scenario for some time. Although there's no final conclusion yet, mostly, the reason behind to prompt the warning UI and a possible block in DownloadStarting event is the same. We consider yours as the same, because we are seeking a good solution can benefit more cases.

@gkerenyi Thanks for telling the details. To your request, I see you don't like the inconsistent behavior, but that's by design. As I know, another inconsistence is based on user's history and reaction to the warning UI. Besides disabling the warning, our draft solution probably can provide you a way to have your own warning UI, your own sentence. So, you don't need to depend on the default behavior. Will it help in your App? Please keep following the scenario discussion, we'll update if any progress comes.

gkerenyi commented 3 weeks ago

Yes, having a way to override the default behavior would probably help in our use case. Thanks!