Files
sdk/tests/html/websocket_test.dart
T
jacobr@google.com 97075e2d22 WebSocket security checks changed a bit with the latest Dartium roll so the test failed with the following error when protocol 'chat' was used. failed: Error during WebSocket handshake: Sec-WebSocket-Protocol mismatch"
I've switched the WebSocket constructor test to pass in the protocol 'chat' so that coverage for passing in a protocol is not impacted.

Note that chrome dev channel reports the same error when a JS WebSocket is created with protocol 'chat' given the same scenario.

BUG=
R=blois@google.com

Review URL: https://codereview.chromium.org//23061008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26496 260f80e4-7a28-3924-810f-c04153c831b5
2013-08-22 00:33:54 +00:00

43 lines
1.0 KiB
Dart

library WebSocketTest;
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_individual_config.dart';
import 'dart:html';
main() {
useHtmlIndividualConfiguration();
group('supported', () {
test('supported', () {
expect(WebSocket.supported, true);
});
});
group('websocket', () {
var isWebSocket = predicate((x) => x is WebSocket, 'is a WebSocket');
var expectation = WebSocket.supported ? returnsNormally : throws;
test('constructorTest', () {
expect(() {
var socket = new WebSocket('ws://localhost/ws', 'chat');
expect(socket, isNotNull);
expect(socket, isWebSocket);
}, expectation);
});
if (WebSocket.supported) {
test('echo', () {
var socket = new WebSocket('ws://${window.location.host}/ws');
socket.onOpen.first.then((_) {
socket.send('hello!');
});
return socket.onMessage.first.then((MessageEvent e) {
expect(e.data, 'hello!');
});
});
}
});
}