Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / test / data / nacl / bad / ppapi_bad.html
blob4cb428557d9779ade4e056d39343640cb6116701
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html>
4 <!--
5 Copyright 2013 The Chromium Authors. All rights reserved.
6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file.
8 -->
9 <head>
10 <META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
11 <META HTTP-EQUIV="Expires" CONTENT="-1" />
12 <script type="text/javascript" src="nacltest.js"> </script>
13 <script type="text/javascript" src="ppapi_bad.js"> </script>
14 <title> PPAPI bad manifest/nexe URLs </title>
15 <style type="text/css">
16 .naclModule { background-color: gray; margin: 2px 2px; }
17 </style>
18 </head>
19 <body id="body">
20 <script type="text/javascript">
21 //<![CDATA[
23 var prefix = 'NaCl module load failed: ';
25 // PNaCl may have slightly different error messages (pexe instead of nexe).
26 function couldNotAccessNexe(is_pnacl) {
27 if (!is_pnacl) {
28 return prefix + 'access to nexe url was denied.';
29 } else {
30 return prefix + 'PnaclCoordinator: pexe load failed (no access).';
34 // PNaCl may have slightly different error messages (pexe instead of nexe).
35 function couldNotLoadNexe(is_pnacl) {
36 if (!is_pnacl) {
37 return prefix + 'could not load nexe url.';
38 } else {
39 /* PP_ERROR_FAILED */
40 return prefix + 'PnaclCoordinator: pexe load failed (pp_error=-2).';
44 function declareTests(tester) {
45 var is_pnacl = getTestArguments()['pnacl'] !== undefined;
46 var mime_type = "application/x-nacl";
47 if (is_pnacl) {
48 mime_type = "application/x-pnacl";
51 // 'bad_magic' loads a manifest, then loads a nexe that tests as invalid.
52 badLoadTest(
53 tester,
54 'bad_magic',
55 'ppapi_bad_magic.nmf',
56 mime_type,
57 is_pnacl
58 ? 'NaCl module load failed: PnaclCoordinator: PNaCl Translator Error: Invalid PNaCl bitcode header'
59 : 'NaCl module load failed: Bad ELF header magic number');
61 // 'nonexistent_nexe' loads a manifest, then tries to load a nonexistent nexe.
62 badLoadTest(
63 tester,
64 'nonexistent_nexe',
65 'ppapi_bad_doesnotexist.nmf',
66 mime_type,
67 couldNotLoadNexe(is_pnacl));
69 // 'nonexistent_manifest' tries to load a nonexistent manifest.
70 badLoadTest(
71 tester,
72 'nonexistent_manifest',
73 'doesnotexist.manifest',
74 mime_type,
75 'NaCl module load failed: could not load manifest url.');
77 // 'bad_manifest' loads an invalid manifest.
78 badLoadTest(
79 tester,
80 'bad_manifest',
81 'ppapi_bad.html',
82 mime_type,
83 'NaCl module load failed: manifest JSON parsing failed: * Line 1, Column 1\n Syntax error: value, object or array expected.\n');
85 // 'bad_manifest_uses_nexes' loads a manifest with an obsolete 'nexes' section.
86 badLoadTest(
87 tester,
88 'bad_manifest_uses_nexes',
89 'ppapi_bad_manifest_uses_nexes.nmf',
90 mime_type,
91 'NaCl module load failed: manifest: missing \'program\' section.');
93 // 'bad_manifest_bad_files' loads a manifest with a bad 'files' section.
94 badLoadTest(
95 tester,
96 'bad_manifest_bad_files',
97 'ppapi_bad_manifest_bad_files.nmf',
98 mime_type,
99 // Manifest loader expects either 'url' or 'pnacl-translate' key present.
100 // If neither is found, it complains about the last one.
101 'NaCl module load failed: manifest: file.txt property \'unknown_arch\' does not have required key: \'url\'.');
103 // 'bad_manifest_nexe_arch' loads a manifest with no program entry for the
104 // user's architecture
105 badLoadTest(
106 tester,
107 'bad_manifest_nexe_arch',
108 'ppapi_bad_manifest_nexe_arch.nmf',
109 mime_type,
110 is_pnacl
111 ? 'NaCl module load failed: manifest: no version of program given for portable.'
112 : 'NaCl module load failed: manifest: no version of program given for current arch and no portable version found.');
114 //////////////////////////////////////
115 // Initialization errors begin here //
116 //////////////////////////////////////
118 // 'bad_ppp_initialize' loads a manifest, then loads a nexe that fails to
119 // initialize PPAPI module
120 badLoadTest(
121 tester,
122 'bad_ppp_initialize',
123 'ppapi_bad_ppp_initialize.nmf',
124 mime_type,
125 'NaCl module load failed: could not initialize module.');
127 // 'bad_ppp_initialize_crash' loads a manifest, then loads a nexe that crashes
128 // before initializing PPAPI module
129 badLoadTest(
130 tester,
131 'bad_ppp_initialize_crash',
132 'ppapi_bad_ppp_initialize_crash.nmf',
133 mime_type,
134 'NaCl module load failed: could not initialize module.');
136 // 'bad_no_ppp_instance' loads a manifest, then loads a nexe that fails to
137 // get the required PPP_Instance interface
138 badLoadTest(
139 tester,
140 'bad_no_ppp_instance',
141 'ppapi_bad_no_ppp_instance.nmf',
142 mime_type,
143 'NaCl module load failed: could not initialize module.');
145 // 'bad_get_ppp_instance_crash' loads a manifest, then loads a nexe that
146 // crashes when getting the required PPP_Instance interface
147 badLoadTest(
148 tester,
149 'bad_get_ppp_instance_crash',
150 'ppapi_bad_get_ppp_instance_crash.nmf',
151 mime_type,
152 'NaCl module load failed: could not initialize module.');
154 // 'bad_ppp_instance_didcreate' loads a manifest, then loads a nexe that fails
155 // to create the instance
156 badLoadTest(
157 tester,
158 'bad_ppp_instance_didcreate',
159 'ppapi_bad_ppp_instance_didcreate.nmf',
160 mime_type,
161 'NaCl module load failed: could not create instance.');
163 // 'bad_ppp_instance_didcreate_crash' loads a manifest, then loads a nexe that
164 // crashes before creating the instance.
165 badLoadTest(
166 tester,
167 'bad_ppp_instance_didcreate_crash',
168 'ppapi_bad_ppp_instance_didcreate_crash.nmf',
169 mime_type,
170 'NaCl module load failed: could not create instance.');
172 /* TODO(bbudge) Re-enable this test when the IPC proxy can report these errors.
173 http://crbug.com/160076
174 // 'bad_event_replay_crash' loads a manifest, then loads a nexe and replays
175 // the events that occured during loading causing the nexe to crash before
176 // proxy start-up was completed.
177 badLoadTest(
178 tester,
179 'bad_event_replay_crash',
180 'ppapi_bad_event_replay_crash.nmf',
181 mime_type,
182 'NaCl module load failed: instance crashed after creation.');
187 // The driver invoked when the body has finished loading.
188 function runTests() {
189 var tester = new Tester($('body'));
190 tester.loadErrorsAreOK();
191 declareTests(tester);
192 tester.run();
194 //]]>
195 </script>
197 <!-- The tests will create and remove embeds from this div. -->
198 <div id="embeds"></div>
200 <!-- These two embeds are not automatically tested - visual inspection only. -->
202 <embed id="cross_manifest_pdf"
203 width=100 height=20
204 src="http://www.google.com/crossorigin.manifest"
205 style="background-color:gray"
206 type="application/pdf" />
208 <!-- This load would have succeeded if the NEXE was from a chrome-extension
209 URL and NaCl had been registered as handling the PDF MIME type using
210 the nacl_modules attribute in a Chrome extension manifest. -->
212 <embed id="cross_origin_pdf"
213 width=100 height=20
214 src="ppapi_bad_crossorigin.nmf"
215 style="background-color:gray"
216 type="application/pdf" />
218 <script type="text/javascript">
219 //<![CDATA[
220 runTests();
221 //]]>
222 </script>
223 </body>
224 </html>