Repository navigation
fix(wasm): Don't double the download file extension - #25672
MartinZikmund merged 5 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix matches the requested behavior and has targeted regression coverage, with only a nonblocking test-metadata nit remaining.
1 open issue
What changed in this PR
Fixes #25671 by preventing the WebAssembly download fallback from duplicating a recognized file extension, aligning it with the existing native-picker path.
Changes:
- Preserves suggested names ending in any allowed extension, using case-insensitive matching.
- Retains first-extension appending when no allowed extension matches.
- Adds four unattended Skia WebAssembly regression cases.
| File | Description |
|---|---|
src/Uno.WinRT/Storage/Pickers/FileSavePicker.wasm.cs |
Checks allowed extensions before appending the default extension. |
src/Uno.UI.RuntimeTests/Windows/Storage/Pickers/Given_FileSavePicker_Download.cs |
Tests extension preservation, including casing and alternate choices. |
Review effort: Balanced
|
This pull request is merged. |
MartinZikmund
left a comment
There was a problem hiding this comment.
Thanks @mikernet, nice and tight fix. The download fallback now uses the same case-insensitive endsWith rule as FileSavePicker.ts, and multi-dot names (archive.tar.gz with .gz or .tar.gz) are handled sensibly too. I checked it against #25685: the two touch different parts of FileSavePicker.wasm.cs and merge cleanly. #25685's download tests use a bare Report name, so this PR doesn't affect them.
Optional nit: a data row or two for the append path (Report -> Report.pdf, and Report.txt with only a PDF choice -> Report.txt.pdf) would lock in the behavior the PR deliberately leaves unchanged.
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 247927 found UI Test snapshots differences: Details
|
The download picker still adds the first choice's extension when the suggested name doesn't end with any choice's extension, including a name with another extension. Lock that in next to the rows for names that keep their extension.
The Android and iOS builds of Uno.WinRT have no WasmPickerConfiguration, but they load every type of the runtime test assembly. The enum in the PickNameAsync state machine made that fail with a ReflectionTypeLoadException, so no runtime test ran on those targets. Pass the configuration by name and touch the enum only in a non-async helper's body.
Head branch was pushed to by a user without write access
|
Added the two rows for the append path in 22b71e0: The red Android and iOS lanes were caused by this PR. Every shard failed before running a single test, in The other two red jobs are unrelated:
|
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 248653 found UI Test snapshots differences: Details
|

GitHub Issue: closes #25671
PR Type:
🐞 Bugfix
What changed? 🚀
When the browser has no File System Access API (Firefox, Safari, Brave and others),
FileSavePickerfalls back to the download picker. That fallback always appended the firstFileTypeChoicesextension toSuggestedFileName, soReport.pdfwith a.pdfchoice was downloaded asReport.pdf.pdf.The download picker now follows the rule that the File System Access API path (
FileSavePicker.ts) and the Android picker already follow: a name that already ends with one of theFileTypeChoicesextensions (case-insensitive) is kept as is, with its own casing. Otherwise the first extension of the first choice is appended, as before.SuggestedFileNameFileTypeChoicesReport.pdf.pdfReport.pdf.pdfReport.pdfReport.PDF.pdfReport.PDF.pdfReport.PDFReport.txt.pdf; Text:.txt,.textReport.txt.pdfReport.txtReport.text.pdf; Text:.txt,.textReport.text.pdfReport.textReport.pdfReport.pdfReport.pdfReport.txt.pdfReport.txt.pdfReport.txt.pdf.pdf<GUID>.pdf<GUID>.pdfA name whose extension none of the choices has (
Report.txtwith only a PDF choice) still gets the first choice's extension appended, as on the File System Access API path and on Android. What the WinUI picker does with such a name isn't documented, so that case is unchanged.When
SuggestedSaveFileis set, the download picker still returns it, unchanged.The new
Given_FileSavePicker_Downloadruntime tests run on Skia WebAssembly only. They pick a file with the download picker and check its name. The picker returns its file without showing anything, so the tests run unattended. Four cases cover the names that keep their extension, and two the names that still get the first choice's extension (ReportandReport.txtwith only a PDF choice). I ran them locally (SamplesAppbrowserwasm, headless Chrome). Without the fix, the four keep cases fail (Report.pdf.pdf,Report.PDF.pdf,Report.txt.pdf,Report.text.pdf). With the fix, all six pass. The two append rows pass with and without the fix, since that behavior is unchanged; a mutation that keeps any name with an extension as is (Path.HasExtension) fails theReport.txtrow.WasmPickerConfigurationonly exists in the__CROSSRUNTIME__build of Uno.WinRT, while the runtime test assembly is also loaded on Android and iOS. The tests therefore pass the configuration by name and use the enum only inside a helper's body, so the assembly's types still load there.PR Checklist ✅
Screenshots Compare Test Runresults.