OLD | NEW |
| (Empty) |
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 <META HTTP-EQUIV="Pragma" CONTENT="no-cache" /> | |
8 <META HTTP-EQUIV="Expires" CONTENT="-1" /> | |
9 <style type="text/css"> | |
10 td.notrun { background-color: skyblue } | |
11 td.pass { background-color: lime } | |
12 td.fail { background-color: red } | |
13 </style> | |
14 <script type="application/x-javascript"> | |
15 //<![CDATA[ | |
16 // The count of failing tests. Set from the queue length and decremented | |
17 // whenever a test passes. | |
18 var failing_count; | |
19 | |
20 // The queue of small tests. | |
21 var testQueue = [ ]; | |
22 var appendTest = function(test_descr) { | |
23 testQueue[testQueue.length] = test_descr; | |
24 } | |
25 | |
26 var expectPass = function(element, has_return, fp) { | |
27 appendTest(new Array('pass', element, has_return, fp)); | |
28 } | |
29 | |
30 var expectFail = function(element, fp) { | |
31 appendTest(new Array('fail', element, fp)); | |
32 } | |
33 | |
34 var PluginProperties = function() { | |
35 // TODO(gregoryd, sehr): remove the check when the tests pass on Chrome. | |
36 var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1; | |
37 // Test the properties of plugin instances. | |
38 if (!is_chrome) { | |
39 // Attempt to set height with invalid type. | |
40 expectFail('plugin_height_null', | |
41 function() { | |
42 server.height = undefined; | |
43 }); | |
44 expectFail('plugin_height_string', | |
45 function() { | |
46 server.height = 'string'; | |
47 }); | |
48 expectFail('plugin_height_object', | |
49 function() { | |
50 server.height = new Array(10); | |
51 }); | |
52 } | |
53 // Attempt to set height to a valid type. | |
54 expectFail('plugin_height_conforming', | |
55 false, | |
56 function() { | |
57 server.height = 100; | |
58 }); | |
59 if (!is_chrome) { | |
60 // Attempt to set width with invalid type. | |
61 expectFail('plugin_width_null', | |
62 function() { | |
63 server.width = undefined; | |
64 }); | |
65 expectFail('plugin_width_string', | |
66 function() { | |
67 server.width = 'string'; | |
68 }); | |
69 expectFail('plugin_width_object', | |
70 function() { | |
71 server.width = new Array(10); | |
72 }); | |
73 } | |
74 // Attempt to set width to a valid type. | |
75 expectPass('plugin_width_conforming', | |
76 false, | |
77 function() { | |
78 server.width = 100; | |
79 }); | |
80 if (!is_chrome) { | |
81 // Attempt to set videoUpdateMode with invalid type. | |
82 expectFail('plugin_video_null', | |
83 function() { | |
84 server.videoUpdateMode = undefined; | |
85 }); | |
86 expectFail('plugin_video_string', | |
87 function() { | |
88 server.videoUpdateMode = 'string'; | |
89 }); | |
90 expectFail('plugin_video_object', | |
91 function() { | |
92 server.videoUpdateMode = new Array(10); | |
93 }); | |
94 } | |
95 // Attempt to set src to a valid type. | |
96 expectPass('plugin_video_conforming', | |
97 false, | |
98 function() { | |
99 server.videoUpdateMode = 1; | |
100 }); | |
101 if (!is_chrome) { | |
102 // Attempt to set src with invalid type. | |
103 expectFail('plugin_src_null', | |
104 function() { | |
105 server.src = undefined; | |
106 }); | |
107 expectFail('plugin_src_integer', | |
108 function() { | |
109 server.src = 100; | |
110 }); | |
111 expectFail('plugin_src_object', | |
112 function() { | |
113 server.src = new Array(10); | |
114 }); | |
115 } | |
116 // Attempt to set src to a valid type. | |
117 expectPass('plugin_src_conforming', | |
118 false, | |
119 function() { | |
120 server.src = 'srpc_nrd_client.nexe'; | |
121 }); | |
122 } | |
123 | |
124 // The test run functions. | |
125 var SetTestResult = function(element_id, result) { | |
126 var element = document.getElementById(element_id); | |
127 element.className = result; | |
128 } | |
129 | |
130 var testExpectedPass = function(element, has_return, fp) { | |
131 var result = undefined; | |
132 try { | |
133 result = fp(); | |
134 if (has_return && (undefined == result)) { | |
135 SetTestResult(element, 'fail'); | |
136 } else { | |
137 SetTestResult(element, 'pass'); | |
138 --failing_count; | |
139 } | |
140 } catch (string) { | |
141 SetTestResult(element, 'fail'); | |
142 } | |
143 } | |
144 | |
145 var testExpectedFail = function(element, fp) { | |
146 var result = undefined; | |
147 try { | |
148 result = fp(); | |
149 SetTestResult(element, 'fail'); | |
150 } catch (string) { | |
151 if (undefined == result) { | |
152 SetTestResult(element, 'pass'); | |
153 --failing_count; | |
154 } else { | |
155 SetTestResult(element, 'fail'); | |
156 } | |
157 } | |
158 } | |
159 | |
160 var RunAllTests = function() { | |
161 var i; | |
162 var len = testQueue.length; | |
163 // All tests are considered failure until they have run successfully. | |
164 // This catches runs that end prematurely. | |
165 failing_count = len; | |
166 for (i = 0; i < len; ++i) { | |
167 var test_descr = testQueue[i]; | |
168 if ('pass' == test_descr[0]) { | |
169 testExpectedPass(test_descr[1], test_descr[2], test_descr[3]); | |
170 } else { | |
171 testExpectedFail(test_descr[1], test_descr[2]); | |
172 } | |
173 } | |
174 if (0 == failing_count) { | |
175 // Set the magic Selenium variable to signal success. | |
176 document.cookie = 'status=OK'; | |
177 } | |
178 } | |
179 | |
180 var EnqueueAndRunTests = function() { | |
181 // Plugin properties. | |
182 // Enqueue the tests. | |
183 PluginProperties(); | |
184 // Run them all. | |
185 RunAllTests(); | |
186 } | |
187 //]]> | |
188 </script> | |
189 </head> | |
190 <body onload="nacllib.waitForModulesAndRunTests();" | |
191 onunload="nacllib.cleanUp();" > | |
192 <h1> SRPC Plugin Properties Test </h1> | |
193 <table cellspacing=5 cellpadding=5 border=5 summary="Test status table"> | |
194 <tr> | |
195 <td> | |
196 </td> | |
197 <td> | |
198 <b> height </b> | |
199 </td> | |
200 <td> | |
201 <b> width </b> | |
202 </td> | |
203 <td> | |
204 <b> videoUpdateMode </b> | |
205 </td> | |
206 <td> | |
207 <b> src </b> | |
208 </td> | |
209 </tr> | |
210 <tr> | |
211 <td> | |
212 <b> Argument type tests </b> | |
213 </td> | |
214 <td valign=top> | |
215 <table summary="Height tests"> | |
216 <tr> | |
217 <td id="plugin_height_null" class="notrun"> | |
218 undefined | |
219 </td> | |
220 </tr> | |
221 <tr> | |
222 <td id="plugin_height_string" class="notrun"> | |
223 string | |
224 </td> | |
225 </tr> | |
226 <tr> | |
227 <td id="plugin_height_object" class="notrun"> | |
228 object | |
229 </td> | |
230 </tr> | |
231 </table> | |
232 </td> | |
233 <td valign=top> | |
234 <table summary="Width tests"> | |
235 <tr> | |
236 <td id="plugin_width_null" class="notrun"> | |
237 undefined | |
238 </td> | |
239 </tr> | |
240 <tr> | |
241 <td id="plugin_width_string" class="notrun"> | |
242 string | |
243 </td> | |
244 </tr> | |
245 <tr> | |
246 <td id="plugin_width_object" class="notrun"> | |
247 object | |
248 </td> | |
249 </tr> | |
250 </table> | |
251 </td> | |
252 <td valign=top> | |
253 <table summary="Video tests"> | |
254 <tr> | |
255 <td id="plugin_video_null" class="notrun"> | |
256 undefined | |
257 </td> | |
258 </tr> | |
259 <tr> | |
260 <td id="plugin_video_string" class="notrun"> | |
261 string | |
262 </td> | |
263 </tr> | |
264 <tr> | |
265 <td id="plugin_video_object" class="notrun"> | |
266 object | |
267 </td> | |
268 </tr> | |
269 </table> | |
270 </td> | |
271 <td valign=top> | |
272 <table summary="src tests"> | |
273 <tr> | |
274 <td id="plugin_src_null" class="notrun"> | |
275 undefined | |
276 </td> | |
277 </tr> | |
278 <tr> | |
279 <td id="plugin_src_integer" class="notrun"> | |
280 integer | |
281 </td> | |
282 </tr> | |
283 <tr> | |
284 <td id="plugin_src_object" class="notrun"> | |
285 object | |
286 </td> | |
287 </tr> | |
288 </table> | |
289 </td> | |
290 </tr> | |
291 | |
292 <tr> | |
293 <td> | |
294 <b> Expected behavior </b> | |
295 </td> | |
296 <td valign=top> | |
297 <table summary="Height conforming test"> | |
298 <tr> | |
299 <td id="plugin_height_conforming" class="notrun"> | |
300 integer | |
301 </td> | |
302 </tr> | |
303 </table> | |
304 </td> | |
305 <td valign=top> | |
306 <table summary="Width conforming test"> | |
307 <tr> | |
308 <td id="plugin_width_conforming" class="notrun"> | |
309 integer | |
310 </td> | |
311 </tr> | |
312 </table> | |
313 </td> | |
314 <td valign=top> | |
315 <table summary="Video conforming test"> | |
316 <tr> | |
317 <td id="plugin_video_conforming" class="notrun"> | |
318 integer | |
319 </td> | |
320 </tr> | |
321 </table> | |
322 </td> | |
323 <td valign=top> | |
324 <table summary="src conforming test"> | |
325 <tr> | |
326 <td id="plugin_src_conforming" class="notrun"> | |
327 string | |
328 </td> | |
329 </tr> | |
330 </table> | |
331 </td> | |
332 </tr> | |
333 </table> | |
334 | |
335 <table summary="The color codes used for identifying test outcomes"> | |
336 <tr> <td align="center"> <em> Legend </em> </td> </tr> | |
337 <tr> <td align="center" class="notrun"> Test not run </td> </tr> | |
338 <tr> <td align="center" class="pass"> Test passed </td> </tr> | |
339 <tr> <td align="center" class="fail"> Test failed </td> </tr> | |
340 </table> | |
341 <p> | |
342 <b> | |
343 NOTE: Some versions of some WebKit-based browsers do not correctly report | |
344 JavaScript exceptions raised by NPAPI plugins. This can cause some of | |
345 the above tests to spuriously report failure. | |
346 </b> | |
347 </p> | |
348 | |
349 <div id=status>NO-STATUS</div> | |
350 | |
351 <embed type="application/x-nacl" id="nacl_server" name="nacl_module" | |
352 width="0" height="0" src="srpc_test.nexe" /> | |
353 | |
354 <script type="text/javascript" src="nacl_js_lib.js"></script> | |
355 <script type="text/javascript"> | |
356 //<![CDATA[ | |
357 var nacllib = new NaclLib("nacl_module", "status", 500); | |
358 | |
359 nacllib.test = function() { | |
360 server = document.getElementById("nacl_server"); | |
361 EnqueueAndRunTests(); | |
362 if (0 == testQueue.length) { | |
363 return "No tests run."; | |
364 } else if (0 != failing_count) { | |
365 return "Tests failed."; | |
366 } else { | |
367 return ""; | |
368 } | |
369 } | |
370 //]]> | |
371 </script> | |
372 </body> | |
373 </html> | |
OLD | NEW |