Add JavaScript test for CJX_Tree object.
Change-Id: I69ebdc3518fb62c15f11494f9ad355d4b7775f62
Reviewed-on: https://pdfium-review.googlesource.com/c/50353
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/testing/resources/javascript/xfa_specific/xfa_tree.in b/testing/resources/javascript/xfa_specific/xfa_tree.in
new file mode 100644
index 0000000..0eee37a
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/xfa_tree.in
@@ -0,0 +1,52 @@
+{{header}}
+{{include ../../xfa_catalog_1_0.fragment}}
+{{include ../../xfa_object_2_0.fragment}}
+{{include ../../xfa_preamble_3_0.fragment}}
+{{include ../../xfa_config_4_0.fragment}}
+{{object 5 0}} <<
+>>
+stream
+<template>
+ <subform layout="tb" name="my_doc">
+ <pageSet id="page" relation="orderedOccurrence">
+ <occur initial="1" max="1" min="1"/>
+ <pageArea id="Page1" name="Page1">
+ <occur max="1" min="1"/>
+ <contentArea h="100mm" w="200mm" x="0.25in" y="0.25in"/>
+ </pageArea>
+ <pageArea id="Page2" name="Page2">
+ <occur max="1" min="1"/>
+ <contentArea h="100mm" w="200mm" x="0.25in" y="0.25in"/>
+ </pageArea>
+ </pageSet>
+ <event activity="docReady" ref="$host">
+ <script contentType="application/x-javascript">
+ {{include ../expect.js}}
+ {{include ../property_test_helpers.js}}
+ testROProperty(xfa.form, "all", "[object XFAObject]");
+ testROProperty(xfa.form, "classAll", "[object XFAObject]");
+ testROProperty(xfa.form, "classIndex", 0);
+ testROProperty(xfa.form, "index", 0);
+ testROProperty(xfa.form, "nodes", "[object XFAObject]");
+ testROProperty(xfa.form, "parent", "[object XFAObject]");
+ testROProperty(xfa.form, "somExpression", "xfa[0].form[0]");
+ expect("typeof xfa.form.resolveNode", "function");
+ expect("typeof xfa.form.resolveNodes", "function");
+ expectError("xfa.form.resolveNode()");
+ expect("xfa.form.resolveNode('bogus')", null);
+ expectError("xfa.form.resolveNodes()");
+ expect("xfa.form.resolveNodes('bogus')", "[object XFAObject]");
+ expect("xfa.form.resolveNodes('bogus').length", 0);
+ </script>
+ </event>
+ </subform>
+</template>
+endstream
+endobj
+{{include ../../xfa_locale_6_0.fragment}}
+{{include ../../xfa_postamble_7_0.fragment}}
+{{include ../../xfa_pages_8_0.fragment}}
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/javascript/xfa_specific/xfa_tree_expected.txt b/testing/resources/javascript/xfa_specific/xfa_tree_expected.txt
new file mode 100644
index 0000000..dd1ef25
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/xfa_tree_expected.txt
@@ -0,0 +1,21 @@
+Alert: PASS: all = [object XFAObject]
+Alert: PASS: all threw Error: Invalid property set operation.
+Alert: PASS: classAll = [object XFAObject]
+Alert: PASS: classAll threw Error: Invalid property set operation.
+Alert: PASS: classIndex = 0
+Alert: PASS: classIndex threw Error: Invalid property set operation.
+Alert: PASS: index = 0
+Alert: PASS: index threw Error: Invalid property set operation.
+Alert: PASS: nodes = [object XFAObject]
+Alert: PASS: nodes threw Error: Unable to set
+Alert: PASS: parent = [object XFAObject]
+Alert: PASS: parent threw Error: Invalid property set operation.
+Alert: PASS: somExpression = xfa[0].form[0]
+Alert: PASS: somExpression threw Error: Invalid property set operation.
+Alert: PASS: typeof xfa.form.resolveNode = function
+Alert: PASS: typeof xfa.form.resolveNodes = function
+Alert: PASS: xfa.form.resolveNode() threw XFAObject.resolveNode: Incorrect number of parameters passed to function.
+Alert: PASS: xfa.form.resolveNode('bogus') = null
+Alert: PASS: xfa.form.resolveNodes() threw XFAObject.resolveNodes: Incorrect number of parameters passed to function.
+Alert: PASS: xfa.form.resolveNodes('bogus') = [object XFAObject]
+Alert: PASS: xfa.form.resolveNodes('bogus').length = 0