summaryrefslogtreecommitdiff
path: root/testing/resources/javascript/event_properties.in
blob: 6f563d1c2c21d15275b1dcf514764e67d58dcdf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
{{header}}
{{object 1 0}} <<
  /Type /Catalog
  /Pages 2 0 R
  /AcroForm << /Fields [ 4 0 R 10 0 R ] /DR 5 0 R >>
>>
endobj
{{object 2 0}} <<
  /Count 1
  /Kids [ 3 0 R ]
  /Type /Pages
>>
endobj
{{object 3 0}} <<
  /Type /Page
  /Parent 2 0 R
  /Resources 5 0 R
  /MediaBox [ 0 0 300 200 ]
  /Contents 8 0 R
  /Annots [ 4 0 R 10 0 R ]
>>
endobj
{{object 4 0}} <<
  /Type /Annot
  /FT /Tx
  /T (Text Box)
  /DA (0 0 0 rg /F1 12 Tf)
  /Rect [ 100 100 200 130 ]
  /Subtype /Widget
  /AA <<
    /F 9 0 R
  >>
>>
endobj
{{object 5 0}} <<
  /Font 6 0 R
>>
endobj
{{object 6 0}} <<
  /F1 7 0 R
>>
endobj
{{object 7 0}} <<
  /Type /Font
  /Subtype /Type1
  /BaseFont /Helvetica
>>
endobj
{{object 8 0}} <<
  {{streamlen}}
>>
stream
endstream
endobj
{{object 9 0}} <<
  /JS (
    function expect(expression, expected) {
      try {
        var actual = eval(expression);
        if (actual == expected) {
          app.alert('PASS: ' + expression + ' = ' + actual);
        } else {
          app.alert('FAIL: ' + expression + ' = ' + actual + ', expected ' + expected + " ");
        }
      } catch (e) {
        app.alert('ERROR: ' + e);
      }
    }

    function expectError(expression) {
      try {
        var actual = eval(expression);
        app.alert('FAIL: ' + expression + ' = ' + actual + ', expected to throw');
      } catch (e) {
        app.alert('PASS: ' + expression + ' threw ' + e);
      }
    }

    try {
      app.alert("*** starting test ***");

      expect("event.change", "");
      expect("event.change = 'boo'", "boo");
      expect("event.change", "boo");

      expect("event.changeEx", "");
      expectError("event.changeEx = 'boo'");

      expect("event.commitKey", "");
      expectError("event.commitKey = 'boo'");

      // FieldFull applies to events named Keystroke only.
      // TODO(tsepez): figure out a way to set event names for tests.
      expectError("event.fieldFull");
      expectError("event.fieldFull = 'boo'");

      expect("event.keyDown", "");
      expectError("event.keyDown = 'boo'");

      expect("event.modifier", "");
      expectError("event.modifier = 'boo'");

      expect("event.name", "Format");
      expectError("event.name = 'boo'");

      expect("event.rc", false);
      expect("event.rc = 'boo'", "boo");
      expect("event.rc", true);
      expect("event.rc = false", false);

      // TODO(tsepez): is silently ignoring update correct here?
      expect("event.richChange", undefined);
      expect("event.richChange = 'boo'", "boo");
      expect("event.richChange", undefined);

      // TODO(tsepez): is silently ignoring update correct here?
      expect("event.richChangeEx", undefined);
      expect("event.richChangeEx = 'boo'", "boo");
      expect("event.richChangeEx", undefined);

      // TODO(tsepez): is silently ignoring update correct here?
      expect("event.richValue", undefined);
      expect("event.richValue = 'boo'", "boo");
      expect("event.richValue", undefined);

      // selEnd applies to events named Keystroke only.
      // TODO(tsepez): figure out a way to set event names for tests.
      expect("event.selEnd", undefined);
      expect("event.selEnd = 'boo'", "boo");
      expect("event.selEnd", undefined);

      // selEnd applies to events named Keystroke only.
      // TODO(tsepez): figure out a way to set event names for tests.
      expect("event.selStart", undefined);
      expect("event.selStart = 'boo'", "boo");
      expect("event.selStart", undefined);

      expect("event.shift", false);
      expectError("event.shift = 'boo'");

      // TODO(tsepez): dig deeper into object.
      expect("event.source", "[object Object]");
      expectError("event.source = 'boo'");

      // TODO(tsepez): dig deeper into object.
      expect("event.target", "[object Object]");
      expectError("event.target = 'boo'");

      expect("event.targetName", "Text Box");
      expectError("event.targetName = 'boo'");

      expect("event.type", "Field");
      expectError("event.type = 'boo'");

      expect("event.value", "");
      expect("event.value = 'boo'", "boo");
      expect("event.value", "boo");

      expect("event.willCommit", true);
      expectError("event.willCommit = 'boo'");
      expect("event.willCommit", true);

      app.alert("*** ending test ***");
    } catch (e) {
      app.alert("Truly unexpected error occured: " + e);
    }
  )
  /S /JavaScript
>>
endobj
{{object 10 0}} <<
  /Type /Annot
  /FT /Tx
  /T (Text2)
  /DA (0 0 0 rg /F1 12 Tf)
  /Rect [ 100 40 200 70 ]
  /Subtype /Widget
>>
endobj
{{xref}}
{{trailer}}
{{startxref}}
%%EOF