1{{header}} 2{{object 1 0}} << 3 /Type /Catalog 4 /Pages 2 0 R 5 /AcroForm << 6 /Fields [ 7 4 0 R 8 10 0 R 9 11 0 R 10 12 0 R 11 ] 12 /DR 5 0 R 13 >> 14>> 15endobj 16{{object 2 0}} << 17 /Count 1 18 /Kids [ 3 0 R ] 19 /Type /Pages 20>> 21endobj 22{{object 3 0}} << 23 /Type /Page 24 /Parent 2 0 R 25 /Resources 5 0 R 26 /MediaBox [ 0 0 300 200 ] 27 /Contents 8 0 R 28 /Annots [ 29 4 0 R 30 10 0 R 31 11 0 R 32 12 0 R 33 ] 34>> 35endobj 36{{object 4 0}} << 37 /Type /Annot 38 /FT /Tx 39 /T (Text Box) 40 /DA (0 0 0 rg /F1 12 Tf) 41 /Rect [ 100 160 200 190 ] 42 /Subtype /Widget 43 /AA << 44 /C 16 0 R 45 /F 17 0 R 46 /K 18 0 R 47 /V 19 0 R 48 >> 49>> 50endobj 51{{object 5 0}} << 52 /Font 6 0 R 53>> 54endobj 55{{object 6 0}} << 56 /F1 7 0 R 57>> 58endobj 59{{object 7 0}} << 60 /Type /Font 61 /Subtype /Type1 62 /BaseFont /Helvetica 63>> 64endobj 65{{object 8 0}} << 66 {{streamlen}} 67>> 68stream 69endstream 70endobj 71{{object 10 0}} << 72 /Type /Annot 73 /Subtype /Widget 74 /FT /Tx 75 /T (Text2) 76 /DA (0 0 0 rg /F1 12 Tf) 77 /Rect [100 0 200 30] 78 /V (123) 79>> 80endobj 81{{object 11 0}} << 82 /Type /Annot 83 /Subtype /Widget 84 /FT /Tx 85 /T (Text3) 86 /DA (0 0 0 rg /F1 12 Tf) 87 /Rect [100 40 200 70] 88 /V (456) 89>> 90endobj 91{{object 12 0}} << 92 /Type /Annot 93 /Subtype /Widget 94 /FT /Tx 95 /T (Text4) 96 /DA (0 0 0 rg /F1 12 Tf) 97 /Rect [100 80 200 110] 98 /V (407.96) 99>> 100endobj 101{{object 16 0}} << 102 /S /JavaScript 103 /JS ( 104 app.alert('Unexpected script 16'); 105 ) 106>> 107endobj 108{{object 17 0}} << 109 /S /JavaScript 110 /JS ( 111 function expect(initial, expression, expected) { 112 try { 113 event.value = initial; 114 var actual = eval(expression); 115 if (actual == expected) { 116 app.alert('PASS: ' + expression + ' = ' + actual); 117 } else { 118 app.alert('FAIL: ' + expression + ' = ' + actual + ', expected ' + expected + " "); 119 } 120 } catch (e) { 121 app.alert('ERROR: ' + e); 122 } 123 } 124 125 function expectEventValue(initial, expression, expected) { 126 try { 127 event.value = initial; 128 eval(expression); 129 var actual = event.value; 130 if (actual == expected) { 131 app.alert('PASS: ' + expression + ' = ' + actual); 132 } else { 133 app.alert('FAIL: ' + expression + ' = ' + actual + ', expected ' + expected + " "); 134 } 135 } catch (e) { 136 app.alert('ERROR: ' + e); 137 } 138 } 139 140 function expectError(initial, expression) { 141 try { 142 event.value = initial; 143 var actual = eval(expression); 144 app.alert('FAIL: ' + expression + ' = ' + actual + ', expected to throw'); 145 } catch (e) { 146 app.alert('PASS: ' + expression + ' threw ' + e); 147 } 148 } 149 150 try { 151 app.alert("*** starting test 1 ***"); 152 153 expectError('', "AFDate_Format()"); 154 expectError('', "AFDate_Format(1, 2)"); 155 expectEventValue("GMT", "AFDate_Format(1)", "1/1/70"); 156 expectEventValue("PDT", "AFDate_Format(1)", "5/9/14"); 157 expectEventValue("GMT", "AFDate_Format('blooey')", "1/1"); 158 expectEventValue("PDT", "AFDate_Format('blooey')", "5/9"); 159 160 app.alert("**********************"); 161 162 expectError('', "AFDate_FormatEx()"); 163 expectError('', "AFDate_FormatEx(1, 2)"); 164 expectEventValue("x", "AFDate_FormatEx(2)", "2"); 165 expectEventValue("x", "AFDate_FormatEx('blooey')", "blooey"); 166 expectEventValue("x", "AFDate_FormatEx('m/d')", "5/9"); 167 // TODO(crbug.com/572901): This is wrong. AFDate_FormatEx() should throw 168 // an error like Adobe Acrobat. 169 expectEventValue("12302015", "AFDate_FormatEx('mm/dd/yyyy')", "12/02/2015"); 170 expectEventValue("20122015", "AFDate_FormatEx('mm/dd/yyyy')", "05/09/2014"); 171 172 app.alert("**********************"); 173 174 expectError('', "AFDate_Keystroke()"); 175 expectError('', "AFDate_Keystroke(1, 2)"); 176 expectEventValue("04/19", "AFDate_Keystroke(2)", "04/19"); 177 expectEventValue("04/19/15", "AFDate_Keystroke('blooey')", "04/19/15"); 178 179 app.alert("**********************"); 180 181 expectError('', "AFDate_KeystrokeEx()"); 182 expectError('', "AFDate_KeystrokeEx(1, 2)"); 183 expectEventValue("x", "AFDate_KeystrokeEx(2)", "x"); 184 expectEventValue("x", "AFDate_KeystrokeEx('blooey')", "x"); 185 expectEventValue("x", "AFDate_KeystrokeEx('m/d')", "x"); 186 187 app.alert("**********************"); 188 189 expectError('', "AFExtractNums()"); 190 expectError('', "AFExtractNums(1, 2)"); 191 expect('', "AFExtractNums('100 200')", "100,200"); 192 193 app.alert("**********************"); 194 195 expectError('', "AFMakeNumber()"); 196 expectError('', "AFMakeNumber(1, 2)"); 197 expect('', "AFMakeNumber('2blooey')", 0); 198 expect('', "AFMakeNumber(1)", 1); 199 expect('', "AFMakeNumber('1.2')", 1.2); 200 expect('', "AFMakeNumber('1,2')", 1.2); 201 202 app.alert("**********************"); 203 204 expectError('', "AFMergeChange()"); 205 expectError('', "AFMergeChange(1, 2)"); 206 expect("one", "AFMergeChange(undefined)", "one"); 207 208 app.alert("**********************"); 209 210 expectError('', "AFNumber_Format()"); 211 expectError('', "AFNumber_Format(0, 1, 0, 0, '', false, 42)"); 212 expectEventValue("blooey", "AFNumber_Format(0, 1, 0, 0, '', false)", 0); 213 expectEventValue(12, "AFNumber_Format(0, 1, 0, 0, '', false)", 12); 214 215 app.alert("**********************"); 216 217 expectError('', "AFNumber_Keystroke()"); 218 expectError('', "AFNumber_Keystroke(1)"); 219 expectError("abc", "AFNumber_Keystroke(1, 2)"); 220 expectEventValue("123", "AFNumber_Keystroke(1, 2)", "123"); 221 expectEventValue("123", "AFNumber_Keystroke(1, 2, 3)", "123"); 222 223 app.alert("**********************"); 224 225 expectError('', "AFParseDateEx()"); 226 expectError('', "AFParseDateEx(1, 2, 3)"); 227 expect('', "AFParseDateEx(1, 2)", "1399672130000"); 228 229 app.alert("**********************"); 230 231 // Requires at least 2 arguments. 232 expectError('', "AFPercent_Format()"); 233 expectError('', "AFPercent_Format(0)"); 234 235 // Extra arguments are ignored. 236 expectEventValue(-5.1234, "AFPercent_Format(1, 0, 0)", "-512.3%"); 237 expectEventValue(-5.1234, "AFPercent_Format(1, 0, 0, 0)", "-512.3%"); 238 expectEventValue(-5.1234, "AFPercent_Format(1, 0, 0, 0, 0)", "-512.3%"); 239 expectEventValue(-5.1234, "AFPercent_Format(1, 0, 0, 0, 0, 0)", "-512.3%"); 240 241 // There seems to be an extra bPercentPrepend parameter that may have been 242 // added in later versions. 243 expectEventValue(-5.1234, "AFPercent_Format(1, 0, 0)", "-512.3%"); 244 expectEventValue(-5.1234, "AFPercent_Format(1, 0, 1)", "%-512.3"); 245 expectEventValue(-5.1234, "AFPercent_Format(1, 0, 2)", "%-512.3"); 246 expectEventValue('', "AFPercent_Format(10, 0, 0)", "0.0000000000%"); 247 expectEventValue('', "AFPercent_Format(10, 0, 1)", "%0.0000000000"); 248 expectEventValue('', "AFPercent_Format(10, 0, 2)", "%0.0000000000"); 249 250 expectEventValue(987654321.001234, "AFPercent_Format(0, 0, 0)", "98,765,432,100%"); 251 expectEventValue(987654321.001234, "AFPercent_Format(0, 1, 0)", "98765432100%"); 252 expectEventValue(987654321.001234, "AFPercent_Format(0, 2, 0)", "98.765.432.100%"); 253 expectEventValue(987654321.001234, "AFPercent_Format(0, 0, 1)", "%98,765,432,100"); 254 expectEventValue(987654321.001234, "AFPercent_Format(0, 1, 1)", "%98765432100"); 255 expectEventValue(987654321.001234, "AFPercent_Format(0, 2, 1)", "%98.765.432.100"); 256 expectEventValue(987654321.001234, "AFPercent_Format(0, 0, 2)", "%98,765,432,100"); 257 expectEventValue(987654321.001234, "AFPercent_Format(0, 1, 2)", "%98765432100"); 258 expectEventValue(987654321.001234, "AFPercent_Format(0, 2, 2)", "%98.765.432.100"); 259 260 // InvalidArgsError 261 expectError(0, "AFPercent_Format(-3, 0)"); 262 expectError(0, "AFPercent_Format(-3, 1)"); 263 expectError(0, "AFPercent_Format(-1, 3)"); 264 expectError(0, "AFPercent_Format(0, -3)"); 265 expectError(0, "AFPercent_Format(0, -1)"); 266 expectError(0, "AFPercent_Format(0, 50)"); 267 expectError(0, "AFPercent_Format(0, 51)"); 268 269 expectEventValue('', "AFPercent_Format(0, 0)", "0%"); 270 expectEventValue('', "AFPercent_Format(0, 1)", "0%"); 271 expectEventValue('', "AFPercent_Format(0, 2)", "0%"); 272 expectEventValue('', "AFPercent_Format(0, 3)", "0%"); 273 expectEventValue('', "AFPercent_Format(0, 4)", "0%"); 274 expectEventValue('', "AFPercent_Format(1, 0)", "0.0%"); 275 expectEventValue('', "AFPercent_Format(1, 1)", "0.0%"); 276 expectEventValue('', "AFPercent_Format(1, 2)", "0,0%"); 277 expectEventValue('', "AFPercent_Format(1, 3)", "0,0%"); 278 expectEventValue('', "AFPercent_Format(1, 4)", "0.0%"); 279 expectEventValue('', "AFPercent_Format(2, 0)", "0.00%"); 280 expectEventValue('', "AFPercent_Format(2, 1)", "0.00%"); 281 expectEventValue('', "AFPercent_Format(2, 2)", "0,00%"); 282 expectEventValue('', "AFPercent_Format(2, 3)", "0,00%"); 283 expectEventValue('', "AFPercent_Format(2, 4)", "0.00%"); 284 expectEventValue('', "AFPercent_Format(3, 0)", "0.000%"); 285 expectEventValue('', "AFPercent_Format(3, 1)", "0.000%"); 286 expectEventValue('', "AFPercent_Format(3, 2)", "0,000%"); 287 expectEventValue('', "AFPercent_Format(3, 3)", "0,000%"); 288 expectEventValue('', "AFPercent_Format(3, 4)", "0.000%"); 289 expectEventValue('', "AFPercent_Format(10, 0)", "0.0000000000%"); 290 expectEventValue('', "AFPercent_Format(10, 1)", "0.0000000000%"); 291 expectEventValue('', "AFPercent_Format(10, 2)", "0,0000000000%"); 292 expectEventValue('', "AFPercent_Format(10, 3)", "0,0000000000%"); 293 expectEventValue('', "AFPercent_Format(10, 4)", "0.0000000000%"); 294 295 expectEventValue(0, "AFPercent_Format(0, 0)", "0%"); 296 expectEventValue(0, "AFPercent_Format(0, 1)", "0%"); 297 expectEventValue(0, "AFPercent_Format(0, 2)", "0%"); 298 expectEventValue(0, "AFPercent_Format(0, 3)", "0%"); 299 expectEventValue(0, "AFPercent_Format(0, 4)", "0%"); 300 expectEventValue(0, "AFPercent_Format(1, 0)", "0.0%"); 301 expectEventValue(0, "AFPercent_Format(1, 1)", "0.0%"); 302 expectEventValue(0, "AFPercent_Format(1, 2)", "0,0%"); 303 expectEventValue(0, "AFPercent_Format(1, 3)", "0,0%"); 304 expectEventValue(0, "AFPercent_Format(1, 4)", "0.0%"); 305 expectEventValue(0, "AFPercent_Format(2, 0)", "0.00%"); 306 expectEventValue(0, "AFPercent_Format(2, 1)", "0.00%"); 307 expectEventValue(0, "AFPercent_Format(2, 2)", "0,00%"); 308 expectEventValue(0, "AFPercent_Format(2, 3)", "0,00%"); 309 expectEventValue(0, "AFPercent_Format(2, 4)", "0.00%"); 310 expectEventValue(0, "AFPercent_Format(3, 0)", "0.000%"); 311 expectEventValue(0, "AFPercent_Format(3, 1)", "0.000%"); 312 expectEventValue(0, "AFPercent_Format(3, 2)", "0,000%"); 313 expectEventValue(0, "AFPercent_Format(3, 3)", "0,000%"); 314 expectEventValue(0, "AFPercent_Format(3, 4)", "0.000%"); 315 expectEventValue(0, "AFPercent_Format(10, 0)", "0.0000000000%"); 316 expectEventValue(0, "AFPercent_Format(10, 1)", "0.0000000000%"); 317 expectEventValue(0, "AFPercent_Format(10, 2)", "0,0000000000%"); 318 expectEventValue(0, "AFPercent_Format(10, 3)", "0,0000000000%"); 319 expectEventValue(0, "AFPercent_Format(10, 4)", "0.0000000000%"); 320 321 expectEventValue(-5.1234, "AFPercent_Format(0, 0)", "-512%"); 322 expectEventValue(-5.1234, "AFPercent_Format(0, 1)", "-512%"); 323 expectEventValue(-5.1234, "AFPercent_Format(0, 2)", "-512%"); 324 expectEventValue(-5.1234, "AFPercent_Format(0, 3)", "-512%"); 325 expectEventValue(-5.1234, "AFPercent_Format(0, 4)", "-512%"); 326 expectEventValue(-5.1234, "AFPercent_Format(1, 0)", "-512.3%"); 327 expectEventValue(-5.1234, "AFPercent_Format(1, 1)", "-512.3%"); 328 expectEventValue(-5.1234, "AFPercent_Format(1, 2)", "-512,3%"); 329 expectEventValue(-5.1234, "AFPercent_Format(1, 3)", "-512,3%"); 330 expectEventValue(-5.1234, "AFPercent_Format(1, 4)", "-512.3%"); 331 expectEventValue(-5.1234, "AFPercent_Format(2, 0)", "-512.34%"); 332 expectEventValue(-5.1234, "AFPercent_Format(2, 1)", "-512.34%"); 333 expectEventValue(-5.1234, "AFPercent_Format(2, 2)", "-512,34%"); 334 expectEventValue(-5.1234, "AFPercent_Format(2, 3)", "-512,34%"); 335 expectEventValue(-5.1234, "AFPercent_Format(2, 4)", "-512.34%"); 336 expectEventValue(-5.1234, "AFPercent_Format(3, 0)", "-512.340%"); 337 expectEventValue(-5.1234, "AFPercent_Format(3, 1)", "-512.340%"); 338 expectEventValue(-5.1234, "AFPercent_Format(3, 2)", "-512,340%"); 339 expectEventValue(-5.1234, "AFPercent_Format(3, 3)", "-512,340%"); 340 expectEventValue(-5.1234, "AFPercent_Format(3, 4)", "-512.340%"); 341 expectEventValue(-5.1234, "AFPercent_Format(10, 0)", "-512.3400000000%"); 342 expectEventValue(-5.1234, "AFPercent_Format(10, 1)", "-512.3400000000%"); 343 expectEventValue(-5.1234, "AFPercent_Format(10, 2)", "-512,3400000000%"); 344 expectEventValue(-5.1234, "AFPercent_Format(10, 3)", "-512,3400000000%"); 345 expectEventValue(-5.1234, "AFPercent_Format(10, 4)", "-512.3400000000%"); 346 347 expectEventValue(5.1234, "AFPercent_Format(0, 0)", "512%"); 348 expectEventValue(5.1234, "AFPercent_Format(0, 1)", "512%"); 349 expectEventValue(5.1234, "AFPercent_Format(0, 2)", "512%"); 350 expectEventValue(5.1234, "AFPercent_Format(0, 3)", "512%"); 351 expectEventValue(5.1234, "AFPercent_Format(0, 4)", "512%"); 352 expectEventValue(5.1234, "AFPercent_Format(1, 0)", "512.3%"); 353 expectEventValue(5.1234, "AFPercent_Format(1, 1)", "512.3%"); 354 expectEventValue(5.1234, "AFPercent_Format(1, 2)", "512,3%"); 355 expectEventValue(5.1234, "AFPercent_Format(1, 3)", "512,3%"); 356 expectEventValue(5.1234, "AFPercent_Format(1, 4)", "512.3%"); 357 expectEventValue(5.1234, "AFPercent_Format(2, 0)", "512.34%"); 358 expectEventValue(5.1234, "AFPercent_Format(2, 1)", "512.34%"); 359 expectEventValue(5.1234, "AFPercent_Format(2, 2)", "512,34%"); 360 expectEventValue(5.1234, "AFPercent_Format(2, 3)", "512,34%"); 361 expectEventValue(5.1234, "AFPercent_Format(2, 4)", "512.34%"); 362 expectEventValue(5.1234, "AFPercent_Format(3, 0)", "512.340%"); 363 expectEventValue(5.1234, "AFPercent_Format(3, 1)", "512.340%"); 364 expectEventValue(5.1234, "AFPercent_Format(3, 2)", "512,340%"); 365 expectEventValue(5.1234, "AFPercent_Format(3, 3)", "512,340%"); 366 expectEventValue(5.1234, "AFPercent_Format(3, 4)", "512.340%"); 367 expectEventValue(5.1234, "AFPercent_Format(10, 0)", "512.3400000000%"); 368 expectEventValue(5.1234, "AFPercent_Format(10, 1)", "512.3400000000%"); 369 expectEventValue(5.1234, "AFPercent_Format(10, 2)", "512,3400000000%"); 370 expectEventValue(5.1234, "AFPercent_Format(10, 3)", "512,3400000000%"); 371 expectEventValue(5.1234, "AFPercent_Format(10, 4)", "512.3400000000%"); 372 373 expectEventValue(12.3456, "AFPercent_Format(1, 0)", "1,234.6%"); 374 expectEventValue(12.3456, "AFPercent_Format(4, 1)", "1234.5600%"); 375 376 expectEventValue(0.009876, "AFPercent_Format(0, 0)", "1%"); 377 expectEventValue(0.009876, "AFPercent_Format(0, 1)", "1%"); 378 expectEventValue(0.009876, "AFPercent_Format(0, 2)", "1%"); 379 expectEventValue(0.009876, "AFPercent_Format(0, 3)", "1%"); 380 expectEventValue(0.009876, "AFPercent_Format(0, 4)", "1%"); 381 expectEventValue(0.009876, "AFPercent_Format(1, 0)", "1.0%"); 382 expectEventValue(0.009876, "AFPercent_Format(1, 1)", "1.0%"); 383 expectEventValue(0.009876, "AFPercent_Format(1, 2)", "1,0%"); 384 expectEventValue(0.009876, "AFPercent_Format(1, 3)", "1,0%"); 385 expectEventValue(0.009876, "AFPercent_Format(1, 4)", "1.0%"); 386 expectEventValue(0.009876, "AFPercent_Format(2, 0)", "0.99%"); 387 expectEventValue(0.009876, "AFPercent_Format(2, 1)", "0.99%"); 388 expectEventValue(0.009876, "AFPercent_Format(2, 2)", "0,99%"); 389 expectEventValue(0.009876, "AFPercent_Format(2, 3)", "0,99%"); 390 expectEventValue(0.009876, "AFPercent_Format(2, 4)", "0.99%"); 391 expectEventValue(0.009876, "AFPercent_Format(3, 0)", "0.988%"); 392 expectEventValue(0.009876, "AFPercent_Format(3, 1)", "0.988%"); 393 expectEventValue(0.009876, "AFPercent_Format(3, 2)", "0,988%"); 394 expectEventValue(0.009876, "AFPercent_Format(3, 3)", "0,988%"); 395 expectEventValue(0.009876, "AFPercent_Format(3, 4)", "0.988%"); 396 expectEventValue(0.009876, "AFPercent_Format(10, 0)", "0.9876000000%"); 397 expectEventValue(0.009876, "AFPercent_Format(10, 1)", "0.9876000000%"); 398 expectEventValue(0.009876, "AFPercent_Format(10, 2)", "0,9876000000%"); 399 expectEventValue(0.009876, "AFPercent_Format(10, 3)", "0,9876000000%"); 400 expectEventValue(0.009876, "AFPercent_Format(10, 4)", "0.9876000000%"); 401 402 expectEventValue(987654321.001234, "AFPercent_Format(0, 0)", "98,765,432,100%"); 403 expectEventValue(987654321.001234, "AFPercent_Format(0, 1)", "98765432100%"); 404 expectEventValue(987654321.001234, "AFPercent_Format(0, 2)", "98.765.432.100%"); 405 expectEventValue(987654321.001234, "AFPercent_Format(0, 3)", "98765432100%"); 406 expectEventValue(987654321.001234, "AFPercent_Format(0, 4)", "98'765'432'100%"); 407 expectEventValue(987654321.001234, "AFPercent_Format(1, 0)", "98,765,432,100.1%"); 408 expectEventValue(987654321.001234, "AFPercent_Format(1, 1)", "98765432100.1%"); 409 expectEventValue(987654321.001234, "AFPercent_Format(1, 2)", "98.765.432.100,1%"); 410 expectEventValue(987654321.001234, "AFPercent_Format(1, 3)", "98765432100,1%"); 411 expectEventValue(987654321.001234, "AFPercent_Format(1, 4)", "98'765'432'100.1%"); 412 expectEventValue(987654321.001234, "AFPercent_Format(2, 0)", "98,765,432,100.12%"); 413 expectEventValue(987654321.001234, "AFPercent_Format(2, 1)", "98765432100.12%"); 414 expectEventValue(987654321.001234, "AFPercent_Format(2, 2)", "98.765.432.100,12%"); 415 expectEventValue(987654321.001234, "AFPercent_Format(2, 3)", "98765432100,12%"); 416 expectEventValue(987654321.001234, "AFPercent_Format(2, 4)", "98'765'432'100.12%"); 417 expectEventValue(987654321.001234, "AFPercent_Format(3, 0)", "98,765,432,100.123%"); 418 expectEventValue(987654321.001234, "AFPercent_Format(3, 1)", "98765432100.123%"); 419 expectEventValue(987654321.001234, "AFPercent_Format(3, 2)", "98.765.432.100,123%"); 420 expectEventValue(987654321.001234, "AFPercent_Format(3, 3)", "98765432100,123%"); 421 expectEventValue(987654321.001234, "AFPercent_Format(3, 4)", "98'765'432'100.123%"); 422 expectEventValue(987654321.001234, "AFPercent_Format(10, 0)", "98,765,432,100.1234130859%"); 423 expectEventValue(987654321.001234, "AFPercent_Format(10, 1)", "98765432100.1234130859%"); 424 expectEventValue(987654321.001234, "AFPercent_Format(10, 2)", "98.765.432.100,1234130859%"); 425 expectEventValue(987654321.001234, "AFPercent_Format(10, 3)", "98765432100,1234130859%"); 426 expectEventValue(987654321.001234, "AFPercent_Format(10, 4)", "98'765'432'100.1234130859%"); 427 428 expectEventValue(987654321, "AFPercent_Format(0, 0)", "98,765,432,100%"); 429 expectEventValue(987654321, "AFPercent_Format(0, 1)", "98765432100%"); 430 expectEventValue(987654321, "AFPercent_Format(0, 2)", "98.765.432.100%"); 431 expectEventValue(987654321, "AFPercent_Format(0, 3)", "98765432100%"); 432 expectEventValue(987654321, "AFPercent_Format(0, 4)", "98'765'432'100%"); 433 expectEventValue(987654321, "AFPercent_Format(1, 0)", "98,765,432,100.0%"); 434 expectEventValue(987654321, "AFPercent_Format(1, 1)", "98765432100.0%"); 435 expectEventValue(987654321, "AFPercent_Format(1, 2)", "98.765.432.100,0%"); 436 expectEventValue(987654321, "AFPercent_Format(1, 3)", "98765432100,0%"); 437 expectEventValue(987654321, "AFPercent_Format(1, 4)", "98'765'432'100.0%"); 438 expectEventValue(987654321, "AFPercent_Format(2, 0)", "98,765,432,100.00%"); 439 expectEventValue(987654321, "AFPercent_Format(2, 1)", "98765432100.00%"); 440 expectEventValue(987654321, "AFPercent_Format(2, 2)", "98.765.432.100,00%"); 441 expectEventValue(987654321, "AFPercent_Format(2, 3)", "98765432100,00%"); 442 expectEventValue(987654321, "AFPercent_Format(2, 4)", "98'765'432'100.00%"); 443 expectEventValue(987654321, "AFPercent_Format(3, 0)", "98,765,432,100.000%"); 444 expectEventValue(987654321, "AFPercent_Format(3, 1)", "98765432100.000%"); 445 expectEventValue(987654321, "AFPercent_Format(3, 2)", "98.765.432.100,000%"); 446 expectEventValue(987654321, "AFPercent_Format(3, 3)", "98765432100,000%"); 447 expectEventValue(987654321, "AFPercent_Format(3, 4)", "98'765'432'100.000%"); 448 expectEventValue(987654321, "AFPercent_Format(10, 0)", "98,765,432,100.0000000000%"); 449 expectEventValue(987654321, "AFPercent_Format(10, 1)", "98765432100.0000000000%"); 450 expectEventValue(987654321, "AFPercent_Format(10, 2)", "98.765.432.100,0000000000%"); 451 expectEventValue(987654321, "AFPercent_Format(10, 3)", "98765432100,0000000000%"); 452 expectEventValue(987654321, "AFPercent_Format(10, 4)", "98'765'432'100.0000000000%"); 453 454 expectEventValue(0.01, "AFPercent_Format(1, 0)", "1.0%"); 455 expectEventValue(0.001, "AFPercent_Format(1, 0)", "0.1%"); 456 expectEventValue(0.0001, "AFPercent_Format(1, 0)", "0.0%"); 457 expectEventValue(0.00001, "AFPercent_Format(1, 0)", "0.0%"); 458 expectEventValue(0.000001, "AFPercent_Format(1, 0)", "0.0%"); 459 expectEventValue(0.000001, "AFPercent_Format(10, 2)", "0,0001000000%"); 460 461 // Acrobat behaves strangely with smaller values. 462 // expectEventValue(0.0000001, "AFPercent_Format(1, 0)", "-170.0%"); 463 // expectEventValue(0.00000001, "AFPercent_Format(1, 0)", "-180.0%"); 464 465 expectEventValue(0, "AFPercent_Format(20, 0)", "0.00000000000000000000%"); 466 expectEventValue(0, "AFPercent_Format(308, 0)", "0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000%"); 467 // Acrobat starts failing here. 468 // expectEventValue(0, "AFPercent_Format(309, 0)", "-1.#IND000...000%"); 469 470 expectEventValue(0.000001, "AFPercent_Format(308, 0)", "0.00009999999999999999123964644631712417321978136897087097167968750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000%"); 471 // After 512, Acrobat probably ran out of buffer space. 472 expectEventValue(0, "AFPercent_Format(513, 0)", "%"); 473 474 app.alert("**********************"); 475 476 expectError('', "AFPercent_Keystroke()"); 477 expectError('', "AFPercent_Keystroke(1)"); 478 expectError("abc", "AFPercent_Keystroke(1, 0)"); 479 expectEventValue(".123", "AFPercent_Keystroke(1, 0)", ".123"); 480 481 app.alert("**********************"); 482 483 expectError('', "AFRange_Validate()", ''); 484 expectError('', "AFRange_Validate(1, 2, 3, 4, 5)", ''); 485 expectEventValue("1", "AFRange_Validate(true, 2, true, 4)", "1"); // Notifies "between". 486 expectEventValue("5", "AFRange_Validate(true, 2, true, 4)", "5"); // Notifies "between". 487 expectEventValue("1", "AFRange_Validate(true, 2, false, 4)", "1"); // Notifies "greater". 488 expectEventValue("5", "AFRange_Validate(false, 2, true, 4)", "5"); // Notifies "less". 489 expectEventValue("3", "AFRange_Validate(true, 2, true, 4)", "3"); // No notification. 490 expectEventValue("1", "AFRange_Validate(false, 2, true, 4)", "1"); // No notification. 491 expectEventValue("5", "AFRange_Validate(true, 2, false, 4)", "5"); // No notification. 492 493 app.alert("**********************"); 494 495 expectError('', "AFSimple()", 2); 496 expectError('', "AFSimple(1, 2, 3, 4)"); 497 expectError('', "AFSimple(1, 2, 3)"); 498 expectError('', "AFSimple('nonesuch', 2, 3)"); 499 expect('', "AFSimple('AVG', 2, 3)", 2.5); 500 expect('', "AFSimple('MIN', 2, 3)", 2); 501 expect('', "AFSimple('MAX', 2, 3)", 3); 502 expect('', "AFSimple('SUM', 2, 3)", 5); 503 expect('', "AFSimple('PRD', 2, 3)", 6); 504 expectError('', "AFSimple('AVG', 2, 'nonesuch')"); 505 expectError('', "AFSimple('MIN', 2, 'nonesuch')"); 506 expectError('', "AFSimple('MAX', 2, 'nonesuch')"); 507 expectError('', "AFSimple('SUM', 2, 'nonesuch')"); 508 expectError('', "AFSimple('PRD', 2, 'nonesuch')"); 509 510 app.alert("**********************"); 511 512 // These two should throw "TypeError", not "AFSimple_Calculate". 513 // https://crbug.com/pdfium/1396 514 expectError('', "AFSimple_Calculate()"); 515 expectError('', "AFSimple_Calculate(1)"); 516 // This should "pass", but currently throws an error. 517 // https://crbug.com/pdfium/1396 518 expectEventValue('', "AFSimple_Calculate('blooey', ['Text2', 'Text3'])", 0); 519 // This should fail with TypeError, since a field does not exist, but 520 // currently passes. https://crbug.com/pdfium/1396 521 expectEventValue('', "AFSimple_Calculate('AVG', [1, 'nonesuch', {'crud': 32}])", 0); 522 expectEventValue('', "AFSimple_Calculate('AVG', ['Text2', 'Text3'])", (123 + 456) / 2); 523 expectEventValue('', "AFSimple_Calculate('SUM', ['Text2', 'Text3'])", 123 + 456); 524 expectEventValue('', "AFSimple_Calculate('PRD', ['Text2', 'Text3'])", 123 * 456); 525 expectEventValue('', "AFSimple_Calculate('MIN', ['Text2', 'Text3'])", 123); 526 expectEventValue('', "AFSimple_Calculate('MAX', ['Text2', 'Text3'])", 456); 527 expectEventValue('', "AFSimple_Calculate('AVG', 'Text2, Text3')", (123 + 456) / 2); 528 expectEventValue('', "AFSimple_Calculate('AVG', ['Text4'])", 407.96); 529 expectEventValue('', "AFSimple_Calculate('SUM', ['Text4'])", 407.96); 530 expectEventValue('', "AFSimple_Calculate('MIN', ['Text4'])", 407.96); 531 expectEventValue('', "AFSimple_Calculate('MAX', ['Text4'])", 407.96); 532 expectEventValue('', "AFSimple_Calculate('AVG', ['Text2', 'Text4'])", (123 + 407.96) / 2); 533 expectEventValue('', "AFSimple_Calculate('SUM', ['Text2', 'Text4'])", 123 + 407.96); 534 expectEventValue('', "AFSimple_Calculate('PRD', ['Text2', 'Text4'])", 50179.08); 535 536 app.alert("**********************"); 537 538 expectError('', "AFSpecial_Format()", ''); 539 expectError('', "AFSpecial_Format(1, 2)", ''); 540 expectEventValue('', "AFSpecial_Format(0)", ""); 541 expectEventValue('', "AFSpecial_Format(1)", "-"); 542 expectEventValue('', "AFSpecial_Format(2)", "-"); 543 expectEventValue('', "AFSpecial_Format(3)", "--"); 544 expectEventValue("0123456789", "AFSpecial_Format(0)", "01234"); 545 expectEventValue("0123456789", "AFSpecial_Format(1)", "01234-5678"); 546 expectEventValue("0123456789", "AFSpecial_Format(2)", "(012) 345-6789"); 547 expectEventValue("0123456789", "AFSpecial_Format(3)", "012-34-5678"); 548 549 app.alert("**********************"); 550 551 expectError('', "AFSpecial_Keystroke()"); 552 expectError('', "AFSpecial_Keystroke(65, 66)"); 553 expectEventValue("abc", "AFSpecial_Keystroke(65)", "abc"); 554 555 app.alert("**********************"); 556 557 expectError('', "AFSpecial_KeystrokeEx()", ''); 558 expectEventValue("12345", "AFSpecial_KeystrokeEx('')", "12345"); // No notification. 559 expectEventValue("123", "AFSpecial_KeystrokeEx('9999')", "123"); // Notifies invalid. 560 expectEventValue("12345", "AFSpecial_KeystrokeEx('9999')", "12345"); // Notifies too long. 561 expectEventValue("abcd", "AFSpecial_KeystrokeEx('9999')", "abcd"); // Notifies invalid. 562 expectEventValue("1234", "AFSpecial_KeystrokeEx('9999')", "1234"); 563 expectEventValue("abcd", "AFSpecial_KeystrokeEx('XXXX')", "abcd"); 564 565 app.alert("**********************"); 566 567 expectError('', "AFTime_Format()"); 568 expectError('', "AFTime_Format(1, 2)"); 569 expectEventValue(0, "AFTime_Format(1)", "9:48 pm"); 570 571 app.alert("**********************"); 572 573 expectError('', "AFTime_FormatEx()"); 574 expectError('', "AFTime_FormatEx('blooey', 42)"); 575 expectEventValue(0, "AFTime_FormatEx('blooey')", "blooey"); 576 577 app.alert("**********************"); 578 579 expectError('', "AFTime_Keystroke()", ''); 580 expectError('', "AFTime_Keystroke(1, 2)", ''); 581 expectEventValue("12:03", "AFTime_Keystroke(65)", "12:03"); 582 583 app.alert("**********************"); 584 585 expectError('', "AFTime_KeystrokeEx()"); 586 expectError('', "AFTime_KeystrokeEx(1, 2)"); 587 expectEventValue("12:04", "AFTime_KeystrokeEx('blooey')", "12:04"); 588 589 app.alert("*** ending test 1 ***"); 590 } catch (e) { 591 app.alert("Truly unexpected error occured: " + e); 592 } 593 ) 594>> 595endobj 596{{object 18 0}} << 597 /S /JavaScript 598 /JS ( 599 // Re-run tests that depend on the "will commit" status of the event 600 // that triggered their execution. 601 try { 602 app.alert("*** starting test 2 ***"); 603 604 expectError('', "AFDate_Keystroke()"); 605 expectError('', "AFDate_Keystroke(1, 2)"); 606 expectEventValue("04/19", "AFDate_Keystroke(2)", "04/19"); 607 expectEventValue("04/19/15", "AFDate_Keystroke('blooey')", "04/19/15"); 608 609 app.alert("**********************"); 610 611 expectError('', "AFNumber_Keystroke()"); 612 expectError('', "AFNumber_Keystroke(1)"); 613 expectError("abc", "AFNumber_Keystroke(1, 2)"); 614 expectEventValue("123", "AFNumber_Keystroke(1, 2)", "123"); 615 expectEventValue("123", "AFNumber_Keystroke(1, 2, 3)", "123"); 616 617 app.alert("**********************"); 618 619 expectError('', "AFSpecial_KeystrokeEx()", ''); 620 expectEventValue("12345", "AFSpecial_KeystrokeEx('')", "12345"); // No notification. 621 expectEventValue("123", "AFSpecial_KeystrokeEx('9999')", "123"); // Notifies invalid. 622 expectEventValue("12345", "AFSpecial_KeystrokeEx('9999')", "12345"); // Notifies too long. 623 expectEventValue("abcd", "AFSpecial_KeystrokeEx('9999')", "abcd"); // Notifies invalid. 624 expectEventValue("1234", "AFSpecial_KeystrokeEx('9999')", "1234"); 625 expectEventValue("abcd", "AFSpecial_KeystrokeEx('XXXX')", "abcd"); 626 627 app.alert("**********************"); 628 629 expectError('', "AFMergeChange()"); 630 expectError('', "AFMergeChange(1, 2)"); 631 expect("one", "AFMergeChange(undefined)", "Aone"); 632 633 app.alert("*** ending test 2 ***"); 634 } catch (e) { 635 app.alert("Truly unexpected error occured: " + e); 636 } 637 ) 638>> 639endobj 640{{object 19 0}} << 641 /S /JavaScript 642 /JS ( 643 app.alert('Unexpected script 19'); 644 ) 645>> 646endobj 647{{xref}} 648{{trailer}} 649{{startxref}} 650%%EOF 651