diff --git a/core/src/avm1/globals/xml.rs b/core/src/avm1/globals/xml.rs index 9883a85bf..92b906b72 100644 --- a/core/src/avm1/globals/xml.rs +++ b/core/src/avm1/globals/xml.rs @@ -278,6 +278,27 @@ pub fn create_xmlnode_proto<'gc>( None, ReadOnly.into(), ); + xmlnode_proto.add_property( + gc_context, + "parentNode", + Executable::Native(|avm, ac, this: Object<'gc>, _args| { + if let Some(node) = this.as_xml_node() { + return Ok(node + .parent() + .unwrap_or(None) + .map(|mut parent| { + parent + .script_object(ac.gc_context, Some(avm.prototypes.xml_node)) + .into() + }) + .unwrap_or_else(|| Value::Null.into())); + } + + Ok(Value::Undefined.into()) + }), + None, + ReadOnly.into(), + ); xmlnode_proto .as_script_object() .unwrap() diff --git a/core/tests/regression_tests.rs b/core/tests/regression_tests.rs index 532a04816..38bc7f85c 100644 --- a/core/tests/regression_tests.rs +++ b/core/tests/regression_tests.rs @@ -110,6 +110,7 @@ swf_tests! { (xml_clone_expandos, "avm1/xml_clone_expandos", 1), (xml_has_child_nodes, "avm1/xml_has_child_nodes", 1), (xml_first_last_child, "avm1/xml_first_last_child", 1), + (xml_parent_and_child, "avm1/xml_parent_and_child", 1), } #[test] diff --git a/core/tests/swfs/avm1/xml_parent_and_child/output.txt b/core/tests/swfs/avm1/xml_parent_and_child/output.txt new file mode 100644 index 000000000..f3d0b0b66 --- /dev/null +++ b/core/tests/swfs/avm1/xml_parent_and_child/output.txt @@ -0,0 +1,5 @@ +true +true +true +true +null diff --git a/core/tests/swfs/avm1/xml_parent_and_child/test.fla b/core/tests/swfs/avm1/xml_parent_and_child/test.fla new file mode 100644 index 000000000..7aff39241 Binary files /dev/null and b/core/tests/swfs/avm1/xml_parent_and_child/test.fla differ diff --git a/core/tests/swfs/avm1/xml_parent_and_child/test.swf b/core/tests/swfs/avm1/xml_parent_and_child/test.swf new file mode 100644 index 000000000..1a1655f86 Binary files /dev/null and b/core/tests/swfs/avm1/xml_parent_and_child/test.swf differ