| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // | 4 // |
| 5 // VMOptions= | 5 // VMOptions= |
| 6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
| 7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
| 8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
| 9 | 9 |
| 10 import "dart:async"; | 10 import "dart:async"; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } else if (event is CloseEvent) { | 157 } else if (event is CloseEvent) { |
| 158 server.close(); | 158 server.close(); |
| 159 } | 159 } |
| 160 }); | 160 }); |
| 161 webSocket.send(originalMessage); | 161 webSocket.send(originalMessage); |
| 162 }); | 162 }); |
| 163 }); | 163 }); |
| 164 } | 164 } |
| 165 | 165 |
| 166 | 166 |
| 167 void testDoubleCloseClient() { |
| 168 createServer().then((server) { |
| 169 server.transform(new WebSocketTransformer()).listen((webSocket) { |
| 170 webSocket.listen((event) { |
| 171 if (event is CloseEvent) { |
| 172 webSocket.close(); |
| 173 } |
| 174 }); |
| 175 }); |
| 176 |
| 177 createClient(server.port).then((webSocket) { |
| 178 webSocket.listen((event) { |
| 179 if (event is CloseEvent) { |
| 180 webSocket.close(); |
| 181 } |
| 182 }); |
| 183 webSocket.close(); |
| 184 }); |
| 185 }); |
| 186 } |
| 187 |
| 188 |
| 189 void testDoubleCloseServer() { |
| 190 createServer().then((server) { |
| 191 server.transform(new WebSocketTransformer()).listen((webSocket) { |
| 192 webSocket.listen((event) { |
| 193 if (event is CloseEvent) { |
| 194 webSocket.close(); |
| 195 } |
| 196 }); |
| 197 webSocket.close(); |
| 198 }); |
| 199 |
| 200 createClient(server.port).then((webSocket) { |
| 201 webSocket.listen((event) { |
| 202 if (event is CloseEvent) { |
| 203 webSocket.close(); |
| 204 } |
| 205 }); |
| 206 }); |
| 207 }); |
| 208 } |
| 209 |
| 210 |
| 167 void testNoUpgrade() { | 211 void testNoUpgrade() { |
| 168 createServer().then((server) { | 212 createServer().then((server) { |
| 169 // Create a server which always responds with NOT_FOUND. | 213 // Create a server which always responds with NOT_FOUND. |
| 170 server.listen((request) { | 214 server.listen((request) { |
| 171 request.response.statusCode = HttpStatus.NOT_FOUND; | 215 request.response.statusCode = HttpStatus.NOT_FOUND; |
| 172 request.response.close(); | 216 request.response.close(); |
| 173 }); | 217 }); |
| 174 | 218 |
| 175 createClient(server.port).catchError((error) { | 219 createClient(server.port).catchError((error) { |
| 176 server.close(); | 220 server.close(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 testRequestResponseClientCloses(2, 3001, null); | 316 testRequestResponseClientCloses(2, 3001, null); |
| 273 testRequestResponseClientCloses(2, 3002, "Got tired"); | 317 testRequestResponseClientCloses(2, 3002, "Got tired"); |
| 274 testRequestResponseServerCloses(2, null, null); | 318 testRequestResponseServerCloses(2, null, null); |
| 275 testRequestResponseServerCloses(2, 3001, null); | 319 testRequestResponseServerCloses(2, 3001, null); |
| 276 testRequestResponseServerCloses(2, 3002, "Got tired"); | 320 testRequestResponseServerCloses(2, 3002, "Got tired"); |
| 277 testMessageLength(125); | 321 testMessageLength(125); |
| 278 testMessageLength(126); | 322 testMessageLength(126); |
| 279 testMessageLength(127); | 323 testMessageLength(127); |
| 280 testMessageLength(65535); | 324 testMessageLength(65535); |
| 281 testMessageLength(65536); | 325 testMessageLength(65536); |
| 326 testDoubleCloseClient(); |
| 327 testDoubleCloseServer(); |
| 282 testNoUpgrade(); | 328 testNoUpgrade(); |
| 283 testUsePOST(); | 329 testUsePOST(); |
| 284 testW3CInterface(10, 3002, "Got tired"); | 330 testW3CInterface(10, 3002, "Got tired"); |
| 285 } | 331 } |
| 286 } | 332 } |
| 287 | 333 |
| 288 | 334 |
| 289 void initializeSSL() { | 335 void initializeSSL() { |
| 290 var testPkcertDatabase = | 336 var testPkcertDatabase = |
| 291 new Path(new Options().script).directoryPath.append("pkcert/"); | 337 new Path(new Options().script).directoryPath.append("pkcert/"); |
| 292 SecureSocket.initialize(database: testPkcertDatabase.toNativePath(), | 338 SecureSocket.initialize(database: testPkcertDatabase.toNativePath(), |
| 293 password: "dartdart"); | 339 password: "dartdart"); |
| 294 } | 340 } |
| 295 | 341 |
| 296 | 342 |
| 297 main() { | 343 main() { |
| 298 new SecurityConfiguration(secure: false).runTests(); | 344 new SecurityConfiguration(secure: false).runTests(); |
| 299 initializeSSL(); | 345 initializeSSL(); |
| 300 new SecurityConfiguration(secure: true).runTests(); | 346 new SecurityConfiguration(secure: true).runTests(); |
| 301 } | 347 } |
| OLD | NEW |