From 68c5024f21a85912f6fea16438709c5fdffd83b5 Mon Sep 17 00:00:00 2001 From: Lord-McSweeney Date: Wed, 19 Jul 2023 05:15:29 -0700 Subject: [PATCH] tests: Add test for LocalConnection.send --- .../avm2/globals/flash/net/local_connection.rs | 5 +++-- .../swfs/avm2/localconnection_send/output.txt | 4 ++++ .../tests/swfs/avm2/localconnection_send/test.swf | Bin 0 -> 690 bytes .../swfs/avm2/localconnection_send/test.toml | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 tests/tests/swfs/avm2/localconnection_send/output.txt create mode 100644 tests/tests/swfs/avm2/localconnection_send/test.swf create mode 100644 tests/tests/swfs/avm2/localconnection_send/test.toml diff --git a/core/src/avm2/globals/flash/net/local_connection.rs b/core/src/avm2/globals/flash/net/local_connection.rs index 85453fee1..15d35274b 100644 --- a/core/src/avm2/globals/flash/net/local_connection.rs +++ b/core/src/avm2/globals/flash/net/local_connection.rs @@ -40,7 +40,7 @@ pub fn send<'gc>( if matches!(args.get_value(0), Value::Null) { return Err(Error::AvmError(type_error( activation, - &format!("Error #2007: Parameter connectionName must be non-null."), + "Error #2007: Parameter connectionName must be non-null.", 2007, )?)); } @@ -48,7 +48,7 @@ pub fn send<'gc>( if matches!(args.get_value(1), Value::Null) { return Err(Error::AvmError(type_error( activation, - &format!("Error #2007: Parameter methodName must be non-null."), + "Error #2007: Parameter methodName must be non-null.", 2007, )?)); } @@ -66,6 +66,7 @@ pub fn send<'gc>( ], )?; + // FIXME: Adding the event listener after calling `send` works in FP. Avm2::dispatch_event(&mut activation.context, event, this); Ok(Value::Undefined) diff --git a/tests/tests/swfs/avm2/localconnection_send/output.txt b/tests/tests/swfs/avm2/localconnection_send/output.txt new file mode 100644 index 000000000..e475e0c51 --- /dev/null +++ b/tests/tests/swfs/avm2/localconnection_send/output.txt @@ -0,0 +1,4 @@ +TypeError: Error #2007: Parameter connectionName must be non-null. +TypeError: Error #2007: Parameter connectionName must be non-null. +TypeError: Error #2007: Parameter methodName must be non-null. +[StatusEvent type="status" bubbles=false cancelable=false eventPhase=2 code=null level="error"] diff --git a/tests/tests/swfs/avm2/localconnection_send/test.swf b/tests/tests/swfs/avm2/localconnection_send/test.swf new file mode 100644 index 0000000000000000000000000000000000000000..f11658a83409fe8082a8322229a1082ac6b1fe20 GIT binary patch literal 690 zcmV;j0!{rxS5px{1ONbdoQ+h?Zqq;z-dWq(_$Rf~rfx`EnnFrZ8zn0$amcAC4OLJ{ zgi?uu6cH!cG)9hH#hVIlJOF17ocbobLV5rmqmNM5v8WnAs4L5!`F6f<=3A}&0V(eg zGA|Iy0y;=15kggbeSQ5cqswTvj#Q58%;yp0@ZOM(jaZvSXsAZ*%hAg`3VMzwRDHp517D5He8#oj z4Y)ElSLJ5j%sd{?TbKv`J^jXf(O+Ix|0A+?+ezgQn=@x6CoE84N^Lw2#&XE~zA|K< z7bsjbVaunCznVCnJ8)UQDzw6eGh%wII^nJt;!2*dh+97}8_h=Tq~1ENHIA#zMk6s| zd>HgCr{AA-K5|3OgrP*p9X<*5*6cIeGIk3yOHOozWW>VIIc1AUu(2X#B|Bjowz-0H z>D*#&DVNDD=j@!Mtl0M@z$pw#Rnv{sf+U-kO|V3;tV%!>g(!q5NusDk(MUokWPv0t zg0lqQBRHq7VUk`~vslezf*+E^mb#6_9mNPx28+v?!cl?%WK|Y{BybS}5($91J*91_ zgK0;loh0oL+DXukLOZf}PSAS1hHxkZFxGYB3bF{b&C8}4VOWy%%ukroD|m#^6