{{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 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="field3" h="10.625mm" w="30.625mm" x="5mm" y="50mm">
      </field>
      <subform name="field4" x="5mm" y="5mm">
        <occur max="-1"/>
        <field name="field5" w="64.77mm" h="6.35mm">
        </field>
      </subform>
    </subform>
    <event activity="docReady">
      <script contentType="application/x-javascript"><![CDATA[
        {{include ../expect.js}}
        {{include ../property_test_helpers.js}}
        {{include dump_tree.js}}

        var mgr = xfa.resolveNode("xfa.form..field4").instanceManager;
        dumpTree(mgr);

        testRWProperty(mgr, "count", 1, 12);
        testROProperty(mgr, "min", 1);
        testROProperty(mgr, "max", -1);

        expectError("mgr.setInstances()");
        expectError("mgr.setInstances(-10)");
        expectError("mgr.setInstances('clams')");
        expectError("mgr.setInstances([1, 2, 3])");
        // setInstances(10000000) will hang or hit OOM.
        expect("mgr.setInstances(4)", undefined);
        expect("mgr.count", 4);
        expect("mgr.setInstances(2)", undefined);
        expect("mgr.count", 2);

        expectError("mgr.moveInstance()");
        expectError("mgr.moveInstance(0)");
        expectError("mgr.moveInstance('clams')");
        expectError("mgr.moveInstance([1, 2, 3])");
        expect("mgr.moveInstance(0, 1)", undefined);
        expect("mgr.count", 2);

        expectError("mgr.addInstance(1, 2, 3)");
        expect("mgr.addInstance().className", "subform");
        expect("mgr.addInstance(true).className", "subform");
        expect("mgr.count", 4);

        expectError("mgr.insertInstance()");
        expectError("mgr.insertInstance(1, 2, 3)");
        expect("mgr.insertInstance(1, true).className", "subform");
        expect("mgr.count", 5);

        expectError("mgr.removeInstance()");
        expectError("mgr.removeInstance(1, 2)");
        expect("mgr.removeInstance(0)", undefined);
        expect("mgr.removeInstance(0)", undefined);
        expect("mgr.removeInstance(0)", undefined);
        expect("mgr.removeInstance(0)", undefined);
        expect("mgr.count", 1);

        expectError("mgr.removeInstance(0)");
        expect("mgr.count", 1);
      ]]></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
