Commit Graph

273 Commits

Author SHA1 Message Date
relrelb dd4b615e82 tests: Expand and format `as3_parse_int` 2022-06-23 01:07:15 +03:00
Callum Thomson 1310f433f2
avm2: Implement escape() toplevel (#7281)
* AVM2: Implement escape()

* chore: Fix formatting

* avm2: Escape resolves non strings to null and use push to append

* chore: Fix nits

* avm2: Escape should coerce objects, add early returns
2022-06-22 08:43:22 +03:00
relrelb a3ac9a7064 tests: Have at most one image per test
Previously image tests had an image per platform (i.e. Linux, Windows).
However, due to containing the LLVM version in their name, which
constantly updates on CI, and the fact that those images are actually
identical, unify them into a single `expected.png` image.
2022-06-21 08:03:25 +03:00
relrelb cc542e4aae tests: Add `as3_parse_float_swf10`
To cover the bug compatibility of `parseFloat`.
2022-06-21 08:02:40 +03:00
relrelb f7a0609b62 tests: Expand `as3_parse_float` 2022-06-21 08:02:40 +03:00
Aaron Hill 6d9d155b15 avm2: Use render_list instead of depth_list in most cases
The `render_list` for a container always contains all of the children
under both AVM1 and AVM2 - howver, the depth_list may not contain
some children under AVM2.

When we're not performing some AVM1-specific operation
(e.g. `getInstanceAtDepth`, or dumping out AVM1 variables),
we should be using the render list.
2022-06-11 00:59:18 +03:00
Aaron Hill 487017e7c5 avm2: Properly handle Dictionary enumerants
Previously, there was an off-by-one bug in `get_enumerant_name`,
which caused us to produce a spurious 'null' as a key.
However, the 'dictionary_foreach' test only checked that certain
keys were present, so the presence of an additional key didn't break
the test.

This commit makes Dictionary enumerants behave in the same way as
Array enumerants - all of the object-specific enumerants
(in this case, the non-primitive dicitonar keys) come first,
followed by 'base' enumerants from ScriptObject (in this case,
primtive/String keys). Additionally, `setPropertyIsEnumerable` is now
ignored for `Dictionary`, consistent with Flash's behavior.

The `dictionary_foreach` test is updated to print out all of
the keys when inspecting the dictionary. Since the enumeration
order is unstable (under both Flash and Ruffle) due to the dependency
on pointer hashing, the test sorts the keys before printing them.
This ensures that we get stable output which is consistent between
Ruffle and Flash.
2022-06-07 00:39:42 +02:00
Aaron Hill a4b3dbed79 avm2: Allow accessing `stage.loaderInfo.loaderURL`
Flash Player allows this, and returns the path to the root SWF file.
The test only checks that the returned path contains 'test.swf',
to avoid depending on a platform-specific path.
2022-06-06 22:08:54 +03:00
Aaron Hill 9e4d13f201 avm2: Make `Array.pop` actually pop from the back
The loop to search for a `non_hole` was missing
a `break;`, so it would actually find the *first*
non-hole, rather than than the last. This was not caught
by the test, since there was only one "real" element
in the array (the other one was set on 'Array.prototype')
2022-06-04 23:28:06 +03:00
Toad06 aad3ad6c08 tests: Add test for `Value::as_bool(String)` in SWFv6 2022-05-27 23:05:55 +03:00
Aaron Hill 15cb9a9ce6 Use `instance_scope` when making `super` method call
A method called with `super` is always an instance method,
so we should be using `instance_scope` for consistency with
`call_property`. This fixes a bug where a method cannot
access static class members (via `getlex`) when called bia
`super.method()`
2022-05-24 18:49:47 -06:00
relrelb a398c619a3 tests: Unignore `xml_inspect_xmldecl`
It passes now.
2022-05-20 18:46:19 -07:00
David Wendt e926af7796 core: Prevent recursive execution of frame scripts on the same movie clip.
To be clear, recursive execution of frame scripts between *different* movie clips is still allowed.
2022-05-20 18:37:42 -07:00
Aaron Hill eaeecfcfbc Adjust error message 2022-05-20 11:41:17 -07:00
Aaron Hill 8d8a7600d8 avm2: Partially implement `URLLoader` and related classes
This PR implements the `URLLoader` class, allowing AVM2 scripts
to load data from a URL. This requires several other related
classes (`URLLoaderDataFormat`, `URLRequest`, `IOError`) to be
implemented as well.

Currently implemented:
* Fetching from URLs using the 'navigator' backend
* The `text` and `binary` data formats (which store data
in a `String` or `ByteArray` respectively)
* The `open`, `complete`, and `ioError` events
* The `bytesLoaded`, `bytesTotal`, and `data` properties

Not yet implemented:
* The HTTP and security events
* All of the properties of `IOError`
* The properties on `URLRequest` (besides `url`)
* The "variables" data format

This should be enough to get some basic uses of `URLLoader` working
(e.g. simple GET requests to a particular website).

Note that in Flash's `playerglobal`, the `URLLoader` class is just
a think wrapper around the more general `URLStream`. However,
implementing `URLStream` will require changes to `Navigator``
to support notifications when data arrives in the stream. When
that happens, we should be able to re-use a large amount of the
code in this PR.
2022-05-20 11:41:17 -07:00
Toad06 7130c6c1c1 tests: Remove `Value::from_bool` 2022-05-19 20:24:53 -06:00
Toad06 78dcfe604d tests: `action_enumerate` can handle paths 2022-05-18 19:30:48 -07:00
Mike Welsh eb38b2fb00 tests: Add test for SWF5 function scope 2022-05-14 22:29:44 -07:00
Aaron Hill a453aa73af avm2: Don't consider declared return type for unchecked functions check
Testing under Flash shows that methods can be considered 'unchecked'
(allowing them to be called with more arguments than declared
parameters) even if they have a declared return type.

This is relied on by SteamBirds, which registers an event handler
which takes 0 parameters and an explicitly declared return type
2022-05-13 09:32:05 -07:00
Mike Welsh a940a0d357 tests: Add test for #768 2022-05-09 17:39:49 -07:00
dependabot[bot] 5c43dba766 build(deps): bump serde_json from 1.0.80 to 1.0.81
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.80 to 1.0.81.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.80...v1.0.81)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-09 13:42:53 -07:00
Mike Welsh cc8a88a570 tests: Add tests for ASSetPropFlags version gating 2022-05-07 10:25:10 -07:00
relrelb bcd35d6ad7 tests: Expand and cleanup `xml_namespaces`
Merge the `xml_node_namespaceuri` and `xml_node_weirdnamespace` tests
into `xml_namespaces`, cleanup, and expand it along the way.
2022-05-07 10:24:45 -07:00
relrelb bb0b56cff6 tests: Uncomment `array_sort` tests
They pass now.
2022-05-03 09:47:38 -07:00
dependabot[bot] 6375927d72 build(deps): bump serde_json from 1.0.79 to 1.0.80
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.79 to 1.0.80.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.79...v1.0.80)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-02 14:48:57 -07:00
dependabot[bot] c1bcc98668 build(deps): bump image from 0.24.1 to 0.24.2
Bumps [image](https://github.com/image-rs/image) from 0.24.1 to 0.24.2.
- [Release notes](https://github.com/image-rs/image/releases)
- [Changelog](https://github.com/image-rs/image/blob/master/CHANGES.md)
- [Commits](https://github.com/image-rs/image/commits/v0.24.2)

---
updated-dependencies:
- dependency-name: image
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-02 14:48:00 -07:00
dependabot[bot] 86e3f6c82a build(deps): bump serde from 1.0.136 to 1.0.137
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.136 to 1.0.137.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.136...v1.0.137)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-02 13:41:28 -07:00
Mike Welsh 1eb06908c8 core: Make PlayerBuilder::build infallible 2022-04-29 09:14:32 -07:00
Mike Welsh f48182ef3d core: Add various settings to PlayerBuilder 2022-04-29 09:14:32 -07:00
Mike Welsh e1e2b1008a core: Add PlayerBuilder 2022-04-29 09:14:32 -07:00
David Wendt 90da579835 tests: Tests should process events after a frame runs, otherwise we miss some at the start. 2022-04-25 16:29:07 -06:00
David Wendt d4dc440bb6 tests: Add a basic test for mouse clicks on AS2. 2022-04-25 16:29:07 -06:00
David Wendt 4c8443a464 tests: Add support for `input.json` files next to tests.
If the file is missing we treat it as if the file has no events to inject.
2022-04-25 16:29:07 -06:00
David Wendt 06410e97ba tests: Input files should be `Debug` 2022-04-25 16:29:07 -06:00
David Wendt e28ecbb647 tests: `InputInjector.next` must actually move up it's position index 2022-04-25 16:29:07 -06:00
David Wendt 952fee4ac0 tests: Add `InputInjector` type for opening and iterating an input file. 2022-04-25 16:29:07 -06:00
David Wendt ac86dee3a6 tests: Add a library defining the file format for Ruffle test input.
I intend to share this code across both Ruffle and FlashTAS (another project that allows running input tests on Flash Player), hence why it's a separate library from Ruffle's tests crate.
2022-04-25 16:29:07 -06:00
relrelb d27f1fb811 tests: Fix image tests
CI was upgraded to use LLVM 14.
Rename image tests (currently only color) to match it.
2022-04-23 00:07:56 -07:00
Mike Welsh cc9bdaaadb tests: Add test for sortOn with proto and virtual properties 2022-04-18 08:34:04 -07:00
Mike Welsh b83879c392 tests: Update reference images 2022-04-15 14:52:33 -07:00
Toad06 65d58f4733 tests: Add tests for `Add`, `Equals`, `Less` and `GetProperty` actions 2022-04-13 22:00:25 -07:00
Mike Welsh bd144194c3 tests: Add test for bool values in SWFv4 2022-04-10 20:03:39 -07:00
Mike Welsh 3d4d7a0ab5 tests: Add test for division in SWFv4 2022-04-09 23:17:39 -07:00
relrelb 7497fb7008 core: Change `Player::set_root_movie` to accept a `SwfMovie`
Move the `Arc::new` to within the function.
2022-04-08 15:16:25 -07:00
dependabot[bot] 2af8c851e2 build(deps): bump pretty_assertions from 1.2.0 to 1.2.1
Bumps [pretty_assertions](https://github.com/colin-kiegel/rust-pretty-assertions) from 1.2.0 to 1.2.1.
- [Release notes](https://github.com/colin-kiegel/rust-pretty-assertions/releases)
- [Changelog](https://github.com/colin-kiegel/rust-pretty-assertions/blob/main/CHANGELOG.md)
- [Commits](https://github.com/colin-kiegel/rust-pretty-assertions/compare/v1.2.0...v1.2.1)

---
updated-dependencies:
- dependency-name: pretty_assertions
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-04 18:43:37 -07:00
Toad06 0aff256c1a tests: `DefineLocal` also accepts dot and slash paths 2022-04-02 14:30:56 -07:00
relrelb 3a5e94dad2 tests: Expand `mcl_loadclip`
Test for invalid data loading.
2022-04-02 12:50:43 -07:00
Aaron Hill 4f23500779 avm2: Implement most of `flash.external.ExternalInterface`
This re-uses the logic we have for handling AVM1's `ExternalInterface`.
For now, serialization/deserialization of non-array objects is
left unimplemented.
2022-03-31 22:40:09 -07:00
Mike Welsh a9aaa0b0de tests: Add test for Add2 op 2022-03-31 16:57:07 -07:00
dependabot[bot] e5a3365957 build(deps): bump image from 0.23.14 to 0.24.1
Bumps [image](https://github.com/image-rs/image) from 0.23.14 to 0.24.1.
- [Release notes](https://github.com/image-rs/image/releases)
- [Changelog](https://github.com/image-rs/image/blob/master/CHANGES.md)
- [Commits](https://github.com/image-rs/image/commits)

---
updated-dependencies:
- dependency-name: image
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-30 08:55:55 +03:00