Commit Graph

151 Commits

Author SHA1 Message Date
David Wendt bb879870ec Add test for the constructor property on v6 and v7 SWFs 2020-04-25 13:25:21 -04:00
Nathan Adams b3322acc8c tests: Copy as2_super_and_this test for manual prototype setting, used by mx (currently broken) 2020-04-25 13:25:20 -04:00
David Wendt aaa6f481ac Add a v6 version of the super-and-this test, which is exactly the same source compiled to SWF version 6. 2020-04-25 13:25:20 -04:00
David Wendt 869cbd17da Extend `as2_super_and_this` to cover accessing object properties in super-methods, super-getters, and super-setters. 2020-04-25 13:25:18 -04:00
David Wendt 15a19f4cf8 Add test from @Dinnerbone that checks to make sure super-called functions can still initialize the object they are a part of. 2020-04-25 13:25:17 -04:00
Mike Welsh bad34c4d8f tests: Fix tests for regressions caused by #498
Changes to the action queue caused actions queued during other
actions to run too late. These regressions weren't caught by the
tests because many of the goto tests ran for more frames than was
necessary, allowing the late actions to still run.
2020-04-25 03:06:54 -07:00
Nathan Adams a673e7108d tests: Add test for movieclip.createEmptyMovieClip().attachMovie()` 2020-04-21 05:49:25 -07:00
Nathan Adams 6316d7e0b3 tests: Add (currently failing) test for init order when combined with register_class 2020-04-17 23:48:58 -07:00
Nathan Adams d0fd26a89c avm1: Fix panic with [].unshift(x) 2020-04-17 21:17:13 -07:00
Mike Welsh 47e936fcc2 tests: Add tests for Array.sort 2020-04-01 18:46:12 -07:00
Mike Welsh 2bdbac9247 tests: Test that Color has no effect when target is undefined 2020-03-30 01:09:05 -07:00
Mike Welsh 4ea609cca1 tests: Don't special case enumeration tests 2020-03-28 16:22:02 -07:00
Mike Welsh 81a0bb370b tests: Add test for SWF<=6 case insensitivty 2020-03-28 16:22:02 -07:00
Mike Welsh 4df1128c19
core: Implement Object.registerClass (merge #344)
Implement Object.registerClass
2020-03-25 18:55:49 -07:00
Nathan Adams b4624fddce avm1: GetVariable and SetVariable look through the scope chain. Fixes #414
GetVariable and SetVariable attempt to resolve paths on each scope
in the scope chain.
2020-03-19 19:58:16 -07:00
Nathan Adams 7bed4d4940 chore: Document each trace in attach_movie avm1 tests 2020-02-29 23:05:17 +01:00
Nathan Adams 041bb6b44c avm1: Implement `Object.registerClass` 2020-02-29 23:05:17 +01:00
Mike Welsh 223edb9bc1 core: Matrix translation is in twips 2020-02-26 12:47:47 -08:00
Mike Welsh a917fa4028 tests: Add temporary test for MovieClip.getRect
This is just testing that it exists and returns the same values as
getBounds for shapes without strokes.

TODO: When it is properly implemented for strokes, add stroked
shapes to testing.
2020-02-24 14:12:48 -08:00
Mike Welsh 73a9a0e771 tests: Add test for MovieClip.getBounds 2020-02-24 14:12:48 -08:00
David Wendt 9adf0f43d7 Allow levels to be read as scope variables, and add a test for this. 2020-02-22 00:02:50 -05:00
David Wendt 5a7e530c91 Add a test for cross-movie `_root`.
This test does not pass yet. Other layers need to resolve as target paths in order for this to happen.
2020-02-22 00:02:48 -05:00
David Wendt aab339880d Implement `XML.load()`, with tests.
Interestingly enough, very little actually has to be done inside the async process for XML. The async process basically just fetches data and fires an event handler when it's done. Everything else is handled via a system builtin, `XML.onData`.
2020-02-22 00:02:45 -05:00
David Wendt 538a5f05e5 Add tests for various forms of `loadVariables`.
Surprisingly enough these tests passed without any changes, somehow.
2020-02-22 00:02:43 -05:00
David Wendt c00ecccd1f Basic, stub implementation of `MovieClipLoader.getProgress`, plus test.
This implementation just returns the size of the current loaded movie. The test is also deliberately written to be loose on timings so that it likely won't see a partially loaded movie. (I don't want it to be a test of load events, so I just wait a few frames, rather than the correct way of waiting for `onLoadComplete`.)

Until we support streaming file loads, we can't faithfully support these properties. Still, it's better to have them, just in case.
2020-02-22 00:02:42 -05:00
David Wendt 3f7e3a9ed8 Implement `MovieClipLoader.unloadClip`, with tests. 2020-02-22 00:02:41 -05:00
David Wendt a132226da4 Run `onLoadInit` at the *end* of a frame, rather than before the movie clip's own actions.
This is technically better, but it may make more sense to trigger `ClipEvent::Load` at the start of the next frame instead. Furthermore, I don't know if other forms of load events should trigger on the next frame (or end of the current one) like this.
2020-02-22 00:02:39 -05:00
David Wendt 55734619f7 `GetUrl2` can accept a `DisplayObject` as target in `LoadTargetFlag` mode.
I have no idea what happens to non-MovieClip objects, or if I'm really supposed to `coerce_to_string` here.
2020-02-22 00:02:36 -05:00
David Wendt d49c0e9bf7 Rewrite some of the unload and cliploader tests to be more generous with load timing.
Loads in Flash Player, like all web technologies, are asynchronous tasks of some kind (probably a separate thread). They appear to operate on some kind of a delay. If I `trace` each frame out, like in the previous version of `mcl_loadclip`, you get a series of events that look like this:

1. Parent frame 1
2. Parent frame 2
3. Event: onLoadStart
4. Event: onLoadProgress
5. Event: onLoadComplete
6. Parent frame 3
7. Event: onLoadInit

If I run that version of the test on Ruffle, everything happens after frame 1. This is an artifact of how we're testing asynchronous behavior in Ruffle. In order to guarantee test determinism, we have a dummy implementation of `fetch` that does a blocking load, and we poll all futures every frame of execution. This means that there is a very specific order of execution with these tests, which is good for testing, but probably isn't 100% accurate.

Flash Player appears to delay all loads by at least one frame, even loads that are coming from disk which should load immediately. I don't know if this is intentional or not, so I don't want to implement a load delay just for the sake of making tests pass. Ergo, I'm loosening the tests to just test the ability to load and unload movies, and fire events from a loader.

Specifically:

1. `mcl_loadclip` no longer traces out frames of the parent timeline
2. `unloadmovie` et. all use a target movie that doesn't fail the test until 10 frames have passed.

If someone can find a movie network that breaks with fast loading, then I'll consider implementing explicit frame delays for async tasks. Otherwise, this is how we're testing this.
2020-02-22 00:01:22 -05:00
David Wendt 8ece2d1b31 Add another ignored test, this time measuring the timing of load events broadcasted by `MovieClipLoader`. We're loading too early, which is why this is ignored. 2020-02-22 00:01:20 -05:00
David Wendt 8ef4a94672 Add new tests for `unloadMovie`, `unloadMovieNum`, and `MovieClip.unloadMovie`.
They currently fail in Ruffle, so they're ignored.
2020-02-22 00:01:18 -05:00
David Wendt cc5dff4254 Add a test for `MovieClip.loadMovie`. 2020-02-22 00:01:17 -05:00
David Wendt 82d305a0f5 Add test for `loadmovienum` 2020-02-22 00:01:16 -05:00
David Wendt a9621da47d Add tests for `loadMovie`.
This test also includes changes to the SWF testing environment to allow asynchronous movie loads to execute.
2020-02-22 00:01:15 -05:00
David Wendt db41bec91e Implement `MovieClipLoader`'s `addListener`, `removeListener`, and `broadcastMessage` methods.
Interestingly, this constitutes an implementation of `AsBroadcaster`. It appears Macromedia decided to implement event handling on `MovieClipLoader` in a very similar fashion to `AsBroadcaster`, down to invoking `broadcastMessage` and searching a `_listeners` property for listeners.
2020-02-22 00:01:12 -05:00
David Wendt 55149b7b7e Reference count the Player and provide a weak reference in UpdateContext.
This allows the formation of `'static` futures that can still interact with a player. Async code will need to upgrade the weak reference in order to be able to interact with the player.
2020-02-21 23:44:06 -05:00
Mike Welsh dc1f99e2ba tests: Add test for misdocumented DefineFunction2 register preload 2020-02-20 12:58:26 -08:00
Mike Welsh 10fb6c7c04 tests: Add define_function2_preload test 2020-02-19 23:22:33 -08:00
Mike Welsh dfde98da7d tests: Add tests for coercing undefined to string in SWF6 2020-02-19 10:47:43 -08:00
Mike Welsh 452ac84f0e tests: Uncomment Number.POSITIVE_INFINITY/Number.NEGATIVE_INFINITY tests 2020-02-18 10:17:55 -08:00
Mike Welsh 324dd1c5e4 tests: Add swf_tests_approx macro
Use this macro to test numeric calculations that might have some
variance using approx_eq.
2020-02-17 15:42:29 -08:00
Mike Welsh b6249cdb73 tests: Add localToGlobal/globalToLocal test 2020-02-17 15:42:29 -08:00
Mike Welsh 3a1a73ae11 tests: Add more tests for display object properties
Add more _x = weirdo value tests, and copy the test into a v6 SWF.
(because undefined etc. can coerce to 0 instead of NaN in SWFv6).
2020-02-14 15:34:14 -08:00
Mike Welsh 19df074a79 tests: Add more tests for AVM1 Color object
Include not defined values, wrapping values, invalid values.
2020-02-13 18:06:27 -08:00
Mike Welsh 4d1f7c4d4a tests: Add movieclip depth method tests 2020-01-31 19:44:42 -08:00
Mike Welsh a835573f3c tests: Add test for global GotoFrame action 2020-01-30 15:17:01 -08:00
Mike Welsh 81a1c05682 tests: Add goto_execution_order2 regression test
Tests execution order of children added during a goto.
2020-01-28 04:15:08 -08:00
Mike Welsh 69f19f03c4 avm1: Output trace warning for invalid SetTarget (fix #332) 2020-01-27 23:35:41 -08:00
Mike Welsh 0446644742 tests: Add target_path test 2020-01-27 23:35:41 -08:00
David Wendt 8eeb9a5c60 This technically isn't a test of `toString`, so remove stuff from the test that it relies upon. 2020-01-27 21:50:11 -05:00