xref: /aosp_15_r20/external/pdfium/testing/resources/javascript/xfa_specific/instance_manager.in (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1{{header}}
2{{include ../../xfa_catalog_1_0.fragment}}
3{{include ../../xfa_object_2_0.fragment}}
4{{include ../../xfa_preamble_3_0.fragment}}
5{{include ../../xfa_config_4_0.fragment}}
6{{object 5 0}} <<
7  {{streamlen}}
8>>
9stream
10<template xmlns="http://www.xfa.org/schema/xfa-template/2.6/">
11  <subform layout="tb" locale="en_US" name="form1" restoreState="auto">
12    <pageSet>
13      <pageArea id="Page1" name="Page1">
14        <contentArea h="10.5in" w="8in" x="0.25in" y="0.25in"/>
15        <medium long="11in" short="8.5in" stock="letter"/>
16      </pageArea>
17    </pageSet>
18    <subform h="10.5in" w="8in" name="subform2">
19      <field h="9.0001mm" name="field1" w="47.625mm" x="6.35mm" y="92.075mm">
20        <ui>
21          <choiceList/>
22        </ui>
23        <items save="1">
24          <text>Single</text>
25          <text>Married</text>
26          <text>Other</text>
27        </items>
28      </field>
29      <field name="field3" h="10.625mm" w="30.625mm" x="5mm" y="50mm">
30      </field>
31      <subform name="field4" x="5mm" y="5mm">
32        <occur max="-1"/>
33        <field name="field5" w="64.77mm" h="6.35mm">
34        </field>
35      </subform>
36    </subform>
37    <event activity="docReady">
38      <script contentType="application/x-javascript"><![CDATA[
39        {{include ../expect.js}}
40        {{include ../property_test_helpers.js}}
41        {{include dump_tree.js}}
42
43        var mgr = xfa.resolveNode("xfa.form..field4").instanceManager;
44        dumpTree(mgr);
45
46        testRWProperty(mgr, "count", 1, 12);
47        testROProperty(mgr, "min", 1);
48        testROProperty(mgr, "max", -1);
49
50        expectError("mgr.setInstances()");
51        expectError("mgr.setInstances(-10)");
52        expectError("mgr.setInstances('clams')");
53        expectError("mgr.setInstances([1, 2, 3])");
54        // setInstances(10000000) will hang or hit OOM.
55        expect("mgr.setInstances(4)", undefined);
56        expect("mgr.count", 4);
57        expect("mgr.setInstances(2)", undefined);
58        expect("mgr.count", 2);
59
60        expectError("mgr.moveInstance()");
61        expectError("mgr.moveInstance(0)");
62        expectError("mgr.moveInstance('clams')");
63        expectError("mgr.moveInstance([1, 2, 3])");
64        expect("mgr.moveInstance(0, 1)", undefined);
65        expect("mgr.count", 2);
66
67        expectError("mgr.addInstance(1, 2, 3)");
68        expect("mgr.addInstance().className", "subform");
69        expect("mgr.addInstance(true).className", "subform");
70        expect("mgr.count", 4);
71
72        expectError("mgr.insertInstance()");
73        expectError("mgr.insertInstance(1, 2, 3)");
74        expect("mgr.insertInstance(1, true).className", "subform");
75        expect("mgr.count", 5);
76
77        expectError("mgr.removeInstance()");
78        expectError("mgr.removeInstance(1, 2)");
79        expect("mgr.removeInstance(0)", undefined);
80        expect("mgr.removeInstance(0)", undefined);
81        expect("mgr.removeInstance(0)", undefined);
82        expect("mgr.removeInstance(0)", undefined);
83        expect("mgr.count", 1);
84
85        expectError("mgr.removeInstance(0)");
86        expect("mgr.count", 1);
87      ]]></script>
88    </event>
89  </subform>
90</template>
91endstream
92endobj
93{{include ../../xfa_locale_6_0.fragment}}
94{{include ../../xfa_postamble_7_0.fragment}}
95{{include ../../xfa_pages_8_0.fragment}}
96{{xref}}
97{{trailer}}
98{{startxref}}
99%%EOF
100