Call CJX_Template methods from JavaScript.
These methods are mostly no-ops, but ensure they do not crash
when called.
Change-Id: I3da331fbe50c85b45a00aa5ab7a1f5d6a6cce3d2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/66310
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/testing/resources/javascript/xfa_specific/xfa_template.in b/testing/resources/javascript/xfa_specific/xfa_template.in
new file mode 100644
index 0000000..60ad46d
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/xfa_template.in
@@ -0,0 +1,60 @@
+{{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}} <<
+ {{streamlen}}
+>>
+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"><![CDATA[
+ {{include ../expect.js}}
+ template0 = xfa.resolveNode("#template");
+ expect("template0.className", "template");
+
+ expectError("template0.execCalculate(1)");
+ expect("template0.execCalculate()", false);
+
+ expectError("template0.execInitialize(1)", false);
+ expect("template0.execInitialize()", false);
+
+ expectError("template0.execValidate(1)", false);
+ expect("template0.execValidate()", false);
+
+ expectError("template0.formNodes()", undefined);
+ expectError("template0.formNodes(1, 2)", undefined);
+ expect("template0.formNodes(true)", true);
+
+ expectError("template0.recalculate()", undefined);
+ expectError("template0.recalculate(1, 2)", undefined);
+ expect("template0.recalculate(true)", true);
+
+ expectError("template0.remerge(1)", undefined);
+ expect("template0.remerge()", undefined);
+ ]]></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_template_expected.txt b/testing/resources/javascript/xfa_specific/xfa_template_expected.txt
new file mode 100644
index 0000000..9bb1ffd
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/xfa_template_expected.txt
@@ -0,0 +1,15 @@
+Alert: PASS: template0.className = template
+Alert: PASS: template0.execCalculate(1) threw XFAObject.execCalculate: Incorrect number of parameters passed to function.
+Alert: PASS: template0.execCalculate() = false
+Alert: PASS: template0.execInitialize(1) threw XFAObject.execInitialize: Incorrect number of parameters passed to function.
+Alert: PASS: template0.execInitialize() = false
+Alert: PASS: template0.execValidate(1) threw XFAObject.execValidate: Incorrect number of parameters passed to function.
+Alert: PASS: template0.execValidate() = false
+Alert: PASS: template0.formNodes() threw XFAObject.formNodes: Incorrect number of parameters passed to function.
+Alert: PASS: template0.formNodes(1, 2) threw XFAObject.formNodes: Incorrect number of parameters passed to function.
+Alert: PASS: template0.formNodes(true) = true
+Alert: PASS: template0.recalculate() threw XFAObject.recalculate: Incorrect number of parameters passed to function.
+Alert: PASS: template0.recalculate(1, 2) threw XFAObject.recalculate: Incorrect number of parameters passed to function.
+Alert: PASS: template0.recalculate(true) = true
+Alert: PASS: template0.remerge(1) threw XFAObject.remerge: Incorrect number of parameters passed to function.
+Alert: PASS: template0.remerge() = undefined