From 2f98da44fb23750bf1b0d02dc964ecb9979d1bfd Mon Sep 17 00:00:00 2001 From: sleepycatcoding <131554884+sleepycatcoding@users.noreply.github.com> Date: Fri, 18 Aug 2023 19:56:24 +0300 Subject: [PATCH] avm2: String.indexOf returns -1 when passed in undefined --- core/src/avm2/globals/string.rs | 2 +- .../tests/swfs/from_avmplus/ecma3/String/e15_5_4_6_1/test.toml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/core/src/avm2/globals/string.rs b/core/src/avm2/globals/string.rs index 8b68592025f7..cd0664f5c9da 100644 --- a/core/src/avm2/globals/string.rs +++ b/core/src/avm2/globals/string.rs @@ -201,7 +201,7 @@ fn index_of<'gc>( ) -> Result, Error<'gc>> { let this = Value::from(this).coerce_to_string(activation)?; let pattern = match args.get(0) { - None => return Ok(Value::Undefined), + None => return Ok(Value::Integer(-1)), Some(s) => s.clone().coerce_to_string(activation)?, }; diff --git a/tests/tests/swfs/from_avmplus/ecma3/String/e15_5_4_6_1/test.toml b/tests/tests/swfs/from_avmplus/ecma3/String/e15_5_4_6_1/test.toml index 29f3cef79022..cf6123969a1d 100644 --- a/tests/tests/swfs/from_avmplus/ecma3/String/e15_5_4_6_1/test.toml +++ b/tests/tests/swfs/from_avmplus/ecma3/String/e15_5_4_6_1/test.toml @@ -1,2 +1 @@ num_ticks = 1 -known_failure = true