ruffle icon indicating copy to clipboard operation
ruffle copied to clipboard

web: Download the file on FileReference.save

Open kjarosh opened this issue 9 months ago • 0 comments

Fixes https://github.com/ruffle-rs/ruffle/issues/14949.

This PR adds support for saving files on web using FileReference. When writing data, a download is triggered with the default file name. Currently, there's no dialog that lets the user select save destination.

This PR also ensures that all implementations of FileDialogResult behave the same way: desktop, web, and tests. The methods write and refresh have been merged into one: write_and_refresh, which allows the tests and web implementations behave the same way as desktop.

Two tests were added:

  1. avm2/filereference_save_and_browse — This test verifies how FileReference behaves when a browse (and load) operations are triggered after save. Additionally, it marks the commented out code related to reporting file size as FIXME, because the current implementation reports the size at all times, instead of only after saving.
  2. avm2/filereference_save_and_load — This test ensures that the error 2037 is thrown when load is called after save. It's currently a known failure as Ruffle is not as strict as FP regarding throwing the error 2037.

kjarosh avatar Apr 30 '24 20:04 kjarosh