Chromium Code Reviews| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 webSocket.close(); | 179 webSocket.close(); |
| 180 }); | 180 }); |
| 181 | 181 |
| 182 createClient(server.port).then((webSocket) { | 182 createClient(server.port).then((webSocket) { |
| 183 webSocket.listen((_) { }, onDone: webSocket.close); | 183 webSocket.listen((_) { }, onDone: webSocket.close); |
| 184 }); | 184 }); |
| 185 }); | 185 }); |
| 186 } | 186 } |
| 187 | 187 |
| 188 | 188 |
| 189 void testImmediateCloseServer() { | |
| 190 createServer().then((server) { | |
| 191 server.listen((request) { | |
| 192 WebSocketTransformer.upgrade(request) | |
| 193 .then((webSocket) { | |
| 194 webSocket.close(); | |
| 195 webSocket.listen((_) { }, onDone: server.close); | |
|
Søren Gjesse
2013/03/05 11:21:37
Expect no messages.
Anders Johnsen
2013/03/05 11:30:58
Done.
| |
| 196 }); | |
| 197 }); | |
| 198 | |
| 199 createClient(server.port).then((webSocket) { | |
| 200 webSocket.listen((_) { }, onDone: webSocket.close); | |
|
Søren Gjesse
2013/03/05 11:21:37
Ditto.
Anders Johnsen
2013/03/05 11:30:58
Done.
| |
| 201 }); | |
| 202 }); | |
| 203 } | |
| 204 | |
| 205 | |
| 206 void testImmediateCloseClient() { | |
| 207 createServer().then((server) { | |
| 208 server.listen((request) { | |
| 209 WebSocketTransformer.upgrade(request) | |
| 210 .then((webSocket) { | |
| 211 webSocket.listen((_) { }, onDone: () { | |
|
Søren Gjesse
2013/03/05 11:21:37
Ditto.
Anders Johnsen
2013/03/05 11:30:58
Done.
| |
| 212 server.close(); | |
| 213 webSocket.close(); | |
| 214 }); | |
| 215 }); | |
| 216 }); | |
| 217 | |
| 218 createClient(server.port).then((webSocket) { | |
| 219 webSocket.close(); | |
| 220 webSocket.listen((_) { }, onDone: webSocket.close); | |
|
Søren Gjesse
2013/03/05 11:21:37
Ditto.
Anders Johnsen
2013/03/05 11:30:58
Done.
| |
| 221 }); | |
| 222 }); | |
| 223 } | |
| 224 | |
| 225 | |
| 189 void testNoUpgrade() { | 226 void testNoUpgrade() { |
| 190 createServer().then((server) { | 227 createServer().then((server) { |
| 191 // Create a server which always responds with NOT_FOUND. | 228 // Create a server which always responds with NOT_FOUND. |
| 192 server.listen((request) { | 229 server.listen((request) { |
| 193 request.response.statusCode = HttpStatus.NOT_FOUND; | 230 request.response.statusCode = HttpStatus.NOT_FOUND; |
| 194 request.response.close(); | 231 request.response.close(); |
| 195 }); | 232 }); |
| 196 | 233 |
| 197 createClient(server.port).catchError((error) { | 234 createClient(server.port).catchError((error) { |
| 198 server.close(); | 235 server.close(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 testRequestResponseServerCloses(2, null, null); | 379 testRequestResponseServerCloses(2, null, null); |
| 343 testRequestResponseServerCloses(2, 3001, null); | 380 testRequestResponseServerCloses(2, 3001, null); |
| 344 testRequestResponseServerCloses(2, 3002, "Got tired"); | 381 testRequestResponseServerCloses(2, 3002, "Got tired"); |
| 345 testMessageLength(125); | 382 testMessageLength(125); |
| 346 testMessageLength(126); | 383 testMessageLength(126); |
| 347 testMessageLength(127); | 384 testMessageLength(127); |
| 348 testMessageLength(65535); | 385 testMessageLength(65535); |
| 349 testMessageLength(65536); | 386 testMessageLength(65536); |
| 350 testDoubleCloseClient(); | 387 testDoubleCloseClient(); |
| 351 testDoubleCloseServer(); | 388 testDoubleCloseServer(); |
| 389 testImmediateCloseServer(); | |
| 390 testImmediateCloseClient(); | |
| 352 testNoUpgrade(); | 391 testNoUpgrade(); |
| 353 testUsePOST(); | 392 testUsePOST(); |
| 354 testConnections(10, 3002, "Got tired"); | 393 testConnections(10, 3002, "Got tired"); |
| 355 testIndivitualUpgrade(5); | 394 testIndivitualUpgrade(5); |
| 356 } | 395 } |
| 357 } | 396 } |
| 358 | 397 |
| 359 | 398 |
| 360 void initializeSSL() { | 399 void initializeSSL() { |
| 361 var testPkcertDatabase = | 400 var testPkcertDatabase = |
| 362 new Path(new Options().script).directoryPath.append("pkcert/"); | 401 new Path(new Options().script).directoryPath.append("pkcert/"); |
| 363 SecureSocket.initialize(database: testPkcertDatabase.toNativePath(), | 402 SecureSocket.initialize(database: testPkcertDatabase.toNativePath(), |
| 364 password: "dartdart"); | 403 password: "dartdart"); |
| 365 } | 404 } |
| 366 | 405 |
| 367 | 406 |
| 368 main() { | 407 main() { |
| 369 new SecurityConfiguration(secure: false).runTests(); | 408 new SecurityConfiguration(secure: false).runTests(); |
| 370 initializeSSL(); | 409 initializeSSL(); |
| 371 new SecurityConfiguration(secure: true).runTests(); | 410 new SecurityConfiguration(secure: true).runTests(); |
| 372 } | 411 } |
| OLD | NEW |