| OLD | NEW | 
|---|
| 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | 
| 2           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | 2           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | 
| 3 <html> | 3 <html> | 
| 4   <!-- Copyright 2009 Google Inc.  All rights reserved. --> | 4   <!-- Copyright 2009 Google Inc.  All rights reserved. --> | 
| 5   <head> | 5   <head> | 
| 6     <title> SRPC Socket Address API Test </title> | 6     <title> SRPC Socket Address API Test </title> | 
| 7     <META HTTP-EQUIV="Pragma" CONTENT="no-cache" /> | 7     <META HTTP-EQUIV="Pragma" CONTENT="no-cache" /> | 
| 8     <META HTTP-EQUIV="Expires" CONTENT="-1" /> | 8     <META HTTP-EQUIV="Expires" CONTENT="-1" /> | 
| 9     <style type="text/css"> | 9     <style type="text/css"> | 
| 10       td.notrun { background-color: skyblue } | 10       td.notrun { background-color: skyblue } | 
| 11       td.pass { background-color: lime } | 11       td.pass { background-color: lime } | 
| 12       td.fail { background-color: red } | 12       td.fail { background-color: red } | 
| 13     </style> | 13     </style> | 
| 14     <script type="application/x-javascript"> | 14     <script type="application/x-javascript"> | 
| 15       //<![CDATA[ | 15       //<![CDATA[ | 
| 16 var SetTestResult = function(element_id, result) { | 16 var SetTestResult = function(element_id, result) { | 
| 17   var element = document.getElementById(element_id); | 17   var element = document.getElementById(element_id); | 
| 18   element.className = result; | 18   element.className = result; | 
| 19 } | 19 } | 
| 20 | 20 | 
| 21 // The NaCl module.  Used to produce handles and for __shmFactory invocations. | 21 // The NaCl module.  Used to produce handles and for __shmFactory invocations. | 
| 22 var server; | 22 var server; | 
| 23 // The default socket address for the plugin. | 23 // The default socket address for the plugin. | 
| 24 var default_addr; | 24 var default_addr; | 
| 25 // The address string of the default socket address for the plugin. |  | 
| 26 var addr_str; |  | 
| 27 // The count of failing tests.  Set from the queue length, and decremented | 25 // The count of failing tests.  Set from the queue length, and decremented | 
| 28 // whenever a test passes. | 26 // whenever a test passes. | 
| 29 var failing_count; | 27 var failing_count; | 
| 30 | 28 | 
| 31 // The queue of small tests. | 29 // The queue of small tests. | 
| 32 var testQueue = [ ]; | 30 var testQueue = [ ]; | 
| 33 var appendTest = function(test_descr) { | 31 var appendTest = function(test_descr) { | 
| 34   testQueue[testQueue.length] = test_descr; | 32   testQueue[testQueue.length] = test_descr; | 
| 35 } | 33 } | 
| 36 | 34 | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 48   expectFail('default_too_many', | 46   expectFail('default_too_many', | 
| 49              function() { | 47              function() { | 
| 50                return server.__defaultSocketAddress('extra'); | 48                return server.__defaultSocketAddress('extra'); | 
| 51              }); | 49              }); | 
| 52   // Attempt to get the default socket address. | 50   // Attempt to get the default socket address. | 
| 53   expectPass('default_conforming', | 51   expectPass('default_conforming', | 
| 54              true, | 52              true, | 
| 55              function() { | 53              function() { | 
| 56                return server.__defaultSocketAddress(); | 54                return server.__defaultSocketAddress(); | 
| 57              }); | 55              }); | 
| 58   // Attempt to get the string form of the socket address. |  | 
| 59   expectPass('default_tostring', |  | 
| 60              true, |  | 
| 61              function() { |  | 
| 62                var sockaddr = server.__defaultSocketAddress(); |  | 
| 63                if (sockaddr.toString() == addr_str) { |  | 
| 64                  return true; |  | 
| 65                } |  | 
| 66                // undefined return will trigger failure. |  | 
| 67                return server.__defaultSocketAddress().toString(); |  | 
| 68              }); |  | 
| 69 } |  | 
| 70 |  | 
| 71 var SocketAddressFactory = function() { |  | 
| 72   // Test the creation of socket address objects. |  | 
| 73   // Attempt to create with the wrong number of parameters. |  | 
| 74   expectFail('factory_too_few', |  | 
| 75              function() { |  | 
| 76                return server.__socketAddressFactory(); |  | 
| 77              }); |  | 
| 78   expectFail('factory_too_many', |  | 
| 79              function() { |  | 
| 80                return server.__socketAddressFactory(addr_str, 'extra'); |  | 
| 81              }); |  | 
| 82   // Attempt to create a shared memory region with size of invalid type. |  | 
| 83   expectFail('factory_null', |  | 
| 84              function() { |  | 
| 85                return server.__socketAddressFactory(undefined); |  | 
| 86              }); |  | 
| 87   expectFail('factory_integer', |  | 
| 88              function() { |  | 
| 89                return server.__socketAddressFactory(1); |  | 
| 90              }); |  | 
| 91   expectFail('factory_object', |  | 
| 92              function() { |  | 
| 93                return server.__socketAddressFactory(new Array(10)); |  | 
| 94              }); |  | 
| 95   // Attempt to create a socket address with a valid string. |  | 
| 96   expectPass('factory_conforming', |  | 
| 97              true, |  | 
| 98              function() { |  | 
| 99                return server.__socketAddressFactory(addr_str); |  | 
| 100              }); |  | 
| 101   // Check that toString returns the string used to create the address. |  | 
| 102   expectPass('factory_tostring', |  | 
| 103              true, |  | 
| 104              function() { |  | 
| 105                var sockaddr = server.__socketAddressFactory(addr_str); |  | 
| 106                if (sockaddr.toString() == addr_str) { |  | 
| 107                  return true; |  | 
| 108                } |  | 
| 109                // undefined return will trigger failure. |  | 
| 110              }); |  | 
| 111 } | 56 } | 
| 112 | 57 | 
| 113 var Connect = function() { | 58 var Connect = function() { | 
| 114   // Test connection to socket address objects. | 59   // Test connection to socket address objects. | 
| 115   // Attempt to create with the wrong number of parameters. | 60   // Attempt to create with the wrong number of parameters. | 
| 116   expectFail('connect_too_many', | 61   expectFail('connect_too_many', | 
| 117              function() { | 62              function() { | 
| 118                return default_addr.connect('extra'); | 63                return default_addr.connect('extra'); | 
| 119              }); | 64              }); | 
| 120   expectFail('connect_invalid', |  | 
| 121              function() { |  | 
| 122                // There's a slight chance this is a valid address, I suppose. |  | 
| 123                var sockaddr = server.__socketAddressFactory('abcd'); |  | 
| 124                return sockaddr.connect(); |  | 
| 125              }); |  | 
| 126   // Attempt to connect to the default socket address. | 65   // Attempt to connect to the default socket address. | 
| 127   expectPass('connect_default', | 66   expectPass('connect_default', | 
| 128              true, | 67              true, | 
| 129              function() { | 68              function() { | 
| 130                return default_addr.connect(); | 69                return default_addr.connect(); | 
| 131              }); | 70              }); | 
| 132   // Attempt to connect to a created socket address. |  | 
| 133   expectPass('connect_sockaddr', |  | 
| 134              true, |  | 
| 135              function() { |  | 
| 136                var sockaddr = server.__socketAddressFactory(addr_str); |  | 
| 137                return sockaddr.connect(); |  | 
| 138              }); |  | 
| 139   // Attempt to connect to a socket address returned from a NaCl module. | 71   // Attempt to connect to a socket address returned from a NaCl module. | 
| 140   expectPass('connect_nacl', | 72   expectPass('connect_nacl', | 
| 141              true, | 73              true, | 
| 142              function() { | 74              function() { | 
| 143                var sockaddr = server.start_server(); | 75                var sockaddr = server.start_server(); | 
| 144                return sockaddr.connect(); | 76                return sockaddr.connect(); | 
| 145              }); | 77              }); | 
| 146 } | 78 } | 
| 147 | 79 | 
| 148 // The test run functions. | 80 // The test run functions. | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 195     document.cookie = 'status=OK'; | 127     document.cookie = 'status=OK'; | 
| 196   } | 128   } | 
| 197 } | 129 } | 
| 198 | 130 | 
| 199 var EnqueueAndRunTests = function() { | 131 var EnqueueAndRunTests = function() { | 
| 200   // Setup -- abort entire test if this fails. | 132   // Setup -- abort entire test if this fails. | 
| 201   try { | 133   try { | 
| 202     // If these fail at the beginning, all the tests will abort. | 134     // If these fail at the beginning, all the tests will abort. | 
| 203     // Otherwise more specific tests are done on them. | 135     // Otherwise more specific tests are done on them. | 
| 204     default_addr = server.__defaultSocketAddress(); | 136     default_addr = server.__defaultSocketAddress(); | 
| 205     addr_str = default_addr.toString(); |  | 
| 206   } catch (string) { | 137   } catch (string) { | 
| 207     window.alert('Socket address test setup failed.'); | 138     window.alert('Socket address test setup failed.'); | 
| 208     return; | 139     return; | 
| 209   } | 140   } | 
| 210   // Enqueue the tests. | 141   // Enqueue the tests. | 
| 211   DefaultSocketAddress(); | 142   DefaultSocketAddress(); | 
| 212   SocketAddressFactory(); |  | 
| 213   Connect(); | 143   Connect(); | 
| 214   // Run them all. | 144   // Run them all. | 
| 215   RunAllTests(); | 145   RunAllTests(); | 
| 216 } | 146 } | 
| 217       //]]> | 147       //]]> | 
| 218     </script> | 148     </script> | 
| 219   </head> | 149   </head> | 
| 220   <body onload="nacllib.waitForModulesAndRunTests();" | 150   <body onload="nacllib.waitForModulesAndRunTests();" | 
| 221         onunload="nacllib.cleanUp();" > | 151         onunload="nacllib.cleanUp();" > | 
| 222     <h1> SRPC Socket Address API Test </h1> | 152     <h1> SRPC Socket Address API Test </h1> | 
| 223     <table cellspacing=5 cellpadding=5 border=5 summary="Test status table"> | 153     <table cellspacing=5 cellpadding=5 border=5 summary="Test status table"> | 
| 224       <tr> | 154       <tr> | 
| 225         <td> | 155         <td> | 
| 226         </td> | 156         </td> | 
| 227         <td> | 157         <td> | 
| 228           <b> __defaultSocketAddress tests </b> | 158           <b> __defaultSocketAddress tests </b> | 
| 229         </td> | 159         </td> | 
| 230         <td> | 160         <td> | 
| 231           <b> __socketAddressFactory tests </b> |  | 
| 232         </td> |  | 
| 233         <td> |  | 
| 234           <b> connect tests </b> | 161           <b> connect tests </b> | 
| 235         </td> | 162         </td> | 
| 236       </tr> | 163       </tr> | 
| 237       <tr> | 164       <tr> | 
| 238         <td> | 165         <td> | 
| 239           <b> Argument count tests </b> | 166           <b> Argument count tests </b> | 
| 240         </td> | 167         </td> | 
| 241         <td> | 168         <td> | 
| 242           <table summary="Default argument count test"> | 169           <table summary="Default argument count test"> | 
| 243             <tr> | 170             <tr> | 
| 244               <td id="default_too_many" class="notrun"> | 171               <td id="default_too_many" class="notrun"> | 
| 245                 argc: too many | 172                 argc: too many | 
| 246               </td> | 173               </td> | 
| 247             </tr> | 174             </tr> | 
| 248           </table> | 175           </table> | 
| 249         </td> | 176         </td> | 
| 250         <td valign=top> |  | 
| 251           <table summary="Factory argument count tests"> |  | 
| 252             <tr> |  | 
| 253               <td id="factory_too_few" class="notrun"> |  | 
| 254                 argc: too few |  | 
| 255               </td> |  | 
| 256             </tr> |  | 
| 257             <tr> |  | 
| 258               <td id="factory_too_many" class="notrun"> |  | 
| 259                 argc: too many |  | 
| 260               </td> |  | 
| 261             </tr> |  | 
| 262           </table> |  | 
| 263         </td> |  | 
| 264         <td> | 177         <td> | 
| 265           <table summary="Connect argument count test"> | 178           <table summary="Connect argument count test"> | 
| 266             <tr> | 179             <tr> | 
| 267               <td id="connect_too_many" class="notrun"> | 180               <td id="connect_too_many" class="notrun"> | 
| 268                 argc: too many | 181                 argc: too many | 
| 269               </td> | 182               </td> | 
| 270             </tr> | 183             </tr> | 
| 271           </table> | 184           </table> | 
| 272         </td> | 185         </td> | 
| 273       </tr> | 186       </tr> | 
| 274       <tr> |  | 
| 275         <td> |  | 
| 276           <b> Argument type tests </b> |  | 
| 277         </td> |  | 
| 278         <td valign=top> |  | 
| 279         </td> |  | 
| 280         <td valign=top> |  | 
| 281           <table summary="Factory argument type tests"> |  | 
| 282             <tr> |  | 
| 283               <td id="factory_null" class="notrun"> |  | 
| 284                 arg[0]: (address) undefined |  | 
| 285               </td> |  | 
| 286             </tr> |  | 
| 287             <tr> |  | 
| 288               <td id="factory_integer" class="notrun"> |  | 
| 289                 arg[0]: (address) integer |  | 
| 290               </td> |  | 
| 291             </tr> |  | 
| 292             <tr> |  | 
| 293               <td id="factory_object" class="notrun"> |  | 
| 294                 arg[0]: (address) object |  | 
| 295               </td> |  | 
| 296             </tr> |  | 
| 297           </table> |  | 
| 298         </td> |  | 
| 299         <td valign=top> |  | 
| 300         </td> |  | 
| 301       </tr> |  | 
| 302 |  | 
| 303       <tr> |  | 
| 304         <td> |  | 
| 305           <b> Semantic error tests </b> |  | 
| 306         </td> |  | 
| 307         <td> |  | 
| 308         </td> |  | 
| 309         <td> |  | 
| 310         </td> |  | 
| 311         <td> |  | 
| 312           <table summary="Invalid connection test"> |  | 
| 313             <tr> |  | 
| 314               <td id="connect_invalid" class="notrun"> |  | 
| 315                 to bad socket address |  | 
| 316               </td> |  | 
| 317             </tr> |  | 
| 318           </table> |  | 
| 319         </td> |  | 
| 320       </tr> |  | 
| 321 | 187 | 
| 322       <tr> | 188       <tr> | 
| 323         <td> | 189         <td> | 
| 324           <b> Expected behavior </b> | 190           <b> Expected behavior </b> | 
| 325         </td> | 191         </td> | 
| 326         <td valign=top> | 192         <td valign=top> | 
| 327           <table summary="Default behavior tests"> | 193           <table summary="Default behavior tests"> | 
| 328             <tr> | 194             <tr> | 
| 329               <td id="default_conforming" class="notrun"> | 195               <td id="default_conforming" class="notrun"> | 
| 330                 conforming invocation | 196                 conforming invocation | 
| 331               </td> | 197               </td> | 
| 332             </tr> | 198             </tr> | 
| 333             <tr> |  | 
| 334               <td id="default_tostring" class="notrun"> |  | 
| 335                 toString |  | 
| 336               </td> |  | 
| 337             </tr> |  | 
| 338           </table> | 199           </table> | 
| 339         </td> | 200         </td> | 
| 340         <td valign=top> | 201         <td valign=top> | 
| 341           <table summary="Factory behavior tests"> |  | 
| 342             <tr> |  | 
| 343               <td id="factory_conforming" class="notrun"> |  | 
| 344                 conforming invocation |  | 
| 345               </td> |  | 
| 346             </tr> |  | 
| 347             <tr> |  | 
| 348               <td id="factory_tostring" class="notrun"> |  | 
| 349                 toString |  | 
| 350               </td> |  | 
| 351             </tr> |  | 
| 352           </table> |  | 
| 353         </td> |  | 
| 354         <td valign=top> |  | 
| 355           <table summary="Connection behavior tests"> | 202           <table summary="Connection behavior tests"> | 
| 356             <tr> | 203             <tr> | 
| 357               <td id="connect_default" class="notrun"> | 204               <td id="connect_default" class="notrun"> | 
| 358                 to default | 205                 to default | 
| 359               </td> | 206               </td> | 
| 360             </tr> | 207             </tr> | 
| 361             <tr> | 208             <tr> | 
| 362               <td id="connect_sockaddr" class="notrun"> |  | 
| 363                 to JavaScript-created address |  | 
| 364               </td> |  | 
| 365             </tr> |  | 
| 366             <tr> |  | 
| 367               <td id="connect_nacl" class="notrun"> | 209               <td id="connect_nacl" class="notrun"> | 
| 368                 to address returned from NaCl | 210                 to address returned from NaCl | 
| 369               </td> | 211               </td> | 
| 370             </tr> | 212             </tr> | 
| 371           </table> | 213           </table> | 
| 372         </td> | 214         </td> | 
| 373       </tr> | 215       </tr> | 
| 374     </table> | 216     </table> | 
| 375 | 217 | 
| 376     <table summary="The color codes used for identifying test outcomes"> | 218     <table summary="The color codes used for identifying test outcomes"> | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
| 405         } else if (0 != failing_count) { | 247         } else if (0 != failing_count) { | 
| 406           return "Tests failed."; | 248           return "Tests failed."; | 
| 407         } else { | 249         } else { | 
| 408           return ""; | 250           return ""; | 
| 409         } | 251         } | 
| 410       } | 252       } | 
| 411       //]]> | 253       //]]> | 
| 412     </script> | 254     </script> | 
| 413   </body> | 255   </body> | 
| 414 </html> | 256 </html> | 
| OLD | NEW | 
|---|