Add tests for XFA's JS global object.
Get coverage of Context_GlobalObjToString().
Change-Id: Ie98f8ea41213794f16ddd20bcf23cba503b9c3bd
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/66130
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/testing/resources/javascript/xfa_specific/xfa_globalobject.in b/testing/resources/javascript/xfa_specific/xfa_globalobject.in
new file mode 100644
index 0000000..7e6acbe
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/xfa_globalobject.in
@@ -0,0 +1,40 @@
+{{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">
+ app.alert('We search non-xfa global space on missing prop: ' + (app == xfa.app));
+ app.alert('Global toString says ' + toString());
+ app.alert('toString.apply to bad object is ' + toString.apply(xfa));
+ app.alert('toString.apply to bad non-xfa object is ' + toString.apply(app));
+ </script>
+ </event>
+ </subform>
+</template>
+endstream
+endobj
+{{include ../../xfa_locale_6_0.fragment}}
+{{include ../../xfa_postamble_7_0.fragment}}
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/javascript/xfa_specific/xfa_globalobject_expected.txt b/testing/resources/javascript/xfa_specific/xfa_globalobject_expected.txt
new file mode 100644
index 0000000..6384afe
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/xfa_globalobject_expected.txt
@@ -0,0 +1,4 @@
+Alert: We search non-xfa global space on missing prop: true
+Alert: Global toString says [object Root]
+Alert: toString.apply to bad object is [object Root]
+Alert: toString.apply to bad non-xfa object is [object Root]