diff --git a/core/src/avm2/globals/XML.as b/core/src/avm2/globals/XML.as index 942fe1bcc328..53b2a233c8b0 100644 --- a/core/src/avm2/globals/XML.as +++ b/core/src/avm2/globals/XML.as @@ -68,6 +68,7 @@ package { AS3 native function child(name:*):XMLList; AS3 native function childIndex():int; AS3 native function children():XMLList; + AS3 native function contains(value:*):Boolean; AS3 native function copy():XML; AS3 native function parent():*; AS3 native function elements(name:* = "*"):XMLList; @@ -171,6 +172,11 @@ package { return self.AS3::children(); }; + prototype.contains = function(value:*):Boolean { + var self:XML = this; + return self.AS3::contains(value); + }; + prototype.copy = function():XML { var self:XML = this; return self.AS3::copy(); diff --git a/core/src/avm2/globals/xml.rs b/core/src/avm2/globals/xml.rs index 90cfd29a27dd..c6c2b286c4c6 100644 --- a/core/src/avm2/globals/xml.rs +++ b/core/src/avm2/globals/xml.rs @@ -336,6 +336,21 @@ pub fn children<'gc>( .into()) } +pub fn contains<'gc>( + _activation: &mut Activation<'_, 'gc>, + this: Object<'gc>, + args: &[Value<'gc>], +) -> Result, Error<'gc>> { + let xml = this.as_xml_object().unwrap(); + let value = args.get_value(0); + + if let Some(other) = value.as_object().and_then(|obj| obj.as_xml_object()) { + let result = xml.node().equals(&other.node()); + return Ok(result.into()); + } + Ok(false.into()) +} + pub fn copy<'gc>( activation: &mut Activation<'_, 'gc>, this: Object<'gc>, diff --git a/tests/tests/swfs/from_avmplus/e4x/XMLList/e13_5_1/test.toml b/tests/tests/swfs/from_avmplus/e4x/XMLList/e13_5_1/test.toml index 29f3cef79022..cf6123969a1d 100644 --- a/tests/tests/swfs/from_avmplus/e4x/XMLList/e13_5_1/test.toml +++ b/tests/tests/swfs/from_avmplus/e4x/XMLList/e13_5_1/test.toml @@ -1,2 +1 @@ num_ticks = 1 -known_failure = true