xref: /aosp_15_r20/external/pdfium/testing/resources/javascript/field_methods.in (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1*3ac0a46fSAndroid Build Coastguard Worker{{header}}
2*3ac0a46fSAndroid Build Coastguard Worker{{include field.fragment}}
3*3ac0a46fSAndroid Build Coastguard Worker
4*3ac0a46fSAndroid Build Coastguard Worker% JS program to execute
5*3ac0a46fSAndroid Build Coastguard Worker{{object 16 0}} <<
6*3ac0a46fSAndroid Build Coastguard Worker  {{streamlen}}
7*3ac0a46fSAndroid Build Coastguard Worker>>
8*3ac0a46fSAndroid Build Coastguard Workerstream
9*3ac0a46fSAndroid Build Coastguard Worker{{include expect.js}}
10*3ac0a46fSAndroid Build Coastguard Worker
11*3ac0a46fSAndroid Build Coastguard Workerfunction testGetField() {
12*3ac0a46fSAndroid Build Coastguard Worker  try {
13*3ac0a46fSAndroid Build Coastguard Worker    var empty =  this.getField("");
14*3ac0a46fSAndroid Build Coastguard Worker    app.alert("empty is " + empty.name);
15*3ac0a46fSAndroid Build Coastguard Worker    var field = this.getField("MyField");
16*3ac0a46fSAndroid Build Coastguard Worker    app.alert("field is " + field.name);
17*3ac0a46fSAndroid Build Coastguard Worker    var button = this.getField("MyField.MyPushButton");
18*3ac0a46fSAndroid Build Coastguard Worker    app.alert("button is " + button.name);
19*3ac0a46fSAndroid Build Coastguard Worker    var nonesuch = this.getField("MyField.nonesuch");
20*3ac0a46fSAndroid Build Coastguard Worker    app.alert("nonesuch is " + nonesuch);
21*3ac0a46fSAndroid Build Coastguard Worker    var dotdot = this.getField("MyField..nonesuch");
22*3ac0a46fSAndroid Build Coastguard Worker    app.alert("dotdot is " + dotdot.name);
23*3ac0a46fSAndroid Build Coastguard Worker    var tripledot = this.getField("MyField...nonesuch");
24*3ac0a46fSAndroid Build Coastguard Worker    app.alert("tripledot is " + tripledot.name);
25*3ac0a46fSAndroid Build Coastguard Worker    var quaddot = this.getField("MyField....nonesuch");
26*3ac0a46fSAndroid Build Coastguard Worker    app.alert("quaddot is " + quaddot.name);
27*3ac0a46fSAndroid Build Coastguard Worker    var dotdot1 = this.getField("MyField..nonesuch      ");
28*3ac0a46fSAndroid Build Coastguard Worker    app.alert("dotdot1 is " + dotdot1.name);
29*3ac0a46fSAndroid Build Coastguard Worker    var dotdot2 = this.getField("MyField..MyPushButton");
30*3ac0a46fSAndroid Build Coastguard Worker    app.alert("dotdot2 is " + dotdot2.name);
31*3ac0a46fSAndroid Build Coastguard Worker    var dotdot3 = this.getField("MyField..3");
32*3ac0a46fSAndroid Build Coastguard Worker    app.alert("dotdot3 is " + dotdot3.name);
33*3ac0a46fSAndroid Build Coastguard Worker  } catch (e) {
34*3ac0a46fSAndroid Build Coastguard Worker    app.alert("Unexpected error: " + e);
35*3ac0a46fSAndroid Build Coastguard Worker  }
36*3ac0a46fSAndroid Build Coastguard Worker}
37*3ac0a46fSAndroid Build Coastguard Worker
38*3ac0a46fSAndroid Build Coastguard Workerfunction testGetArray() {
39*3ac0a46fSAndroid Build Coastguard Worker  try {
40*3ac0a46fSAndroid Build Coastguard Worker    var subs = this.getField("MyField").getArray();
41*3ac0a46fSAndroid Build Coastguard Worker    app.alert("found " + subs.length + " sub-fields:");
42*3ac0a46fSAndroid Build Coastguard Worker    for (i = 0; i < subs.length; ++i) {
43*3ac0a46fSAndroid Build Coastguard Worker      app.alert(subs[i].name);
44*3ac0a46fSAndroid Build Coastguard Worker    }
45*3ac0a46fSAndroid Build Coastguard Worker  } catch (e) {
46*3ac0a46fSAndroid Build Coastguard Worker    app.alert("Unexpected error: " + e);
47*3ac0a46fSAndroid Build Coastguard Worker  }
48*3ac0a46fSAndroid Build Coastguard Worker}
49*3ac0a46fSAndroid Build Coastguard Worker
50*3ac0a46fSAndroid Build Coastguard WorkertestGetField();
51*3ac0a46fSAndroid Build Coastguard WorkertestGetArray();
52*3ac0a46fSAndroid Build Coastguard Worker
53*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyPushButton').buttonGetCaption()", "");
54*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyPushButton').buttonGetCaption(0)", "");
55*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyPushButton').buttonGetCaption(1)", "");
56*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyPushButton').buttonGetCaption(2)", "");
57*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField.MyPushButton').buttonGetCaption(3)")
58*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField.MyMultiSelect').buttonGetCaption()")
59*3ac0a46fSAndroid Build Coastguard Worker
60*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyPushButton').buttonGetIcon()", "[object Object]");
61*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyPushButton').buttonGetIcon(0)", "[object Object]");
62*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyPushButton').buttonGetIcon(1)", "[object Object]");
63*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField.MyPushButton').buttonGetIcon(3)");
64*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField.MyMultiSelect').buttonGetIcon()");
65*3ac0a46fSAndroid Build Coastguard Worker
66*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyPushButton').buttonImportIcon()", undefined);
67*3ac0a46fSAndroid Build Coastguard Worker
68*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyFile').browseForFileToSubmit()", undefined);
69*3ac0a46fSAndroid Build Coastguard Worker
70*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyMultiSelect').getItemAt(0)", "foo");
71*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyMultiSelect').getItemAt(1, false)", "bar");
72*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyMultiSelect').getItemAt(1, true)", "bar");
73*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyMultiSelect').getItemAt(2, false)", "Qux");
74*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyMultiSelect').getItemAt(2, true)", "qux");
75*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyMultiSelect').getItemAt(3)", "");
76*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyMultiSelect').getItemAt()", "qux");
77*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyMultiSelect').getItemAt(172)", "qux");
78*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyMultiSelect').getItemAt(-400)", "");
79*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField.MyMultiSelect').getItemAt('zzzz')", "foo");
80*3ac0a46fSAndroid Build Coastguard Worker
81*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').checkThisBox()");
82*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').checkThisBox({})");
83*3ac0a46fSAndroid Build Coastguard Worker
84*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').defaultIsChecked()");
85*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField').defaultIsChecked(0)", false);
86*3ac0a46fSAndroid Build Coastguard Worker
87*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').isBoxChecked()");
88*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').isBoxChecked(20)");
89*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField').isBoxChecked(0)", false);
90*3ac0a46fSAndroid Build Coastguard Worker
91*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').isDefaultChecked()", false);
92*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').isDefaultChecked(20)", false);
93*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField').isDefaultChecked(0)", false);
94*3ac0a46fSAndroid Build Coastguard Worker
95*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField').setFocus()", undefined);
96*3ac0a46fSAndroid Build Coastguard Worker
97*3ac0a46fSAndroid Build Coastguard Workerapp.alert("These mismatched cases always throw");
98*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField.MyText').browseForFileToSubmit()");
99*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').checkThisBox(0, true)");
100*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').getItemAt(0)");
101*3ac0a46fSAndroid Build Coastguard Worker
102*3ac0a46fSAndroid Build Coastguard Workerapp.alert("These always succeed without actually doing anything:");
103*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField').clearItems()", undefined);
104*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField').deleteItemAt()", undefined);
105*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField').insertItemAt()", undefined);
106*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField').setAction()", undefined);
107*3ac0a46fSAndroid Build Coastguard Workerexpect("this.getField('MyField').setItems()");
108*3ac0a46fSAndroid Build Coastguard Worker
109*3ac0a46fSAndroid Build Coastguard Workerapp.alert("These always throw operation not supported errors:");
110*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').buttonSetCaption()");
111*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').buttonSetIcon()");
112*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').getLock()");
113*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').setLock()");
114*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').signatureGetModifications()");
115*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').signatureGetSeedValue()");
116*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').signatureInfo()");
117*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').signatureSetSeedValue()");
118*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').signatureSign()");
119*3ac0a46fSAndroid Build Coastguard WorkerexpectError("this.getField('MyField').signatureValidate()");
120*3ac0a46fSAndroid Build Coastguard Worker
121*3ac0a46fSAndroid Build Coastguard Workerendstream
122*3ac0a46fSAndroid Build Coastguard Workerendobj
123*3ac0a46fSAndroid Build Coastguard Worker{{xref}}
124*3ac0a46fSAndroid Build Coastguard Worker{{trailer}}
125*3ac0a46fSAndroid Build Coastguard Worker{{startxref}}
126*3ac0a46fSAndroid Build Coastguard Worker%%EOF
127