xref: /aosp_15_r20/external/pdfium/testing/resources/javascript/apply.in (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
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 1
11  /Kids [
12    3 0 R
13  ]
14>>
15endobj
16% Page number 0.
17{{object 3 0}} <<
18  /Type /Page
19  /Parent 2 0 R
20  /Resources <<
21    /Font <</F1 15 0 R>>
22  >>
23  /Contents [21 0 R]
24  /MediaBox [0 0 612 792]
25>>
26endobj
27% OpenAction action
28{{object 10 0}} <<
29  /Type /Action
30  /S /JavaScript
31  /JS 11 0 R
32>>
33endobj
34% JS program to execute
35{{object 11 0}} <<
36  {{streamlen}}
37>>
38stream
39app.alert('Applying to util itself - should succeed');
40try {
41  app.alert(util.byteToChar.apply(util, [65]));
42}
43catch (e) {
44  app.alert('Caught: ' + e);
45}
46
47app.alert('Applying to array - should throw');
48try {
49  app.alert(util.byteToChar.apply([], [65]));
50}
51catch (e) {
52  app.alert('Caught: ' + e);
53}
54
55app.alert('Applying to number - should throw');
56try {
57  app.alert(util.byteToChar.apply(7, [65]));
58}
59catch (e) {
60  app.alert('Caught: ' + e);
61}
62
63app.alert('Applying to wrong native obj - should throw');
64try {
65  app.alert(util.byteToChar.apply(app, [65]));
66}
67catch (e) {
68  app.alert('Caught: ' + e);
69}
70endstream
71endobj
72{{xref}}
73{{trailer}}
74{{startxref}}
75%%EOF
76