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 "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 }); | 186 }); |
187 } | 187 } |
188 | 188 |
189 | 189 |
190 void testImmediateCloseServer() { | 190 void testImmediateCloseServer() { |
191 createServer().then((server) { | 191 createServer().then((server) { |
192 server.listen((request) { | 192 server.listen((request) { |
193 WebSocketTransformer.upgrade(request) | 193 WebSocketTransformer.upgrade(request) |
194 .then((webSocket) { | 194 .then((webSocket) { |
195 webSocket.close(); | 195 webSocket.close(); |
196 webSocket.listen((_) { Expect.fail(); }, onDone: server.close); | 196 webSocket.listen( |
| 197 (_) { Expect.fail("Unexpected message"); }, |
| 198 onDone: server.close); |
197 }); | 199 }); |
198 }); | 200 }); |
199 | 201 |
200 createClient(server.port).then((webSocket) { | 202 createClient(server.port).then((webSocket) { |
201 webSocket.listen((_) { Expect.fail(); }, onDone: webSocket.close); | 203 webSocket.listen( |
| 204 (_) { Expect.fail("Unexpected message"); }, |
| 205 onDone: webSocket.close); |
202 }); | 206 }); |
203 }); | 207 }); |
204 } | 208 } |
205 | 209 |
206 | 210 |
207 void testImmediateCloseClient() { | 211 void testImmediateCloseClient() { |
208 createServer().then((server) { | 212 createServer().then((server) { |
209 server.listen((request) { | 213 server.listen((request) { |
210 WebSocketTransformer.upgrade(request) | 214 WebSocketTransformer.upgrade(request) |
211 .then((webSocket) { | 215 .then((webSocket) { |
212 webSocket.listen((_) { Expect.fail(); }, onDone: () { | 216 webSocket.listen( |
| 217 (_) { Expect.fail("Unexpected message"); }, |
| 218 onDone: () { |
213 server.close(); | 219 server.close(); |
214 webSocket.close(); | 220 webSocket.close(); |
215 }); | 221 }); |
216 }); | 222 }); |
217 }); | 223 }); |
218 | 224 |
219 createClient(server.port).then((webSocket) { | 225 createClient(server.port).then((webSocket) { |
220 webSocket.close(); | 226 webSocket.close(); |
221 webSocket.listen((_) { Expect.fail(); }, onDone: webSocket.close); | 227 webSocket.listen( |
| 228 (_) { Expect.fail("Unexpected message"); }, |
| 229 onDone: webSocket.close); |
222 }); | 230 }); |
223 }); | 231 }); |
224 } | 232 } |
225 | 233 |
226 | 234 |
227 void testNoUpgrade() { | 235 void testNoUpgrade() { |
228 createServer().then((server) { | 236 createServer().then((server) { |
229 // Create a server which always responds with NOT_FOUND. | 237 // Create a server which always responds with NOT_FOUND. |
230 server.listen((request) { | 238 server.listen((request) { |
231 request.response.statusCode = HttpStatus.NOT_FOUND; | 239 request.response.statusCode = HttpStatus.NOT_FOUND; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 SecureSocket.initialize(database: testPkcertDatabase.toNativePath(), | 411 SecureSocket.initialize(database: testPkcertDatabase.toNativePath(), |
404 password: "dartdart"); | 412 password: "dartdart"); |
405 } | 413 } |
406 | 414 |
407 | 415 |
408 main() { | 416 main() { |
409 new SecurityConfiguration(secure: false).runTests(); | 417 new SecurityConfiguration(secure: false).runTests(); |
410 initializeSSL(); | 418 initializeSSL(); |
411 new SecurityConfiguration(secure: true).runTests(); | 419 new SecurityConfiguration(secure: true).runTests(); |
412 } | 420 } |
OLD | NEW |