1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <!-- Copyright 2009 Google Inc. All rights reserved. -->
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
}
12 <script type=
"application/x-javascript">
14 // The count of failing tests. Set from the queue length, and decremented
15 // whenever a test passes.
18 // The queue of small tests.
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',
37 server.height = undefined;
39 expectFail('plugin_height_string',
41 server.height = 'string';
43 expectFail('plugin_height_object',
45 server.height = new Array(10);
47 // Attempt to set height to a valid type.
48 expectFail('plugin_height_conforming',
53 // Attempt to set width with invalid type.
54 expectFail('plugin_width_null',
56 server.width = undefined;
58 expectFail('plugin_width_string',
60 server.width = 'string';
62 expectFail('plugin_width_object',
64 server.width = new Array(10);
66 // Attempt to set width to a valid type.
67 expectPass('plugin_width_conforming',
72 // Attempt to set videoUpdateMode with invalid type.
73 expectFail('plugin_video_null',
75 server.videoUpdateMode = undefined;
77 expectFail('plugin_video_string',
79 server.videoUpdateMode = 'string';
81 expectFail('plugin_video_object',
83 server.videoUpdateMode = new Array(10);
85 // Attempt to set src to a valid type.
86 expectPass('plugin_video_conforming',
89 server.videoUpdateMode = 1;
91 // Attempt to set src with invalid type.
92 expectFail('plugin_src_null',
94 server.src = undefined;
96 expectFail('plugin_src_integer',
100 expectFail('plugin_src_object',
102 server.src = new Array(10);
104 // Attempt to set src to a valid type.
105 expectPass('plugin_src_conforming',
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;
122 if (has_return && (undefined == result)) {
123 SetTestResult(element, 'fail');
125 SetTestResult(element, 'pass');
129 SetTestResult(element, 'fail');
133 var testExpectedFail = function(element, fp) {
134 var result = undefined;
137 SetTestResult(element, 'fail');
139 if (undefined == result) {
140 SetTestResult(element, 'pass');
143 SetTestResult(element, 'fail');
148 var RunAllTests = function() {
150 var len = testQueue.length;
151 // All tests are considered failure until they have run successfully.
152 // This catches runs that end prematurely.
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]);
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.
175 // Before running tests we need to ensure the Native Client modules are loaded.
178 var RunTestsAfterLoad = function() {
179 // Initialize the selenium magic to failure here.
180 if (server.__moduleReady) {
181 clearTimeout(startupTimeout);
182 EnqueueAndRunTests();
184 if (server.__moduleReady == undefined) {
185 alert('The Native Client plugin was unable to load');
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.
202 <body onload=
"Init();">
203 <h1> SRPC Plugin Properties Test
</h1>
204 <table cellspacing=
5 cellpadding=
5 border=
5>
215 <b> videoUpdateMode
</b>
223 <b> Argument type tests
</b>
228 <td id=
"plugin_height_null" class=
"notrun">
233 <td id=
"plugin_height_string" class=
"notrun">
238 <td id=
"plugin_height_object" class=
"notrun">
247 <td id=
"plugin_width_null" class=
"notrun">
252 <td id=
"plugin_width_string" class=
"notrun">
257 <td id=
"plugin_width_object" class=
"notrun">
266 <td id=
"plugin_video_null" class=
"notrun">
271 <td id=
"plugin_video_string" class=
"notrun">
276 <td id=
"plugin_video_object" class=
"notrun">
285 <td id=
"plugin_src_null" class=
"notrun">
290 <td id=
"plugin_src_integer" class=
"notrun">
295 <td id=
"plugin_src_object" class=
"notrun">
305 <b> Expected behavior
</b>
310 <td id=
"plugin_height_conforming" class=
"notrun">
319 <td id=
"plugin_width_conforming" class=
"notrun">
328 <td id=
"plugin_video_conforming" class=
"notrun">
337 <td id=
"plugin_src_conforming" class=
"notrun">
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>
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.
359 <embed type=
"application/x-nacl-srpc" id=
"nacl_server"
360 width=
"0" height=
"0" src=
"srpc_nrd_server.nexe" />