XFA: Test resolving variables cross-variables context

Attempt to cover a portion of CFXJSE_Engine::QueryVariablesValue() by
introducing variables in different contexts whose names shadow each
other. We should be able to refer to each set via a specific script
node associated with each context.

The test unfortunately is based on trying to cover program logic
rather than a specification of correct behaviour. In particular,
requiring a script to be parented by a variables context (script3
in the test) is questionable.

Change-Id: I098845e75442e93e26fbf7f954a0a0d18e9705ed
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/67930
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/testing/resources/javascript/xfa_specific/xfa_variables.in b/testing/resources/javascript/xfa_specific/xfa_variables.in
index e812aed..429e663 100644
--- a/testing/resources/javascript/xfa_specific/xfa_variables.in
+++ b/testing/resources/javascript/xfa_specific/xfa_variables.in
@@ -27,16 +27,39 @@
       </pageArea>
     </pageSet>
     <event activity="docReady" ref="$host">
-      <script contentType="application/x-javascript">
+      <script name="my_script" contentType="application/x-javascript">
         try {
           app.alert('We search variables context ' + (xx01.value + xx02.value));
           app.alert('We search variables context ' + (xx03.value + xx04.value));
+          var script1 = xfa.resolveNode('template..my_script');
+          var script2 = xfa.resolveNode('template..their_script');
+          var script3 = xfa.resolveNode('template..other_script');
+          app.alert('We resolve off of script1 ' + (script1.xx01.value + script1.xx02.value));
+          app.alert('We resolve off of script2 ' + (script2.xx01.value + script2.xx02.value));
+          app.alert('We resolve off of script3 ' + (script3.xx01.value + script3.xx02.value));
+          app.alert('We resolve off of script1 ' + script1.nonesuch);
+          app.alert('We resolve off of script2 ' + script2.nonesuch);
+          app.alert('We resolve off of script3 ' + script3.nonesuch);
         } catch (e) {
           app.alert('Error: ' + e);
         }
       </script>
     </event>
   </subform>
+  <subform layout="tb" name="their_doc">
+    <variables>
+      <text name="xx01">78</text>
+      <text name="xx02">90</text>
+      <integer name="xx03">78</integer>
+      <integer name="xx04">90</integer>
+      <script name="other_script">
+        var xx01 = "chips";
+      </script>
+    </variables>
+    <script name="their_script">
+      var xx01 = "clams";
+    </script>
+  </subform>
 </template>
 endstream
 endobj
diff --git a/testing/resources/javascript/xfa_specific/xfa_variables_expected.txt b/testing/resources/javascript/xfa_specific/xfa_variables_expected.txt
index 1931ce7..bdb521c 100644
--- a/testing/resources/javascript/xfa_specific/xfa_variables_expected.txt
+++ b/testing/resources/javascript/xfa_specific/xfa_variables_expected.txt
@@ -1,2 +1,8 @@
 Alert: We search variables context 123456
 Alert: We search variables context 579
+Alert: We resolve off of script1 123456
+Alert: We resolve off of script2 7890
+Alert: We resolve off of script3 7890
+Alert: We resolve off of script1 undefined
+Alert: We resolve off of script2 undefined
+Alert: We resolve off of script3 undefined