Commit Graph

163 Commits

Author SHA1 Message Date
Chris Midgley 868706d775
avm1: call watcher, if defined, from virtual properties on prototype (#4827)
* avm1: extract get_watcher

* tests: add tests for TextField text watch

* avm1: call the watcher, if defined, from call_setter

* dev: shadow variable to avoid unused mut warning

* dev: remove value mutability

* chore: cargo fmt

* dev: unify virtual and stored property watcher cases

* tests: add test for watching prototyped property

* feat: when getting old values, ascend the proto chain ignoring virtual properties

* chore: lint

* dev: share complicated code

* chore: Small cleanups

Co-authored-by: relrelb <relrelbachar@gmail.com>
2021-09-08 03:41:18 +03:00
David Wendt 34fe35a998 avm2: Impl `SoundMixer.bufferTime` 2021-09-03 16:47:02 -06:00
David Wendt 364ee62c92 avm2: Impl `SoundChannel`'s `soundComplete` event.
This includes a test that is currently ignored because `NullAudioBackend` can't fire complete events.
2021-09-03 16:47:02 -06:00
David Wendt efcab92d97 avm2: Impl `SoundMixer.stopAll` 2021-09-03 16:47:02 -06:00
David Wendt d73ba586d0 avm2: Impl `SoundChannel.stop()` 2021-09-03 16:47:02 -06:00
David Wendt 39305f6a38 avm2: Implement `SoundChannel.soundTransform` 2021-09-03 16:47:02 -06:00
David Wendt 6b7609ff4e avm2: Stub `SoundChannel.position`.
This also comes with an ignored test for `position`, because I originally believed this to be implementable.
2021-09-03 16:47:02 -06:00
David Wendt 116fb1f323 avm2: Impl `Sound.play`
This does not (yet) implement the third `SoundTransform` parameter on `play`.
2021-09-03 16:47:02 -06:00
David Wendt 3c3228f3c9 tests: Add tests for `SimpleButton.soundTransform` and `SoundMixer.soundTransform` 2021-09-03 16:47:02 -06:00
David Wendt 2f6e695483 avm2: Impl `Sprite.soundTransform` 2021-09-03 16:47:02 -06:00
David Wendt 66117450f5 tests: Add more coverage of `rightToLeft` as it disables `pan` 2021-09-03 16:47:02 -06:00
David Wendt 9926237074 tests: Add a test for AS3 `SoundTransform` properties 2021-09-03 16:47:02 -06:00
David Wendt b184273352 tests: Add some basic tests for the `Sound` class 2021-09-03 16:47:02 -06:00
David Wendt bf4492c454 avm2: Add the legacy Vector types that old movies can use.
This one was rather tough to test, as I actually can't generate ABCs in Animate CC that reference these classes. I instead had to modify a compiled SWF to open the package-internal namespace that these pre-specialized classes exist in.
2021-09-02 17:57:58 -06:00
David Wendt b452b653bf tests: Add a test for `Vector`'s instance initializer. 2021-09-02 17:57:58 -06:00
David Wendt aaddcc598f avm2: Impl `Vector.toLocaleString` and test `toString` 2021-09-02 17:57:58 -06:00
David Wendt dbc6f38c34 avm2: Impl `Vector.splice` 2021-09-02 17:57:58 -06:00
David Wendt 81d0775776 avm2: Impl `Vector.sort` 2021-09-02 17:57:58 -06:00
David Wendt 44a9f13047 avm2: Impl `Vector.slice` 2021-09-02 17:57:58 -06:00
David Wendt 077fd87842 avm2: Impl `Vector.reverse` 2021-09-02 17:57:58 -06:00
David Wendt aa2d729a44 avm2: Impl `Vector.removeAt` 2021-09-02 17:57:58 -06:00
David Wendt cea580e7c0 tests: Ensure we're testing push/shift/etc with empty vectors 2021-09-02 17:57:58 -06:00
David Wendt a053015558 avm2: Impl `Vector.insertAt` 2021-09-02 17:57:58 -06:00
David Wendt e3ad30a0f7 tests: Consolidate all of the type variants of each test into one test per function. 2021-09-02 17:57:58 -06:00
David Wendt 1cfa9e0b28 avm2: Impl `Vector.push` and `.pop` 2021-09-02 17:57:58 -06:00
David Wendt 6350ce2dde avm2: Impl `Vector.map` 2021-09-02 17:57:58 -06:00
David Wendt 7628b2b49a avm2: Impl `Vector.lastIndexOf` (and the weird backward-index behavior of `indexOf`) 2021-09-02 17:57:58 -06:00
David Wendt 4624157ae0 avm2: Impl `Vector.indexOf` 2021-09-02 17:57:58 -06:00
David Wendt c06a3c10d8 avm2: Impl `Vector.filter` 2021-09-02 17:57:58 -06:00
David Wendt 97e6f55110 avm2: Impl `Vector.every` 2021-09-02 17:57:58 -06:00
David Wendt 01904acad3 tests: Add `Vector.<T>.join` tests 2021-09-02 17:57:58 -06:00
David Wendt f255c7d577 tests: Add tests for multi-dimensional vector coercion typechecks & concatenation 2021-09-02 17:57:58 -06:00
David Wendt ecf514969b tests: Add a test for concatenating to lists of ES4 interfaces. 2021-09-02 17:57:58 -06:00
David Wendt 8740098e5d tests: Recompile the `vector_es4class_concat` test 2021-09-02 17:57:58 -06:00
David Wendt 70b60d6bb4 tests: Recompile the concat test 2021-09-02 17:57:58 -06:00
David Wendt 9a1b864988 tests: Add tests for `Vector.concat` 2021-09-02 17:57:58 -06:00
David Wendt 176f05a16b tests: Recompile a handful of miscompiled tests 2021-09-02 17:57:58 -06:00
David Wendt 1711400f07 tests: Actually enable all the vector tests I've been running 2021-09-02 17:57:58 -06:00
David Wendt f6ea1b2bff tests: Add a test for the `delete` operator 2021-09-02 17:57:58 -06:00
David Wendt f3cf82ad5a tests: Add test for sticking ES3 classes in a `Vector.<Object>` 2021-09-02 17:57:58 -06:00
David Wendt e65958cc22 tests: Add another test for subclass and superclass storage 2021-09-02 17:57:58 -06:00
David Wendt 2af5192893 tests: Add tests for vector holes and set coercion 2021-09-02 17:57:58 -06:00
David Wendt 9a3c4e6adb tests: Here's a very basic test for int access 2021-09-02 17:57:58 -06:00
David Wendt 4cf407da7e tests: Add a test for symbol class association on buttons, both for timeline-constructed and AVM-constructed buttons. 2021-08-31 21:21:54 -06:00
David Wendt 587c423027 tests: Remove garbage in `font_embedded` test, too 2021-08-30 17:53:39 -06:00
David Wendt 6c3c930954 tests: Remove garbage character in `font_hasglyphs` test 2021-08-30 17:53:39 -06:00
David Wendt 2d57bed82e avm2: Impl `Font.hasGlyphs` 2021-08-30 17:53:39 -06:00
David Wendt 37af9be533 avm2: Implement `Font` for embedded fonts. 2021-08-30 17:53:39 -06:00
Adrian Wielgosik 945bce4a85 xml: Use forked quick-xml to support loose entity parsing 2021-08-30 19:08:22 +02:00
EmperorBale 830c2b541f tests: Add test for getQualifiedSuperclassName 2021-08-29 20:41:20 -06:00
EmperorBale a2a73c0278 tests: Improve getDefinitionByName test 2021-08-29 20:41:20 -06:00
EmperorBale 34e9443a3b tests: Add test for getQualifiedClassName 2021-08-29 20:41:20 -06:00
EmperorBale 70ffc8c224 tests: Add test for getDefinitionByName 2021-08-29 20:41:20 -06:00
David Wendt 24086af276 tests: Restore the "original" source code of the AVM1 rectangle test and reapply all modifications made to it to produce the AVM2 test 2021-08-23 16:40:32 -06:00
lukaszN cf3f02a9ce avm2: add tests for Rectangle 2021-08-23 15:44:14 -06:00
lukaszN 65eb6f3dfd avm2: Add flash.geom.Rectangle tests 2021-08-23 15:44:14 -06:00
Tal Hayon 7b9049cedf core: Add DefineBinaryData and SymbolClass connection (Part of #1368) 2021-08-21 12:24:46 -06:00
relrelb 9d174825c9 tests: Expand add_property 2021-08-21 17:23:15 +03:00
Chris Midgley 58c907e985
avm2: implement string.split for undefined (#5064)
* avm2: implement string.split for undefined

* chore: cargo fmt

* dev: avoid explicit ArrayStorage
2021-08-18 18:02:41 +02:00
Adrian Wielgosik 5dee7f163c Add new tests for avm2 string.split() 2021-08-14 00:52:38 +02:00
relrelb 3641822f7d tests: Expand object_prototypes 2021-07-30 17:42:42 -07:00
Mike Welsh 8a2298bd8f chore: Bump mesa-vulkan-drivers version 2021-07-22 00:30:18 -07:00
Aaron Hill 068e06e40f Add support for image comparison tests 2021-07-21 21:48:24 -07:00
EmperorBale 38ae630aac tests: Add test for generateRandomBytes 2021-07-21 18:09:21 +02:00
David Wendt ddd73b3cd6 avm2: Supercalls should fall back to normal receiver access if there is no matching supertrait to use. 2021-07-20 22:12:31 -04:00
David Wendt b2c1299f79 tests: Add a test for bare calls on the ES4 class object 2021-07-20 22:12:28 -04:00
David Wendt 21a994ee8a tests: Actually run the `istypelate_coerce` test 2021-07-20 22:05:37 -04:00
David Wendt e38b1bc281 avm2: Make numbers appear to be of any numeric type that can represent them.
This also prevents an exception from being fired when testing `undefined` or `null`, which are valid inputs to `istype`.
2021-07-20 22:05:35 -04:00
David Wendt 974fe152ff avm2: Include the parameter coercions into `op_coerce` 2021-07-20 22:05:34 -04:00
David Wendt 2d3ef5493b tests: Add tests for default parameters, type checks, and implicit typecheck coercions 2021-07-20 22:05:33 -04:00
dependabot[bot] ca2d17ade6 chore: Bump env_logger from 0.8.4 to 0.9.0
Bumps [env_logger](https://github.com/env-logger-rs/env_logger) from 0.8.4 to 0.9.0.
- [Release notes](https://github.com/env-logger-rs/env_logger/releases)
- [Changelog](https://github.com/env-logger-rs/env_logger/blob/main/CHANGELOG.md)
- [Commits](https://github.com/env-logger-rs/env_logger/compare/v0.8.4...v0.9.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-19 23:49:40 +03:00
relrelb 3ddd8ff31c tests: Add as_set_prop_flags 2021-07-18 20:03:52 +03:00
Callum Thomson 939d467897
avm1: Correct ToInteger
* Coerce objects as well.
* Wrap numbers around i32.
2021-07-09 03:39:07 +03:00
Chris Midgley ac0fc40345
avm1: implement scroll, maxscroll and bottomScroll for TextField (#4698)
* tests: add tests for scroll

* avm1: implement scroll, maxscroll, bottomScroll

* chore: fmt

* docs: note that scroll is 1-based

* fix: non-word wrapped text with manual breaks is scrollable

* chore: move magic number to const

* chore: avoid mut with extra if

* chore: moving clamping behaviour into core

* refactor: eagerly compute line data

* fix: make scroll work when text is aligned right

* chore: clippy

* docs: add more information about line_data

* tests: add more test cases for scroll
2021-07-08 19:23:30 +02:00
EmperorBale d334e30259
avm1: Fix apply_to_display_object (#4377) (#4743)
* avm1: Fix apply_to_display_object
2021-07-06 17:32:14 +02:00
relrelb b44f3f2c15 tests: Turn array_vs_object_length into array_length 2021-06-22 10:43:10 -07:00
relrelb 814ce4c265 tests: Merge array_apply into array_constructor 2021-06-22 10:43:10 -07:00
relrelb ff7ccfa43e tests: Enable negative array length in array_constructor 2021-06-22 10:43:10 -07:00
relrelb c383b70336 avm1: Merge array_function with constructor 2021-06-22 10:43:10 -07:00
Chris Midgley b7de03b5c8
avm1: implement hscroll and maxhscroll for TextField 2021-06-22 01:43:02 -07:00
EmperorBale 1ee61cca57
avm2: ByteArray updates 2021-06-22 01:26:27 -07:00
Mike Welsh e0a478163b tests: Add test for PlaceObjectAction::Replace during goto 2021-06-16 20:57:43 -07:00
Mike Welsh 6146502b1a tests: Add test for SetTarget on a removed clip 2021-06-14 14:04:28 -07:00
Mike Welsh 76603d5554 tests: Add test for execution order 2021-06-14 14:04:28 -07:00
Mike Welsh cb136e56bb tests: Change button_order test to 2 frames
In Flash, the trace actually occurs on the 2nd frame. Frame 1 is
when the clips are actually loaded. Previously this inaccurately
happened on frame 1 in Ruffle, but now happens correctly on frame
2.
2021-06-14 14:04:28 -07:00
Mike Welsh 1f96af6b64 core: Add Avm1::exec_list to manage global list of display objects 2021-06-14 14:04:28 -07:00
dependabot[bot] cf4a1136c5 chore: Bump env_logger from 0.8.3 to 0.8.4
Bumps [env_logger](https://github.com/env-logger-rs/env_logger) from 0.8.3 to 0.8.4.
- [Release notes](https://github.com/env-logger-rs/env_logger/releases)
- [Changelog](https://github.com/env-logger-rs/env_logger/blob/main/CHANGELOG.md)
- [Commits](https://github.com/env-logger-rs/env_logger/compare/v0.8.3...v0.8.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-14 00:47:57 -07:00
Mike Welsh 5135b14023 tests: Add test for PlaceObject replace 2021-06-08 19:47:16 -07:00
Mike Welsh 5acc476789 tests: Add test for DefineFunction case sensitivity 2021-06-08 16:51:59 -07:00
dependabot[bot] 2f1dc0cbb1 chore: Bump approx from 0.4.0 to 0.5.0
Bumps [approx](https://github.com/brendanzab/approx) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/brendanzab/approx/releases)
- [Commits](https://github.com/brendanzab/approx/compare/v0.4.0...v0.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-07 11:30:59 -07:00
Adam Gashlin 79aabb3aa7 tests: Test attachMovie scaling 2021-06-02 23:28:24 -07:00
Mike Welsh 2b98c878f0 swf: Use Fixed in more places 2021-05-30 21:24:03 -07:00
Adrian Wielgosik 34d54dbc05
avm1: Fix string methods handling of negative args (fix #4437)
* Improve string.substr handling of negative args
* Add tests for more substr() combinations
2021-05-30 12:04:17 -07:00
Mike Welsh b4dd64a568 tests: Add test for overriding Object.prototype.toString 2021-05-24 17:52:15 -07:00
Mike Welsh 3ddb97d2f6 core: Add SwfMovie::frame_rate and num_frames 2021-05-23 23:02:38 -07:00
Mike Welsh e1439f4105 swf: Add HeaderExt struct providing additional info
When reading an SWF, search for FileAttributes and
SetBackgroundColor and return this along with the header data
because it's useful (in particular, the AS3 flag).
2021-05-23 23:02:38 -07:00
David Wendt b383aec78d tests: Move the button tests into the new test directory. 2021-05-16 17:53:07 -07:00
David Wendt 71bb0c901a avm2: Impl the constructor parameters for `SimpleButton` 2021-05-16 17:53:07 -07:00
David Wendt e4a6a10038 tests: Add tests for what children see as their parent when constructed or shuffled between movie clips and buttons 2021-05-16 17:53:07 -07:00
David Wendt d7deaf5e00 tests: Add currently-failing tests for the `SimpleButton` constructor and order-of-events. 2021-05-16 17:53:07 -07:00