imcplugin demo: Extend to support stat() call
[nativeclient.git] / tests / srpc / srpc_plugin.html
blob25e42723ea733c466d4541056e7c256d6f0988e7
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 <!-- Copyright 2009 Google Inc. All rights reserved. -->
5 <head>
6 <title> SRPC Plugin Properties Test </title>
7 <style type="text/css">
8 td.notrun { background-color: skyblue }
9 td.pass { background-color: lime }
10 td.fail { background-color: red }
11 </style>
12 <script type="application/x-javascript">
13 <!--
14 // The count of failing tests. Set from the queue length, and decremented
15 // whenever a test passes.
16 var failing_count;
18 // The queue of small tests.
19 var testQueue = [ ];
20 var appendTest = function(test_descr) {
21 testQueue[testQueue.length] = test_descr;
24 var expectPass = function(element, has_return, fp) {
25 appendTest(new Array('pass', element, has_return, fp));
28 var expectFail = function(element, fp) {
29 appendTest(new Array('fail', element, fp));
32 var PluginProperties = function() {
33 // Test the properties of plugin instances.
34 // Attempt to set height with invalid type.
35 expectFail('plugin_height_null',
36 function() {
37 server.height = undefined;
38 });
39 expectFail('plugin_height_string',
40 function() {
41 server.height = 'string';
42 });
43 expectFail('plugin_height_object',
44 function() {
45 server.height = new Array(10);
46 });
47 // Attempt to set height to a valid type.
48 expectFail('plugin_height_conforming',
49 false,
50 function() {
51 server.height = 100;
52 });
53 // Attempt to set width with invalid type.
54 expectFail('plugin_width_null',
55 function() {
56 server.width = undefined;
57 });
58 expectFail('plugin_width_string',
59 function() {
60 server.width = 'string';
61 });
62 expectFail('plugin_width_object',
63 function() {
64 server.width = new Array(10);
65 });
66 // Attempt to set width to a valid type.
67 expectPass('plugin_width_conforming',
68 false,
69 function() {
70 server.width = 100;
71 });
72 // Attempt to set videoUpdateMode with invalid type.
73 expectFail('plugin_video_null',
74 function() {
75 server.videoUpdateMode = undefined;
76 });
77 expectFail('plugin_video_string',
78 function() {
79 server.videoUpdateMode = 'string';
80 });
81 expectFail('plugin_video_object',
82 function() {
83 server.videoUpdateMode = new Array(10);
84 });
85 // Attempt to set src to a valid type.
86 expectPass('plugin_video_conforming',
87 false,
88 function() {
89 server.videoUpdateMode = 1;
90 });
91 // Attempt to set src with invalid type.
92 expectFail('plugin_src_null',
93 function() {
94 server.src = undefined;
95 });
96 expectFail('plugin_src_integer',
97 function() {
98 server.src = 100;
99 });
100 expectFail('plugin_src_object',
101 function() {
102 server.src = new Array(10);
104 // Attempt to set src to a valid type.
105 expectPass('plugin_src_conforming',
106 false,
107 function() {
108 server.src = 'srpc_nrd_client.nexe';
112 // The test run functions.
113 var SetTestResult = function(element_id, result) {
114 var element = document.getElementById(element_id);
115 element.className = result;
118 var testExpectedPass = function(element, has_return, fp) {
119 var result = undefined;
120 try {
121 result = fp();
122 if (has_return && (undefined == result)) {
123 SetTestResult(element, 'fail');
124 } else {
125 SetTestResult(element, 'pass');
126 --failing_count;
128 } catch (string) {
129 SetTestResult(element, 'fail');
133 var testExpectedFail = function(element, fp) {
134 var result = undefined;
135 try {
136 result = fp();
137 SetTestResult(element, 'fail');
138 } catch (string) {
139 if (undefined == result) {
140 SetTestResult(element, 'pass');
141 --failing_count;
142 } else {
143 SetTestResult(element, 'fail');
148 var RunAllTests = function() {
149 var i;
150 var len = testQueue.length;
151 // All tests are considered failure until they have run successfully.
152 // This catches runs that end prematurely.
153 failing_count = len;
154 for (i = 0; i < len; ++i) {
155 var test_descr = testQueue[i];
156 if ('pass' == test_descr[0]) {
157 testExpectedPass(test_descr[1], test_descr[2], test_descr[3]);
158 } else {
159 testExpectedFail(test_descr[1], test_descr[2]);
162 if (0 == failing_count) {
163 // All tests passed -- set the selenium magic to success here.
167 var EnqueueAndRunTests = function() {
168 // Plugin properties.
169 // Enqueue the tests.
170 PluginProperties();
171 // Run them all.
172 RunAllTests();
175 // Before running tests we need to ensure the Native Client modules are loaded.
176 var startupTimeout;
178 var RunTestsAfterLoad = function() {
179 // Initialize the selenium magic to failure here.
180 if (server.__moduleReady) {
181 clearTimeout(startupTimeout);
182 EnqueueAndRunTests();
183 } else {
184 if (server.__moduleReady == undefined) {
185 alert('The Native Client plugin was unable to load');
186 return;
188 startupTimeout = setTimeout(RunTestsAfterLoad, 100);
192 // Init is called when the document has completed loading.
193 var Init = function(boxsize) {
194 // Remember object to make access to the elements easier.
195 server = document.getElementById('nacl_server');
196 // Run the tests after ensuring loads have completed.
197 RunTestsAfterLoad();
200 </script>
201 </head>
202 <body onload="Init();">
203 <h1> SRPC Plugin Properties Test </h1>
204 <table cellspacing=5 cellpadding=5 border=5>
205 <tr>
206 <td>
207 </td>
208 <td>
209 <b> height </b>
210 </td>
211 <td>
212 <b> width </b>
213 </td>
214 <td>
215 <b> videoUpdateMode </b>
216 </td>
217 <td>
218 <b> src </b>
219 </td>
220 </tr>
221 <tr>
222 <td>
223 <b> Argument type tests </b>
224 </td>
225 <td valign=top>
226 <table>
227 <tr>
228 <td id="plugin_height_null" class="notrun">
229 undefined
230 </td>
231 </tr>
232 <tr>
233 <td id="plugin_height_string" class="notrun">
234 string
235 </td>
236 </tr>
237 <tr>
238 <td id="plugin_height_object" class="notrun">
239 object
240 </td>
241 </tr>
242 </table>
243 </td>
244 <td valign=top>
245 <table>
246 <tr>
247 <td id="plugin_width_null" class="notrun">
248 undefined
249 </td>
250 </tr>
251 <tr>
252 <td id="plugin_width_string" class="notrun">
253 string
254 </td>
255 </tr>
256 <tr>
257 <td id="plugin_width_object" class="notrun">
258 object
259 </td>
260 </tr>
261 </table>
262 </td>
263 <td valign=top>
264 <table>
265 <tr>
266 <td id="plugin_video_null" class="notrun">
267 undefined
268 </td>
269 </tr>
270 <tr>
271 <td id="plugin_video_string" class="notrun">
272 string
273 </td>
274 </tr>
275 <tr>
276 <td id="plugin_video_object" class="notrun">
277 object
278 </td>
279 </tr>
280 </table>
281 </td>
282 <td valign=top>
283 <table>
284 <tr>
285 <td id="plugin_src_null" class="notrun">
286 undefined
287 </td>
288 </tr>
289 <tr>
290 <td id="plugin_src_integer" class="notrun">
291 integer
292 </td>
293 </tr>
294 <tr>
295 <td id="plugin_src_object" class="notrun">
296 object
297 </td>
298 </tr>
299 </table>
300 </td>
301 </tr>
303 <tr>
304 <td>
305 <b> Expected behavior </b>
306 </td>
307 <td valign=top>
308 <table>
309 <tr>
310 <td id="plugin_height_conforming" class="notrun">
311 integer
312 </td>
313 </tr>
314 </table>
315 </td>
316 <td valign=top>
317 <table>
318 <tr>
319 <td id="plugin_width_conforming" class="notrun">
320 integer
321 </td>
322 </tr>
323 </table>
324 </td>
325 <td valign=top>
326 <table>
327 <tr>
328 <td id="plugin_video_conforming" class="notrun">
329 integer
330 </td>
331 </tr>
332 </table>
333 </td>
334 <td valign=top>
335 <table>
336 <tr>
337 <td id="plugin_src_conforming" class="notrun">
338 string
339 </td>
340 </tr>
341 </table>
342 </td>
343 </tr>
344 </table>
346 <table summary="The color codes used for identifying test outcomes">
347 <tr> <td align="center"> <em> Legend </em> </td> </tr>
348 <tr> <td align="center" class="notrun"> Test not run </td> </tr>
349 <tr> <td align="center" class="pass"> Test passed </td> </tr>
350 <tr> <td align="center" class="fail"> Test failed </td> </tr>
351 </table>
354 NOTE: Some versions of some WebKit-based browsers do not correctly report
355 JavaScript exceptions raised by NPAPI plugins. This can cause some of
356 the above tests to spuriously report failure.
357 </b>
358 </p>
359 <embed type="application/x-nacl-srpc" id="nacl_server"
360 width="0" height="0" src="srpc_nrd_server.nexe" />
361 </body>
362 </html>