Skip to content
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

File System Access API prompts do not call PermissionRequested event #1039

Closed
AshleyScirra opened this issue Mar 5, 2021 · 5 comments
Closed
Labels
bug Something isn't working priority-low We have considered this issue and decided that we will not be able to address it in the near future. tracked We are tracking this work internally.

Comments

@AshleyScirra
Copy link

AshleyScirra commented Mar 5, 2021

Description
The File System Access API (formerly the Native File System API) allows access to local files. It sometimes shows permission prompts for file access, such as "Save changes to test.txt?" with options "Save changes" and "Cancel". These prompts do not go through the PermissionRequested event in WebView2, so they cannot be controlled. In particular if the WebView2 is showing local app-provided content, there's no point having these prompts since the containing app already has access to the file system, but the prompts cannot be removed.

Version
SDK: 1.0.705.50
Runtime: Stable 89.0.774.45
Framework: Win32
OS: Win10 x64 20H2

Repro Steps
I just took the getting started guide: https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/win32
And set the navigation URL to this repro page:https://downloads.scirra.com/labs/bugs/fileaccessprompt/index.html

Before the Navigate call, I inserted the following code snippet that logs if the PermissionRequested event happens, and approves all requests:

webviewWindow->add_PermissionRequested(Callback<ICoreWebView2PermissionRequestedEventHandler>(
[](ICoreWebView2* sender, ICoreWebView2PermissionRequestedEventArgs* args) -> HRESULT
{
	OutputDebugString(L"Permission requested event\n");
	args->put_State(COREWEBVIEW2_PERMISSION_STATE_ALLOW);
	return S_OK;
}).Get(), nullptr);

Run the app, click 'Pick file', and choose a file. (Nothing is written to this file, it only uses fileHandle.requestPermission() to request write permission, then stops.)

In both the browser and WebView2, it shows a "Save changes?" permission prompt. In WebView2, the PermissionRequested event does not appear to run (nothing is written to debug output). It should run this event and take in to account the indicated state (i.e. automatically allow).

AB#32079502

@AshleyScirra AshleyScirra added the bug Something isn't working label Mar 5, 2021
@champnic
Copy link
Member

Thanks for the report @AshleyScirra - I've added this bug to our backlog to take a look.

@champnic champnic added the tracked We are tracking this work internally. label Mar 11, 2021
@groege
Copy link

groege commented Aug 18, 2021

Do you have any Idea when this Bug will be resolved?

@vickiez
Copy link
Contributor

vickiez commented Jan 21, 2023

Hi @AshleyScirra and @groege, we added support for this permission kind in our latest prerelease package, 1.0.1619-prerelease. The PermissionRequested event will now be raised for requests of the kind COREWEBVIEW2_PERMISSION_KIND_FILE_READ_WRITE.

Steps for testing upcoming APIs/ features:
https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/set-preview-channel.

Permission management spec: https://github.com/MicrosoftEdge/WebView2Feedback/blob/main/specs/PermissionManagement.md

@AshleyScirra
Copy link
Author

AshleyScirra commented Jan 23, 2023

That's great to see, thanks!

@vickiez
Copy link
Contributor

vickiez commented Mar 22, 2023

@AshleyScirra @groege this permission kind is now part of the latest release package, 1.0.1661.34. Closing this issue as completed but feel free to reactivate if you run into any problems. :)

@vickiez vickiez closed this as completed Mar 22, 2023
@github-actions github-actions bot added the priority-low We have considered this issue and decided that we will not be able to address it in the near future. label Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-low We have considered this issue and decided that we will not be able to address it in the near future. tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

4 participants