1{{header}} 2{{object 1 0}} << 3 /Type /Catalog 4 /Pages 2 0 R 5 /OpenAction 10 0 R 6>> 7endobj 8{{object 2 0}} << 9 /Type /Pages 10 /Count 4 11 /Kids [ 12 3 0 R 13 4 0 R 14 5 0 R 15 6 0 R 16 ] 17>> 18endobj 19% Page number 0. 20{{object 3 0}} << 21 /Type /Page 22 /Parent 2 0 R 23 /Resources << 24 /Font <</F1 15 0 R>> 25 >> 26 /MediaBox [0 0 612 792] 27 /Contents 8 0 R 28>> 29endobj 30% Page number 1. 31{{object 4 0}} << 32 /Type /Page 33 /Parent 2 0 R 34 /Resources << 35 /Font <</F1 15 0 R>> 36 >> 37 /MediaBox [0 0 612 792] 38>> 39endobj 40% Page number 2. 41{{object 5 0}} << 42 /Type /Page 43 /Parent 2 0 R 44 /Resources << 45 /Font <</F1 15 0 R>> 46 >> 47 /MediaBox [0 0 612 792] 48>> 49endobj 50% Page number 3. 51{{object 6 0}} << 52 /Type /Page 53 /Parent 2 0 R 54 /Resources << 55 /Font <</F1 15 0 R>> 56 >> 57 /MediaBox [0 0 612 792] 58>> 59endobj 60% Contents of the page. 61{{object 8 0}} << 62 {{streamlen}} 63>> 64stream 65BT 6620 50 Td 67/F1 12 Tf 68(Hello, world!) Tj 690 50 Td 70endstream 71endobj 72% Info 73{{object 9 0}} << 74 /Author (Joe Random Author) 75 /Creator (Joe Random Creator) 76>> 77endobj 78% OpenAction action 79{{object 10 0}} << 80 /Type /Action 81 /S /JavaScript 82 /JS 11 0 R 83>> 84endobj 85% JS program to execute 86{{object 11 0}} << 87 {{streamlen}} 88>> 89stream 90{{include expect.js}} 91 92// "Unsupported" methods are present in the document object, but not 93// implemented. They always return |undefined| regardless of arguments. 94function testUnsupported(str) { 95 expect('typeof ' + str, 'function'); 96 expect(str + '()', undefined); 97 expect(str + '(1, 2, "clams", [1, 2, 3])', undefined); 98} 99 100function testAddIcon() { 101 // Method is present. 102 expect('typeof this.addIcon', 'function'); 103 104 // Method takes exactly two arguments. 105 expectError('this.addIcon()'); 106 expectError('this.addIcon(1)'); 107 expectError('this.addIcon(1, 2, 3)'); 108 109 // Second argument must actually be an icon. 110 expectError('this.addIcon("myicon", 3)'); 111 expectError('this.addIcon("myicon", undefined)'); 112 113 // TODO(tsepez): test success cases. 114} 115 116function testCalculateNow() { 117 // Method is present. 118 expect('typeof this.calculateNow', 'function'); 119 120 // TODO(tsepez): test with no permissions. 121 122 expect('this.calculateNow()', undefined) 123} 124 125function testGetAnnot() { 126 // Method is present. 127 expect('typeof this.getAnnot', 'function'); 128 129 // Method needs two arguments. 130 expectError('this.getAnnot()'); 131 expectError('this.getAnnot(0)'); 132 expectError('this.getAnnot(0, "test", 0)'); 133 134 // TODO(tonikitoo): test success cases. 135} 136 137function testGetAnnots() { 138 // Method is present. 139 expect('typeof this.getAnnots', 'function'); 140 141 // TODO(tonikitoo): test success cases. 142} 143 144function testGetField() { 145 // Method is present. 146 expect('typeof this.getField', 'function'); 147 148 // Method needs at least one argument. 149 expectError('this.getField()'); 150 151 // TODO(tsepez): test success cases. 152} 153 154function testGetIcon() { 155 // Method is present. 156 expect('typeof this.getIcon', 'function'); 157 158 // Method needs exactly one argument. 159 expectError('this.getIcon()'); 160 expectError('this.getIcon(1, 2)'); 161 162 // TODO(tsepez): test success cases. 163} 164 165function testGetNthFieldName() { 166 // Method is present. 167 expect('typeof this.getNthFieldName', 'function'); 168 169 // Method needs at least one argument. 170 expectError('this.getNthFieldName()'); 171 172 // Argument can not be negative. 173 expectError('this.getNthFieldName(-1)'); 174 175 // Argument can not be huge. 176 expectError('this.getNthFieldName(400000)'); 177 178 // TODO(tsepez): add field object so this case works. 179 expectError('this.getNthFieldName(0)'); 180} 181 182function testGetPageNthWord() { 183 // Method is present. 184 expect('typeof this.getPageNthWord', 'function'); 185 186 // Method accepts any number of parameters. 187 expect('this.getPageNthWord(0, 0, true, "clams", [1, 2])', 'Hello,'); 188 189 // Arguments can't be negative or out of range. 190 expectError('this.getPageNthWord(-1, 0, true)'); 191 expectError('this.getPageNthWord(6, 0, true)'); 192 193 // TODO(tsepez): test with no permissions. 194 // TODO(tsepez): test success cases. 195} 196 197function testGetPageNthWordQuads() { 198 // Method is present. 199 expect('typeof this.getPageNthWordQuads', 'function'); 200 201 // TODO(tsepez): test with no permissions. 202 203 expectError('this.getPageNthWordQuads()'); 204} 205 206function testGetPageNumWords() { 207 // Method is present. 208 expect('typeof this.getPageNumWords', 'function'); 209 210 // Method accepts any number of parameters. 211 expect('this.getPageNumWords(0, "clams", [1, 2])', 2); 212 213 // Arguments can't be negative or out of range. 214 expectError('this.getPageNumWords(-1)'); 215 expectError('this.getPageNumWords(6)'); 216 217 // TODO(tsepez): test with no permissions. 218 // TODO(tsepez): test success cases. 219} 220 221function testGetPrintParams() { 222 // Method is present. 223 expect('typeof this.getPrintParams', 'function'); 224 225 // Method always returns in error. 226 expectError('this.getPrintParams()'); 227 expectError('this.getPrintParams(42)'); 228} 229 230function testGotoNamedDest() { 231 // Method is present. 232 expect('typeof this.gotoNamedDest', 'function'); 233 234 // Method needs exactly one argument. 235 expectError('this.gotoNamedDest()'); 236 expectError('this.gotoNamedDest(1, 2)'); 237 238 // TODO(tsepez): add actual named dest matching this. 239 expectError('this.gotoNamedDest("chicago")'); 240} 241 242function testMailDoc() { 243 // Method is present. 244 expect('typeof this.mailDoc', 'function'); 245 246 // TODO(tsepez): test with no permissions. 247 248 // Success cases. 249 expect('this.mailDoc()', undefined); 250 expect('this.mailDoc(false, "[email protected]", "[email protected]", ' + 251 '"[email protected]", "Lottery Winner", "You won the lottery!")', 252 undefined); 253 expect('this.mailDoc({})', undefined); 254 expect('this.mailDoc({"bUI": false, "cTo": "[email protected]", ' + 255 '"cCc": "[email protected]", "cBcc": "[email protected]", ' + 256 '"cSubject": "LotteryWinner", "cMsg": "You won the lottery!", ' + 257 '"bogus": "yes"})', 258 undefined); 259} 260 261function testMailForm() { 262 // Method is present. 263 expect('typeof this.mailForm', 'function'); 264 265 // TODO(tsepez): test with no permissions. 266 267 // Success cases. 268 expect('this.mailForm()', undefined); 269 expect('this.mailForm(false, "[email protected]", "[email protected]", ' + 270 '"[email protected]", "Lottery Winner", "You won the lottery!")', 271 undefined); 272 expect('this.mailForm({})', undefined); 273 expect('this.mailForm({"bUI": false, "cTo": "[email protected]", ' + 274 '"cCc": "[email protected]", "cBcc": "[email protected]", ' + 275 '"cSubject": "LotteryWinner", "cMsg": "You won the lottery!", ' + 276 '"bogus": "yes"})', 277 undefined); 278} 279 280function testPrint() { 281 // Method is present. 282 expect('typeof this.print', 'function'); 283 284 // Successful only when invoked by a user gesture. 285 expectError('this.print()', undefined); 286} 287 288function testRemoveField() { 289 // Method is present. 290 expect('typeof this.removeField', 'function'); 291 292 // Method requires at least one argument. 293 expectError('this.removeField()'); 294 295 // TODO(tsepez): test with no permissions. 296 // TODO(tsepez): test success cases. 297} 298 299function testResetForm() { 300 // Method is present. 301 expect('typeof this.resetForm', 'function'); 302 303 // TODO(tsepez): test with no permissions. 304 305 // TODO(tsepez): Add form to document to match these arguments. 306 expect('this.resetForm()', undefined); 307 expect('this.resetForm("myform")', undefined); 308} 309 310function testSubmitForm() { 311 // Method is present. 312 expect('typeof this.submitForm', 'function'); 313 314 // Method requires at least one argument. 315 expectError('this.submitForm()'); 316 317 // Successful only when invoked by a user gesture. 318 expectError('this.submitForm("myform", true, true, ["name", "age"])'); 319} 320 321try { 322 app.alert('*** Testing Unsupported Methods ***'); 323 testUnsupported('this.addAnnot'); 324 testUnsupported('this.addField'); 325 testUnsupported('this.addLink'); 326 testUnsupported('this.closeDoc'); 327 testUnsupported('this.createDataObject'); 328 testUnsupported('this.deletePages'); 329 testUnsupported('this.exportAsFDF'); 330 testUnsupported('this.exportAsText'); 331 testUnsupported('this.exportAsXFDF'); 332 testUnsupported('this.extractPages'); 333 testUnsupported('this.getAnnot3D'); 334 testUnsupported('this.getAnnots3D'); 335 testUnsupported('this.getLinks'); 336 testUnsupported('this.getOCGs'); 337 testUnsupported('this.getPageBox'); 338 testUnsupported('this.getURL'); 339 testUnsupported('this.importAnFDF'); 340 testUnsupported('this.importAnXFDF'); 341 testUnsupported('this.importTextData'); 342 testUnsupported('this.insertPages'); 343 testUnsupported('this.removeIcon'); 344 testUnsupported('this.replacePages'); 345 testUnsupported('this.saveAs'); 346 testUnsupported('this.syncAnnotScan'); 347 348 app.alert('*** Testing Supported Methods ***'); 349 testAddIcon(); 350 testCalculateNow(); 351 testGetAnnot(); 352 testGetAnnots(); 353 testGetField(); 354 testGetIcon(); 355 testGetNthFieldName(); 356 testGetPageNthWord(); 357 testGetPageNthWordQuads(); 358 testGetPageNumWords(); 359 testGetPrintParams(); 360 testGotoNamedDest(); 361 testMailDoc(); 362 testMailForm(); 363 testPrint(); 364 testRemoveField(); 365 testResetForm(); 366 testSubmitForm(); 367} catch (e) { 368 app.alert('FATAL: ' + e.toString()); 369} 370endstream 371endobj 372{{xref}} 373trailer << 374 /Root 1 0 R 375 /Info 9 0 R 376>> 377{{startxref}} 378%%EOF 379