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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 webSocket.close(); | 180 webSocket.close(); |
181 }); | 181 }); |
182 | 182 |
183 createClient(server.port).then((webSocket) { | 183 createClient(server.port).then((webSocket) { |
184 webSocket.close(); | 184 webSocket.close(); |
185 }); | 185 }); |
186 }); | 186 }); |
187 } | 187 } |
188 | 188 |
189 | 189 |
| 190 void testCancelThenClose() { |
| 191 createServer().then((server) { |
| 192 server.transform(new WebSocketTransformer()).listen((webSocket) { |
| 193 webSocket.listen(null).cancel(); |
| 194 webSocket.close(); |
| 195 server.close(); |
| 196 }); |
| 197 |
| 198 createClient(server.port).then((webSocket) { |
| 199 webSocket.close(); |
| 200 }); |
| 201 }); |
| 202 } |
| 203 |
| 204 void testCloseThenCancel() { |
| 205 createServer().then((server) { |
| 206 server.transform(new WebSocketTransformer()).listen((webSocket) { |
| 207 var subscription = webSocket.listen(null); |
| 208 webSocket.close(); |
| 209 subscription.cancel(); |
| 210 server.close(); |
| 211 }); |
| 212 |
| 213 createClient(server.port).then((webSocket) { |
| 214 webSocket.close(); |
| 215 }); |
| 216 }); |
| 217 } |
| 218 |
| 219 |
190 void testListenAfterClose() { | 220 void testListenAfterClose() { |
191 createServer().then((server) { | 221 createServer().then((server) { |
192 server.transform(new WebSocketTransformer()).listen((webSocket) { | 222 server.transform(new WebSocketTransformer()).listen((webSocket) { |
193 server.close(); | 223 server.close(); |
194 webSocket.close(); | 224 webSocket.close(); |
195 Expect.throws(() => webSocket.drain()); | 225 Expect.throws(() => webSocket.drain()); |
196 }); | 226 }); |
197 | 227 |
198 createClient(server.port).then((webSocket) { | 228 createClient(server.port).then((webSocket) { |
199 webSocket.close(); | 229 webSocket.close(); |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 testRequestResponseClientCloses(2, 3002, "Got tired", 3); | 566 testRequestResponseClientCloses(2, 3002, "Got tired", 3); |
537 testRequestResponseServerCloses(2, null, null); | 567 testRequestResponseServerCloses(2, null, null); |
538 testRequestResponseServerCloses(2, 3001, null); | 568 testRequestResponseServerCloses(2, 3001, null); |
539 testRequestResponseServerCloses(2, 3002, "Got tired"); | 569 testRequestResponseServerCloses(2, 3002, "Got tired"); |
540 testMessageLength(125); | 570 testMessageLength(125); |
541 testMessageLength(126); | 571 testMessageLength(126); |
542 testMessageLength(127); | 572 testMessageLength(127); |
543 testMessageLength(65535); | 573 testMessageLength(65535); |
544 testMessageLength(65536); | 574 testMessageLength(65536); |
545 testCloseNoListen(); | 575 testCloseNoListen(); |
| 576 testCancelThenClose(); |
| 577 testCloseThenCancel(); |
546 testListenAfterClose(); | 578 testListenAfterClose(); |
547 testDoubleCloseClient(); | 579 testDoubleCloseClient(); |
548 testDoubleCloseServer(); | 580 testDoubleCloseServer(); |
549 testImmediateCloseServer(); | 581 testImmediateCloseServer(); |
550 testImmediateCloseClient(); | 582 testImmediateCloseClient(); |
551 testNoUpgrade(); | 583 testNoUpgrade(); |
552 testUsePOST(); | 584 testUsePOST(); |
553 testConnections(10, 3002, "Got tired"); | 585 testConnections(10, 3002, "Got tired"); |
554 testIndividualUpgrade(5); | 586 testIndividualUpgrade(5); |
555 testFromUpgradedSocket(); | 587 testFromUpgradedSocket(); |
556 testAdditionalHeaders(); | 588 testAdditionalHeaders(); |
557 testBasicAuthentication(); | 589 testBasicAuthentication(); |
558 } | 590 } |
559 } | 591 } |
560 | 592 |
561 | 593 |
562 void initializeSSL() { | 594 void initializeSSL() { |
563 var testPkcertDatabase = Platform.script.resolve('pkcert').toFilePath(); | 595 var testPkcertDatabase = Platform.script.resolve('pkcert').toFilePath(); |
564 SecureSocket.initialize(database: testPkcertDatabase, | 596 SecureSocket.initialize(database: testPkcertDatabase, |
565 password: "dartdart"); | 597 password: "dartdart"); |
566 } | 598 } |
567 | 599 |
568 | 600 |
569 main() { | 601 main() { |
570 new SecurityConfiguration(secure: false).runTests(); | 602 new SecurityConfiguration(secure: false).runTests(); |
571 initializeSSL(); | 603 initializeSSL(); |
572 new SecurityConfiguration(secure: true).runTests(); | 604 new SecurityConfiguration(secure: true).runTests(); |
573 } | 605 } |
OLD | NEW |