Add test cases for several recently fixed XFA bugs.

Backfilling some tests that I had not taken the time to convert
to our template format.

Change-Id: Ib848a267c1fbb0ed1da846eef555c85a7ec23862
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/66813
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/testing/resources/javascript/xfa_specific/bug_1039629.evt b/testing/resources/javascript/xfa_specific/bug_1039629.evt
new file mode 100644
index 0000000..aa5fcb1
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/bug_1039629.evt
@@ -0,0 +1,3 @@
+mousedown,left,295,187

+mouseup,left,295,187

+keycode,40
\ No newline at end of file
diff --git a/testing/resources/javascript/xfa_specific/bug_1039629.in b/testing/resources/javascript/xfa_specific/bug_1039629.in
new file mode 100644
index 0000000..a911db6
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/bug_1039629.in
@@ -0,0 +1,188 @@
+{{header}}
+{{object 1 0}} <<
+  /Type /Catalog
+  /AcroForm 3 0 R
+  /Pages 5 0 R
+  /NeedsRendering true
+>>
+endobj
+{{object 3 0}} <<
+  /XFA [
+    (preamble) 7 0 R
+    (config) 8 0 R
+    (template) 9 0 R
+    (form) 10 0 R
+    (postamble) 11 0 R
+  ]
+>>
+endobj
+{{object 5 0}} <<
+  /Type /Pages
+  /Count 1
+  /Kids [ 12 0 R ]
+>>
+endobj
+{{object 7 0}} <<
+  {{streamlen}}
+>>
+stream
+<?xml version="1.0" encoding="UTF-8"?>
+<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/" timeStamp="2007-08-07T18:35:24Z" uuid="3b6c6ea3-3edf-40f5-90ff-51ee202e15b4">
+endstream
+endobj
+{{object 8 0}} <<
+  {{streamlen}}
+>>
+stream
+<config xmlns="http://www.xfa.org/schema/xci/2.6/">
+  <agent name="designer">
+    <destination>pdf</destination>
+    <pdf>
+      <!--  [0..n]  -->
+      <fontInfo/>
+    </pdf>
+  </agent>
+  <present>
+    <!--  [0..n]  -->
+    <pdf>
+      <!--  [0..n]  -->
+      <version>1.7</version>
+      <renderPolicy>client</renderPolicy>
+      <creator>Adobe LiveCycle Designer ES 8.1</creator>
+      <producer>Adobe LiveCycle Designer ES 8.1</producer>
+      <scriptModel>XFA</scriptModel>
+      <interactive>1</interactive>
+      <tagged>1</tagged>
+      <fontInfo>
+        <embed>1</embed>
+      </fontInfo>
+      <compression>
+        <level>6</level>
+        <compressLogicalStructure>1</compressLogicalStructure>
+      </compression>
+      <linearized>1</linearized>
+      <viewerPreferences>
+        <addViewerPreferences>0</addViewerPreferences>
+        <duplexOption>simplex</duplexOption>
+        <numberOfCopies>0</numberOfCopies>
+      </viewerPreferences>
+    </pdf>
+    <cache>
+      <macroCache/>
+      <renderCache/>
+    </cache>
+    <incrementalMerge/>
+    <script>
+      <runScripts/>
+      <exclude/>
+      <currentPage/>
+    </script>
+    <copies/>
+    <layout/>
+    <xdp>
+      <packets>*</packets>
+    </xdp>
+    <destination>pdf</destination>
+  </present>
+  <psMap/>
+  <acrobat>
+    <acrobat7>
+      <dynamicRender>required</dynamicRender>
+    </acrobat7>
+  </acrobat>
+</config>
+endstream
+endobj
+{{object 9 0}} <<
+  {{streamlen}}
+>>
+stream
+<template xmlns="http://www.xfa.org/schema/xfa-template/2.6/">
+  <subform name="form1">
+    <pageSet>
+      <pageArea id="Page1" name="Page1">
+        <contentArea h="10.5in" w="8in" x="0.25in" y="0.25in"/>
+        <medium long="11in" short="8.5in" stock="letter"/>
+      </pageArea>
+    </pageSet>
+    <subform h="10.5in" w="8in">
+      <field h="9.0001mm" name="ChoiceList" w="47.625mm" x="6.35mm" y="92.075mm">
+        <ui>
+          <choiceList/>
+        </ui>
+        <items>
+          <text>Foo</text>
+        </items>
+      </field>
+      <field h="100mm" name="ChoiceList1" w="100mm" x="0mm" y="0mm">
+      <ui>
+        <choiceList open="onEntry"/>
+      </ui>
+      <items>
+        <text>1111111111111</text>
+        <text>222222222222222</text>
+      </items>
+      <event activity="change">
+        <script contentType="application/x-javascript">
+        a += 1;
+        if (a == 2) {
+            list1 = xfa.resolveNode("ChoiceList");
+            xfa.host.setFocus(list1);
+            xfa.template.remerge();
+            xfa.host.openList(list1);
+        }
+        </script>
+      </event>
+    </field>
+  </subform>
+    <event activity="docReady">
+      <script contentType="application/x-javascript">
+        a = 0;
+      </script>
+    </event>
+  </subform>
+</template>
+endstream
+endobj
+{{object 10 0}} <<
+  {{streamlen}}
+>>
+stream
+<form xmlns="http://www.xfa.org/schema/xfa-form/2.6/">
+</form>
+endstream
+endobj
+{{object 11 0}} <<
+  {{streamlen}}
+>>
+stream
+</xdp:xdp>
+endstream
+endobj
+{{object 12 0}} <<
+  /Type /Page
+  /Contents 13 0 R
+  /CropBox [ 0.0 0.0 612.0 792.0 ]
+  /MediaBox [ 0.0 0.0 612.0 792.0 ]
+  /Parent 5 0 R
+  /Resources <<
+    /Font <<
+      /T1_0 14 0 R
+    >>
+    /ProcSet [ /PDF /Text ]
+  >>
+  /Rotate 0
+  /StructParents 0
+>>
+endobj
+{{object 14 0}} <<
+  /Type /Font
+  /Subtype /Type1
+  /BaseFont /Helvetica
+  /Encoding /WinAnsiEncoding
+>>
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/javascript/xfa_specific/bug_1040329.in b/testing/resources/javascript/xfa_specific/bug_1040329.in
new file mode 100644
index 0000000..7117084
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/bug_1040329.in
@@ -0,0 +1,99 @@
+{{header}}
+{{object 1 0}} <<
+  /Pages 2 0 R
+  /NeedsRendering true
+  /AcroForm <</XFA 5 0 R>>
+  /OpenAction 3 0 R
+  /Type /Catalog
+>>
+endobj
+{{object 2 0}} <<
+  /Type /Pages
+  /Count 1
+  /Kids [ 4 0 R ]
+>>
+endobj
+{{object 3 0}} <<
+  /S /JavaScript
+  /JS (
+  )
+>>
+endobj
+{{object 4 0}} <<
+  /Type /Page
+  /Parent 2 0 R
+  /MediaBox [ 0 0 795 842 ]
+>>
+endobj
+{{object 5 0}} <<
+  {{streamlen}}
+>>
+stream
+<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
+<template >
+  <subform allowMacro="0" layout="lr" mergeMode="consumeData" name="subform_0" >
+    <pageSet >
+      <occur initial="1" max="10" min="0" ></occur>
+      <pageArea >
+        <contentArea h="0.75in" w="0.25in" x="0.25in" y="0.25in" ></contentArea>
+        <subform allowMacro="0" layout="row" mergeMode="consumeData" name="subform_1" >
+          <event activity="initialize" >
+            <script contentType="application/x-javascript">
+            </script>
+          </event>
+          <field name="field_1" >
+            <bind match="dataRef" ref="a" ></bind>
+            <calculate >
+              <script contentType="application/x-javascript">
+                var f=xfa.resolveNode("xfa.form.subform_0");
+                xfa.host.setFocus(f);
+                f.mark ="square";
+              </script>
+            </calculate>
+            <event activity="docReady" >
+              <script contentType="application/x-javascript">
+                xfa.host.resetData(this);
+              </script>
+            </event>
+          </field>
+        </subform>
+      </pageArea>
+    </pageSet>
+    <field name="field_2" >
+      <bind match="dataRef" ref="a" ></bind>
+      <calculate >
+        <script contentType="application/x-javascript">
+          xfa.host.setFocus(this);
+        </script>
+      </calculate>
+      <items presence="hidden" save="0" >
+        <text >a</text>
+        <text >b</text>
+        <text >c</text>
+      </items>
+      <ui >
+        <choiceList commitOn="exit" open="onEntry" textEntry="1" ></choiceList>
+      </ui>
+      <value override="0" >
+        <text >a</text>
+      </value>
+      <event activity="initialize" >
+        <script contentType="application/x-javascript">
+        </script>
+      </event>
+      <event activity="change" >
+        <script contentType="application/x-javascript">
+          xfa.form.remerge();
+          xfa.host.openList(this);
+        </script>
+      </event>
+    </field>
+  </subform>
+</template>
+</xdp:xdp>
+endstream
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/javascript/xfa_specific/bug_1043508.in b/testing/resources/javascript/xfa_specific/bug_1043508.in
new file mode 100644
index 0000000..2afe129
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/bug_1043508.in
@@ -0,0 +1,62 @@
+{{header}}
+{{object 1 0}} <<
+  /Type /Catalog
+  /Pages 2 0 R
+  /AcroForm <<
+    /XFA 4 0 R
+  >>
+  /NeedsRendering true
+>>
+endobj
+{{object 2 0}} <<
+  /Type /Pages
+  /Count 1
+  /Kids [3 0 R]
+>>
+endobj
+{{object 3 0}} <<
+  /Type /Page
+  /Parent 2 0 R
+  /MediaBox [0 0 3 3]
+>>
+endobj
+{{object 4 0}} <<
+  {{streamlen}}
+>>
+stream
+<xdp xmlns="http://ns.adobe.com/xdp/">
+<config>
+  <acrobat>
+    <acrobat7>
+      <dynamicRender>required</dynamicRender>
+    </acrobat7>
+  </acrobat>
+</config>
+<template>
+  <subform>
+    <breakBefore>
+      <script>
+        $.#field[1]=2
+      </script>
+    </breakBefore>
+    <field>
+      <ui>
+        <choiceList open="multiSelect"></choiceList>
+      </ui>
+    </field>
+    <field>
+      <event activity="change">
+        <script>
+          $host.openList(&quot;$form.#field[0]&quot;)
+        </script>
+      </event>
+    </field>
+  </subform>
+</template>
+</xdp>
+endstream
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
\ No newline at end of file
diff --git a/testing/resources/javascript/xfa_specific/bug_1052651.evt b/testing/resources/javascript/xfa_specific/bug_1052651.evt
new file mode 100644
index 0000000..e88ef06
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/bug_1052651.evt
@@ -0,0 +1,4 @@
+mousemove,100,100
+mousedown,left,100,100
+mouseup,left,100,100
+charcode,96
diff --git a/testing/resources/javascript/xfa_specific/bug_1052651.in b/testing/resources/javascript/xfa_specific/bug_1052651.in
new file mode 100644
index 0000000..a26312d
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/bug_1052651.in
@@ -0,0 +1,168 @@
+{{header}}
+{{object 1 0}} <<
+  /Type /Catalog
+  /AcroForm 3 0 R
+  /Pages 5 0 R
+  /NeedsRendering true
+>>
+endobj
+{{object 3 0}} <<
+  /DA (/Helv 0 Tf 0 g )
+  /DR <<
+    /Font <<
+      /Helv 9 0 R
+    >>
+  >>
+  /XFA [
+    (preamble) 10 0 R
+    (config) 11 0 R
+    (template) 12 0 R
+    (form) 13 0 R
+    (postamble) 14 0 R
+  ]
+>>
+endobj
+{{object 5 0}}  <<
+  /Type /Pages
+  /Count 1
+  /Kids [6 0 R]
+>>
+endobj
+{{object 6 0}} <<
+  /Type /Page
+  /CropBox [0.0 0.0 612.0 792.0]
+  /MediaBox [0.0 0.0 612.0 792.0]
+  /Parent 5 0 R
+  /Resources <<
+    /ProcSet [/PDF /Text]
+  >>
+  /Rotate 0
+  /StructParents 0
+>>
+endobj
+{{object 8 0}} <<
+  /Type /Font
+  /Subtype /Type1
+  /BaseFont /Helvetica
+  /Encoding /WinAnsiEncoding
+>>
+endobj
+{{object 9 0}} <<
+  /Type /Font
+  /Subtype /Type1
+  /BaseFont /Helvetica
+  /Encoding /WinAnsiEncoding
+>>
+endobj
+{{object 10 0}} <<
+  {{streamlen}}
+>>
+stream
+<?xml version="1.0" encoding="UTF-8"?>
+<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
+endstream
+endobj
+{{object 11 0}} <<
+  {{streamlen}}
+>>
+stream
+<config xmlns="http://www.xfa.org/schema/xci/2.6/">
+  <agent name="designer">
+    <destination>pdf</destination>
+    <pdf>
+      <fontInfo/>
+    </pdf>
+  </agent>
+  <present>
+    <pdf>
+      <version>1.7</version>
+      <renderPolicy>client</renderPolicy>
+      <scriptModel>XFA</scriptModel>
+      <interactive>1</interactive>
+    </pdf>
+    <xdp>
+      <packets>*</packets>
+    </xdp>
+    <destination>pdf</destination>
+  </present>
+  <acrobat>
+    <acrobat7>
+      <dynamicRender>required</dynamicRender>
+    </acrobat7>
+  </acrobat>
+</config>
+endstream
+endobj
+{{object 12 0}} <<
+  {{streamlen}}
+>>
+stream
+<template xmlns="http://www.xfa.org/schema/xfa-template/2.6/">
+  <subform layout="tb" locale="en_US" name="form1" restoreState="auto">
+    <pageSet>
+      <pageArea id="Page1" name="Page1">
+        <contentArea h="10.5in" w="8in" x="0.25in" y="0.25in"/>
+        <medium long="11in" short="8.5in" stock="letter"/>
+      </pageArea>
+    </pageSet>
+    <subform h="10.5in" w="8in" name="subform2">
+      <field h="9.0001mm" name="field1" w="47.625mm" x="6.35mm" y="92.075mm">
+        <ui>
+          <choiceList/>
+        </ui>
+        <items save="1">
+          <text>Single</text>
+          <text>Married</text>
+          <text>Other</text>
+        </items>
+      </field>
+      <field name="field2" h="200mm" w="200mm" x="1mm" y="1mm">
+        <ui>
+          <textEdit/>
+        </ui>
+        <value>
+          <text>pdfium</text>
+        </value>
+        <event activity="change">
+          <script contentType="application/x-javascript">
+            f2_change = f2_change + 1;
+            if (f2_change == 2) {
+                xfa.event.cancelAction = true;
+                f1 = xfa.resolveNode("xfa.form..field1");
+                xfa.host.setFocus(f1);
+                xfa.template.remerge();
+                xfa.host.openList(f1);
+            }
+          </script>
+        </event>
+      </field>
+    </subform>
+    <event activity="docReady">
+      <script contentType="application/x-javascript">
+        f2_change = 0;
+        f2 = xfa.resolveNode("xfa.form..field2");
+        xfa.host.setFocus(f2);
+     </script>
+    </event>
+  </subform>
+</template>
+endstream
+endobj
+{{object 13 0}} <<
+  {{streamlen}}
+>>
+stream
+<form xmlns="http://www.xfa.org/schema/xfa-form/2.6/"></form>
+endstream
+endobj
+{{object 14 0}} <<
+ {{streamlen}}
+>>
+stream
+</xdp:xdp>
+endstream
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/javascript/xfa_specific/bug_1052786.in b/testing/resources/javascript/xfa_specific/bug_1052786.in
new file mode 100644
index 0000000..b9dd5e9
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/bug_1052786.in
@@ -0,0 +1,168 @@
+{{header}}
+{{object 1 0}} <<
+  /Type /Catalog
+  /AcroForm 3 0 R
+  /Pages 5 0 R
+  /NeedsRendering true
+>>
+endobj
+{{object 3 0}} <<
+  /DA (/Helv 0 Tf 0 g )
+  /DR <<
+    /Font <<
+      /Helv 9 0 R
+    >>
+  >>
+  /XFA [
+    (preamble) 10 0 R
+    (config) 11 0 R
+    (template) 12 0 R
+    (form) 13 0 R
+    (postamble) 14 0 R
+  ]
+>>
+endobj
+{{object 5 0}} <<
+  /Type /Pages
+  /Count 1
+  /Kids [6 0 R]
+>>
+endobj
+{{object 6 0}} <<
+  /Type /Page
+  /CropBox [0.0 0.0 612.0 792.0]
+  /MediaBox [0.0 0.0 612.0 792.0]
+  /Parent 5 0 R
+  /Resources <<
+    /ProcSet [/PDF /Text]
+  >>
+  /Rotate 0
+>>
+endobj
+{{object 8 0}} <<
+  /Type /Font
+  /Subtype /Type1
+  /BaseFont /Helvetica
+  /Encoding /WinAnsiEncoding
+>>
+endobj
+{{object 9 0}} <<
+  /Type /Font
+  /Subtype /Type1
+  /BaseFont /Helvetica
+  /Encoding /WinAnsiEncoding
+>>
+endobj
+{{object 10 0}} <<
+  {{streamlen}}
+>>
+stream
+<?xml version="1.0" encoding="UTF-8"?>
+<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
+endstream
+endobj
+{{object 11 0}} <<
+  {{streamlen}}
+>>
+stream
+<config xmlns="http://www.xfa.org/schema/xci/2.6/">
+  <agent name="designer">
+    <destination>pdf</destination>
+    <pdf>
+      <fontInfo/>
+    </pdf>
+  </agent>
+  <present>
+    <pdf>
+      <version>1.7</version>
+      <renderPolicy>client</renderPolicy>
+      <scriptModel>XFA</scriptModel>
+      <interactive>1</interactive>
+    </pdf>
+    <xdp>
+      <packets>*</packets>
+    </xdp>
+    <destination>pdf</destination>
+  </present>
+  <psMap/>
+  <acrobat>
+    <acrobat7>
+      <dynamicRender>required</dynamicRender>
+    </acrobat7>
+  </acrobat>
+</config>
+endstream
+endobj
+{{object 12 0}} <<
+  {{streamlen}}
+>>
+stream
+<template xmlns="http://www.xfa.org/schema/xfa-template/2.6/">
+  <subform layout="tb" locale="en_US" name="form1" restoreState="auto">
+    <pageSet>
+      <pageArea id="Page1" name="Page1">
+        <contentArea h="10.5in" w="8in" x="0.25in" y="0.25in"/>
+        <medium long="11in" short="8.5in" stock="letter"/>
+      </pageArea>
+    </pageSet>
+    <subform h="10.5in" w="8in" name="subform2">
+      <field h="9.0001mm" name="choiceList0" w="47.625mm" x="6.35mm" y="92.075mm">
+        <ui>
+          <choiceList/>
+        </ui>
+        <items save="1">
+          <text>Single</text>
+          <text>Married</text>
+          <text>Other</text>
+        </items>
+      </field>
+      <field name="choiceList1" h="10mm" w="1mm" x="5mm" y="50mm">
+        <ui>
+          <textEdit hScrollPolicy="off" vScrollPolicy="off" multiLine="0"/>
+        </ui>
+      <value>
+        <text maxChars="6">pdfium</text>
+      </value>
+      <event activity="full">
+        <script contentType="application/x-javascript">
+          full_count += 1;
+          if (full_count == 2) {
+            f1 = xfa.resolveNode("xfa.form..choiceList0");
+            xfa.host.setFocus(f1);
+            xfa.template.remerge();
+            xfa.host.openList(f1);
+          }
+        </script>
+      </event>
+    </field>
+  </subform>
+    <event activity="docReady">
+      <script contentType="application/x-javascript">
+        full_count = 0;
+        choiceList1 = xfa.resolveNode("xfa.form..choiceList1");
+        choiceList1.rawValue = "12345888888888888888";
+        xfa.host.setFocus(choiceList1);
+      </script>
+    </event>
+  </subform>
+</template>
+endstream
+endobj
+{{object 13 0}} <<
+  {{streamlen}}
+>>
+stream
+<form xmlns="http://www.xfa.org/schema/xfa-form/2.6/"></form>
+endstream
+endobj
+{{object 14 0}} <<
+  {{streamlen}}
+>>
+stream
+</xdp:xdp>
+endstream
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/javascript/xfa_specific/bug_1053617.in b/testing/resources/javascript/xfa_specific/bug_1053617.in
new file mode 100644
index 0000000..1e98bdc
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/bug_1053617.in
@@ -0,0 +1,155 @@
+{{header}}
+{{object 1 0}} <<
+  /Type /Catalog
+  /AcroForm 2 0 R
+  /Pages 3 0 R
+  /Extensions <<
+    /ADBE <<
+      /BaseVersion /1.7
+      /ExtensionLevel 8
+    >>
+  >>
+  /NeedsRendering true
+>>
+endobj
+{{object 2 0}} <<
+  /XFA [
+    (preamble) 5 0 R
+    (config) 6 0 R
+    (template) 7 0 R
+    (postamble) 9 0 R
+  ]
+>>
+endobj
+{{object 3 0}} <<
+  /Type /Pages
+  /Count 1
+  /Kids [4 0 R]
+>>
+endobj
+{{object 4 0}} <<
+  /Type /Page
+  /Parent 2 0 R
+  /MediaBox [0 0 612 792]
+>>
+endobj
+{{object 5 0}} <<
+  {{streamlen}}
+>>
+stream
+<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
+endstream
+endobj
+{{object 6 0}} <<
+  {{streamlen}}
+>>
+stream
+<config xmlns="http://www.xfa.org/schema/xci/3.0/">
+<agent name="designer">
+  <destination>pdf</destination>
+  <pdf>
+    <fontInfo/>
+  </pdf>
+</agent>
+<present>
+  <pdf>
+    <version>1.7</version>
+    <adobeExtensionLevel>8</adobeExtensionLevel>
+    <renderPolicy>client</renderPolicy>
+    <scriptModel>XFA</scriptModel>
+    <interactive>1</interactive>
+  </pdf>
+  <xdp>
+    <packets>*</packets>
+  </xdp>
+  <destination>pdf</destination>
+  <script>
+    <runScripts>server</runScripts>
+  </script>
+</present>
+<acrobat>
+  <acrobat7>
+    <dynamicRender>required</dynamicRender>
+  </acrobat7>
+  <validate>preSubmit</validate>
+</acrobat>
+</config>
+endstream
+endobj
+{{object 7 0}} <<
+  {{streamlen}}
+>>
+stream
+<template xmlns="http://www.xfa.org/schema/xfa-template/2.6/">
+  <subform name="form1">
+    <pageSet>
+      <pageArea id="Page1" name="Page1">
+        <contentArea h="10.5in" w="8in" x="0.25in" y="0.25in"/>
+        <medium long="11in" short="8.5in" stock="letter"/>
+      </pageArea>
+    </pageSet>
+    <subform h="10.5in" w="8in" name="subform2">
+      <field name="f1" h="10mm" w="10mm" x="20mm" y="20mm">
+        <ui>
+          <choiceList/>
+        </ui>
+        <items save="1">
+          <text>Single</text>
+        </items>
+      </field>
+      <subform name="f4" x="5mm" y="5mm">
+          <occur max="-1"/>
+          <field name="f2" h="10mm" w="10mm" x="1mm" y="1mm">
+            <ui>
+              <dateTimeEdit/>
+            </ui>
+            <value>
+              <date/>
+            </value>
+            <format>
+              <picture>date{MM/DD/YY}</picture>
+            </format>
+            <event activity="initialize">
+              <script contentType="application/x-javascript">
+                this.rawValue = "2020" + "-" + "12" + "-" + "10";
+              </script>
+            </event>
+            <event activity="change">
+              <script contentType="application/x-javascript">
+                a = a + 1;
+                if (a == 2) {
+                  xfa.event.cancelAction = true;
+                  c = xfa.resolveNode("xfa.form..f1");
+                  xfa.host.setFocus(c);
+                  d = xfa.resolveNode("xfa.form..f4");
+                  d.instanceManager.addInstance(1);
+                  d.instanceManager.removeInstance(0);
+                  xfa.host.openList(c);
+                }
+              </script>
+            </event>
+          </field>
+      </subform>
+    </subform>
+    <event activity="docReady">
+      <script contentType="application/x-javascript">
+        a = 0;
+        b = xfa.resolveNode("xfa.form..f2");
+        xfa.host.setFocus(b);
+      </script>
+    </event>
+  </subform>
+</template>
+endstream
+endobj
+{{object 9 0}} <<
+  {{streamlen}}
+>>
+stream
+</xdp:xdp>
+endstream
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/javascript/xfa_specific/bug_1054429.evt b/testing/resources/javascript/xfa_specific/bug_1054429.evt
new file mode 100644
index 0000000..8158a76
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/bug_1054429.evt
@@ -0,0 +1,2 @@
+mousedown,left,61,51

+keycode,46
\ No newline at end of file
diff --git a/testing/resources/javascript/xfa_specific/bug_1054429.in b/testing/resources/javascript/xfa_specific/bug_1054429.in
new file mode 100644
index 0000000..7295e5f
--- /dev/null
+++ b/testing/resources/javascript/xfa_specific/bug_1054429.in
@@ -0,0 +1,147 @@
+{{header}}
+{{object 1 0}} <<
+  /Type /Catalog
+  /AcroForm 2 0 R
+  /Pages 3 0 R
+  /Extensions <<
+    /ADBE <<
+      /BaseVersion /1.7
+      /ExtensionLevel 8
+    >>
+  >>
+  /NeedsRendering true
+>>
+endobj
+{{object 2 0}} <<
+  /XFA [
+    (preamble) 5 0 R
+    (config) 6 0 R
+    (template) 7 0 R
+    (postamble) 9 0 R
+  ]
+>>
+endobj
+{{object 3 0}} <<
+  /Type /Pages
+  /Count 1
+  /Kids [4 0 R]
+>>
+endobj
+{{object 4 0}} <<
+ /Type /Page
+ /Parent 2 0 R
+ /MediaBox [0 0 612 792]
+>>
+endobj
+{{object 5 0}} <<
+  {{streamlen}}
+>>
+stream
+<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
+endstream
+endobj
+{{object 6 0}} <<
+  {{streamlen}}
+>>
+stream
+<config xmlns="http://www.xfa.org/schema/xci/3.0/">
+<agent name="designer">
+  <destination>pdf</destination>
+  <pdf>
+    <fontInfo/>
+  </pdf>
+</agent>
+<present>
+  <pdf>
+    <version>1.7</version>
+    <adobeExtensionLevel>8</adobeExtensionLevel>
+    <renderPolicy>client</renderPolicy>
+    <scriptModel>XFA</scriptModel>
+    <interactive>1</interactive>
+  </pdf>
+  <xdp>
+    <packets>*</packets>
+  </xdp>
+  <destination>pdf</destination>
+  <script>
+    <runScripts>server</runScripts>
+  </script>
+</present>
+<acrobat>
+  <acrobat7>
+    <dynamicRender>required</dynamicRender>
+  </acrobat7>
+  <validate>preSubmit</validate>
+</acrobat>
+</config>
+endstream
+endobj
+{{object 7 0}} <<
+  {{streamlen}}
+>>
+stream
+<template xmlns="http://www.xfa.org/schema/xfa-template/2.6/">
+  <subform layout="tb" locale="en_US" name="form1" restoreState="auto">
+    <pageSet>
+      <pageArea id="Page1" name="Page1">
+        <contentArea h="10.5in" w="8in" x="0.25in" y="0.25in"/>
+        <medium long="11in" short="8.5in" stock="letter"/>
+      </pageArea>
+    </pageSet>
+    <subform h="10.5in" w="8in" name="subform2">
+      <field h="10mm" name="f1" w="40mm" x="5mm" y="90mm">
+        <ui>
+          <choiceList/>
+        </ui>
+        <items save="1">
+          <text>Single</text>
+        </items>
+      </field>
+      <subform name="f4" x="5mm" y="5mm">
+          <occur max="-1"/>
+          <field name="f2" h="300mm" w="300mm" x="1mm" y="1mm">
+            <ui>
+              <textEdit/>
+            </ui>
+            <value>
+              <text>pdfiummmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm</text>
+            </value>
+            <event activity="change">
+              <script contentType="application/x-javascript">
+                a = a + 1;
+                if (a == 2)  {
+                    xfa.event.cancelAction = true;
+                    b = xfa.resolveNode("xfa.form..f1");
+                    xfa.host.setFocus(b);
+                    d = xfa.resolveNode("xfa.form..f4");
+                    d.instanceManager.addInstance(1);
+                    d.instanceManager.removeInstance(0);
+                    xfa.host.openList(b);
+                }
+              </script>
+            </event>
+          </field>
+      </subform>
+    </subform>
+    <event activity="docReady">
+      <script contentType="application/x-javascript">
+        a = 0;
+        c = xfa.resolveNode("xfa.form..f2");
+        xfa.host.setFocus(c);
+      </script>
+    </event>
+  </subform>
+</template>
+endstream
+endobj
+{{object 9 0}} <<
+  {{streamlen}}
+>>
+stream
+</xdp:xdp>
+endstream
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF