MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Problem/Bug]: File System Access `move()` fails inside folder passed via `CreateWebFileSystemDirectoryHandle()`
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
What happened?
In our host app, we use CreateWebFileSystemDirectoryHandle() to pass the current app data folder (of the form C:\Users\username\AppData\Local\FileSystemMoveFail) to JavaScript content via PostWebMessageAsJsonWithAdditionalObjects(). This lets JavaScript content read/write directly to this folder via a FileSystemDirectoryHandle.
When we do this, creating a new file works OK (calling createWritable et al). However when calling the FileSystemFileHandle method move(), a visible UI prompt appears in the app (shown below). These file system operations are expected to complete silently (as the host app is implicitly providing permission), so this is a bug. Further, clicking either option causes the call to move() to throw, so it never completes successfully.
Note the File System move() API was developed and launched later than the rest of the file system access API, so there may be an oversight in WebView2's file system logic that does not bypass the usual permission checks for this method specifically when using directory handles passed from the host app via CreateWebFileSystemDirectoryHandle().
Importance
Important. My app's user experience is significantly compromised.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
152.0.4191.66
SDK Version
1.0.4129.50
Framework
Win32
Operating System
Windows 11
OS Version
26200.9445
Repro steps
Repro executable: wv2-fs-move-fail.zip
- Extract all files to a folder and launch FileSystemMoveFail.exe
- Wait for the splash screen to finish and then observe permission prompt
- Press F12 and check for error messages in the browser console
The app will attempt to write a file to a path of the form C:\Users\username\AppData\Local\FileSystemMoveFail\test-save.json. This completes OK. It then calls move() to attempt to rename test-save.json to test-save.json.bak. This incorrectly shows a permission prompt and the API call fails (throwing an exception).
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked wv2-fs-move-fail.zip reproduction and inspect the browser console after the splash screen. Trace the flow from CreateWebFileSystemDirectoryHandle() and PostWebMessageAsJsonWithAdditionalObjects() to the FileSystemFileHandle move() call, comparing it with the successful file creation. Done means move() renames the file without showing a permission prompt or throwing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100