Skip to content

avm1: Implement FileReferenceList#23889

Merged
SuchAFuriousDeath merged 3 commits into
ruffle-rs:masterfrom
SuchAFuriousDeath:avm1-file-reference-list
Jun 15, 2026
Merged

avm1: Implement FileReferenceList#23889
SuchAFuriousDeath merged 3 commits into
ruffle-rs:masterfrom
SuchAFuriousDeath:avm1-file-reference-list

Conversation

@SuchAFuriousDeath

@SuchAFuriousDeath SuchAFuriousDeath commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Description

Significantly progresses #308.
Supersedes #7637.

Testing

Tests are included.

Checklist

  • I, a human, have self-reviewed this PR and fully understand the changes within.
  • I have made or updated tests where possible.
  • All of my commits are properly scoped, compile successfully, and pass all tests.
  • This PR does not make sense to split up into smaller PRs.
  • An LLM was involved in the authoring of this code.

@SuchAFuriousDeath SuchAFuriousDeath added A-avm1 Area: AVM1 (ActionScript 1 & 2) T-compat Type: Compatibility with Flash Player labels Jun 3, 2026
@SuchAFuriousDeath SuchAFuriousDeath force-pushed the avm1-file-reference-list branch from cb12135 to d699c0e Compare June 3, 2026 17:10
@danielhjacobs

Copy link
Copy Markdown
Contributor

Presumably supersedes #7637?

@SuchAFuriousDeath

Copy link
Copy Markdown
Collaborator Author

Presumably supersedes #7637?

It does indeed.

Comment thread core/src/avm1/globals/utils.rs Outdated
Comment thread core/src/avm1/globals/file_reference.rs
Comment thread tests/tests/swfs/avm1/file_reference_list_browse_invalid_filters/test.as Outdated
Comment thread core/src/avm1/globals/file_reference_list.rs Outdated
Comment thread tests/tests/swfs/avm1/file_reference_list_browse_invalid_filters/test.as Outdated
@SuchAFuriousDeath SuchAFuriousDeath force-pushed the avm1-file-reference-list branch from 4ae0a28 to d65b5a2 Compare June 7, 2026 11:03
@SuchAFuriousDeath SuchAFuriousDeath requested a review from kjarosh June 7, 2026 12:15
@SuchAFuriousDeath SuchAFuriousDeath marked this pull request as draft June 8, 2026 09:12
@SuchAFuriousDeath SuchAFuriousDeath force-pushed the avm1-file-reference-list branch from d65b5a2 to a292c11 Compare June 9, 2026 09:41
@SuchAFuriousDeath SuchAFuriousDeath marked this pull request as ready for review June 9, 2026 09:49
@SuchAFuriousDeath SuchAFuriousDeath force-pushed the avm1-file-reference-list branch 2 times, most recently from b9b6022 to e25e125 Compare June 10, 2026 09:58

@Lord-McSweeney Lord-McSweeney left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change core::avm1::globals::file_reference::constructor to use FileReferenceObject::new instead of manually constructing the FileReferenceObject?

@SuchAFuriousDeath

Copy link
Copy Markdown
Collaborator Author

Could you change core::avm1::globals::file_reference::constructor to use FileReferenceObject::new instead of manually constructing the FileReferenceObject?

Done 🫡

@SuchAFuriousDeath SuchAFuriousDeath force-pushed the avm1-file-reference-list branch 2 times, most recently from d643388 to 3b023af Compare June 12, 2026 20:24
Comment thread core/src/avm1/globals/file_reference.rs Outdated
@SuchAFuriousDeath SuchAFuriousDeath force-pushed the avm1-file-reference-list branch from 3b023af to 30e110e Compare June 13, 2026 08:28
Comment thread core/src/avm1/globals/file_reference.rs Outdated
@SuchAFuriousDeath SuchAFuriousDeath force-pushed the avm1-file-reference-list branch from 30e110e to 056bb00 Compare June 15, 2026 07:50
@SuchAFuriousDeath SuchAFuriousDeath enabled auto-merge (rebase) June 15, 2026 07:53
Preparation for `FileReferenceList` support. Two pieces of glue around
the file dialog that are about to grow a second caller are pulled out:

- `parse_file_filters` handles the `FileFilter[]` argument to
  `FileReference.browse` / `FileReferenceList.browse`. The inline parser
  in `FileReference.browse` is replaced by it. The helper reads filter
  fields via `has_own_property` + `Object.get` so that prototype-only
  fields are ignored and virtual `addProperty` getters are invoked
  (matching Flash). Invalid filter arrays now bail with `false` from
  `browse()` consistently, including when the argument is a non-Object
  value.
- `broadcast_avm1_file_event` in `loader.rs` wraps the
  `as_broadcaster::broadcast_internal` call used to dispatch `onSelect`
  / `onCancel`. `select_file_dialog_avm1` is updated to use it.
`flash.net.FileReferenceList` now supports `browse(filters)`, which
opens a multi-file picker via `UiBackend::display_file_open_dialog_multiple`
and populates `fileList` (read-only) with `FileReference` instances on
success, then dispatches `onSelect` / `onCancel` through the AsBroadcaster.

Selection results are wired through `loader::select_multi_file_dialog_avm1`,
which mirrors `select_file_dialog_avm1` and reuses the existing
`run_file_dialog` and `broadcast_avm1_file_event` helpers.
Three tests covering `FileReferenceList.browse`:

- `browse_cancel` — bare `browse()` hits the test backend's cancel
  path; assert `onCancel` fires and `fileList` stays `undefined`.
- `browse_select` — `debug-select-success` magic filter triggers a
  3-file fake selection; assert `onSelect` fires with `fileList`
  populated.
- `browse_invalid_filters` — covers every early-bail path in
  `parse_file_filters`, plus edge cases for prototype-only filter
  fields, `addProperty` getters, and `toString` throwing during
  string coercion of `description` / `extension`.
@SuchAFuriousDeath SuchAFuriousDeath force-pushed the avm1-file-reference-list branch from 056bb00 to 42c0a3e Compare June 15, 2026 08:04
@SuchAFuriousDeath SuchAFuriousDeath merged commit 476fcd0 into ruffle-rs:master Jun 15, 2026
24 of 26 checks passed
@SuchAFuriousDeath SuchAFuriousDeath deleted the avm1-file-reference-list branch June 15, 2026 08:40
@ROBERT-MCDOWELL

Copy link
Copy Markdown

@SuchAFuriousDeath the browse event still not working so I cannot select multiple files for upload. about download, it works but the progress event is not fired so the progressbar never reaches 100%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-avm1 Area: AVM1 (ActionScript 1 & 2) T-compat Type: Compatibility with Flash Player

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants