ruffle icon indicating copy to clipboard operation
ruffle copied to clipboard

avm1: Partially implement FileReference

Open CUB3D opened this issue 2 years ago • 0 comments

This partially implements flash.net.FileReference (#307), based of @hatal175's initial work on implementing browse from around 2021.

Implements:

  • browse
    • The file picker is provided via the AsyncFileDialog crate on all platforms.
  • download
    • Does not support authentication, which is apparently supported in the Flash Player browser Plugin.
    • Only implemented for Ruffle desktop currently as AsyncFileDialog does not support save_file on WASM.
    • Does not report intermediate progress to listeners, a single onProgress callback is ran after the download has completed
  • upload
    • Does not support authentication.
    • Does not report intermediate progress.

Does not implement:

  • cancel
    • Neither downloads, nor uploads can be canceled whilst they are in progress

In addition to adding the above, the test harnesses have been updated to allow simulating successful / failed requests, via a new TestNavigatorBackend and dialog interactions can be simulated via the TestUiBackend allowing regression tests for the new functionality.

On web platforms, the ability to upload is dependent on cors configuration for the destination which may still prevent some content from working.

Whilst implementing this, care has been taken to match the ordering for the callbacks that Flash Player invokes in erroneous conditions, however there may still be some differences in some scenarios. To facilitate this, NavigatorBackend::fetch has been updated to return a FetchError containing error details.

Remaining:

  • [x] Appease clippy
  • [x] Clean up some todos
  • [x] Testing harness changes
  • [x] Download tests
  • [x] Upload tests
  • [x] Browse tests
  • [x] dates should actually be Dates
  • [x] Correct confusing callbacks
  • [x] Update web UI backend
  • [x] Test on other platforms
  • [x] rebase

CUB3D avatar Aug 08 '22 03:08 CUB3D

Thanks for the patience here, this one's a little chunky but I'll take some time to review it this week

Herschel avatar Sep 07 '22 02:09 Herschel