Skip to content

Commit

Permalink
a few more WebSocket tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 10, 2016
1 parent 3614b9d commit e9b5615
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Mojo/WebSocket.pm
Expand Up @@ -228,7 +228,7 @@ Perform WebSocket handshake client-side.
=head2 parse_frame
my $frame = parse_frame \$bytes, $max_websocket_size;
my $frame = parse_frame \$bytes, $limit;
Parse WebSocket frame.
Expand Down
11 changes: 11 additions & 0 deletions t/mojo/websocket_frames.t
Expand Up @@ -222,6 +222,17 @@ is $frame->[4], 2, 'binary frame';
is $frame->[5], '', 'no payload';
isnt(build_frame(0, 1, 0, 0, 0, 2, ''), $bytes, 'frames are not equal');

# Size limit
$bytes = build_frame(0, 1, 0, 0, 0, WS_BINARY, 'works');
is $bytes, "\x82\x05\x77\x6f\x72\x6b\x73", 'right frame';
$frame = parse_frame \($dummy = $bytes), 4;
ok $frame, 'true';
ok !ref $frame, 'not a reference';

# Incomplete frame
is parse_frame(\($dummy = "\x82\x05\x77\x6f\x72\x6b"), 262144), undef,
'incomplete frame';

# Compressed binary message roundtrip
my $ws = Mojo::Transaction::WebSocket->new({compressed => 1});
$bytes = $ws->build_message({binary => 'just works'});
Expand Down

0 comments on commit e9b5615

Please sign in to comment.