xref: /aosp_15_r20/external/pdfium/testing/resources/javascript/app_methods.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  /MediaBox [0 0 612 792]
21>>
22endobj
23% OpenAction action
24{{object 10 0}} <<
25  /Type /Action
26  /S /JavaScript
27  /JS 11 0 R
28>>
29endobj
30% JS program to execute
31{{object 11 0}} <<
32  {{streamlen}}
33>>
34stream
35{{include expect.js}}
36
37try {
38  // Test unicode support, no particular reason for these CJK characters.
39  expect("app.alert('message \u4023', 1, 2, 'title \u4024')", 0);
40  expect("app.alert({'cMsg': 'message', 'cTitle': 'title'})", 0);
41  expect("app.alert({'cMsg': 'message', 'cTitle': 'title', 'nIcon': 3, 'nType': 4})", 0);
42  expect("app.alert(undefined)", 0);
43  expect("app.alert(null)", 0);
44  expect("app.alert(true)", 0);
45  expect("app.alert(false)", 0);
46  expect("app.alert(42)", 0);
47  expect("app.alert([1, 2, 3])", 0);
48  expect("app.alert([1, 2, {'color': 'red'}])", 0);
49  expect("app.alert({'color': 'red'}, 5, 6, 'title')", 0);
50  expectError("app.alert()");
51  expectError("app.alert({})");
52  expectError("app.alert({'color': 'red', 'size': 42})");
53
54  expect("app.beep(1)", undefined);
55
56  expectError("app.browseForDoc()");
57  expect("app.execDialog()", undefined);
58  expectError("app.execMenuItem()");
59  expect("app.findComponent()", undefined);
60  expect("app.goBack()", undefined);
61  expect("app.goForward()", undefined);
62  expect("app.launchURL()", undefined);
63  expectError("app.newDoc()");
64  expect("app.newFDF()", undefined);
65  expectError("app.openDoc()");
66  expect("app.openFDF()", undefined);
67  expectError("app.popUpMenuEx()");
68  expectError("app.popUpMenu()");
69
70  expect("app.mailMsg(true)", undefined);
71  expect("app.mailMsg(false, '[email protected]')", undefined);
72  expect("app.mailMsg(false, '[email protected]', '[email protected]', " +
73         "'[email protected]', 'subject', 'body')", undefined);
74  expect("app.mailMsg({'bUI': true})", undefined);
75  expect("app.mailMsg({'bUI': false, 'cTo': '[email protected]'})", undefined);
76  expect("app.mailMsg({'bUI': false, 'cTo': '[email protected]', " +
77         "'cCc': '[email protected]', 'cBcc': '[email protected]', " +
78         "'cSubject': 'subject', 'cMsg': 'body'})", undefined);
79  expectError("app.mailMsg()");
80  expectError("app.mailMsg(false)");
81  expectError("app.mailMsg({'color': 'red', 'size': 42})");
82
83  expect("app.response('question')", 'No');
84  expect("app.response('question', 'title', 'default', true, 'label')", 'No');
85  expect("app.response({'cQuestion': 'question'})", 'No');
86  expect("app.response({'cQuestion': 'question', 'cTitle': 'title', " +
87         "'cDefault': 'default', 'bPassword': true, 'cLabel': 'label'})", 'No');
88  expectError("app.response()");
89  expectError("app.response({})");
90
91} catch (e) {
92  app.alert('Truly unexpected error: ' + e);
93}
94endstream
95endobj
96{{xref}}
97{{trailer}}
98{{startxref}}
99%%EOF
100