blob: 1d0e7d27013c2dbf0af6cac8140f67233bc261bd [file] [log] [blame]
Hitoshi Uchida7a59bac2014-06-11 22:36:551<!doctype html>
2<title>WebSockets : Boundary-value tests for the 'Extended payload length' field in RFC6455 section5.2 'Base Framing Protocol'</title>
3<meta name=timeout content=long>
4<script src=/resources/testharness.js></script>
5<script src=/resources/testharnessreport.js></script>
6<script src=../constants.js?pipe=sub></script>
7<div id=log></div>
8<script>
9async_test(function(t){
10 var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
11 var datasize = 125;
12 var data = null;
13 ws.onopen = t.step_func(function(e) {
14 data = new Array(datasize + 1).join('a');
15 ws.send(data);
16 });
17 ws.onmessage = t.step_func(function(e) {
18 assert_equals(e.data, data);
19 t.done();
20 });
21}, "Application data is 125 byte which means any 'Extended payload length' field isn't used at all.", {timeout:20000});
22
23async_test(function(t){
24 var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
25 var datasize = 126;
26 var data = null;
27 ws.onopen = t.step_func(function(e) {
28 data = new Array(datasize + 1).join('a');
29 ws.send(data);
30 });
31 ws.onmessage = t.step_func(function(e) {
32 assert_equals(e.data, data);
33 t.done();
34 });
35}, "Application data is 126 byte which starts to use the 16 bit 'Extended payload length' field.", {timeout:20000});
36
37async_test(function(t){
38 var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
39 var datasize = 0xFFFF;
40 var data = null;
41 ws.onopen = t.step_func(function(e) {
42 data = new Array(datasize + 1).join('a');
43 ws.send(data);
44 });
45 ws.onmessage = t.step_func(function(e) {
46 assert_equals(e.data, data);
47 t.done();
48 });
49}, "Application data is 0xFFFF byte which means the upper bound of the 16 bit 'Extended payload length' field.", {timeout:20000});
50
51async_test(function(t){
52 var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
53 var datasize = 0xFFFF + 1;
54 var data = null;
55 ws.onopen = t.step_func(function(e) {
56 data = new Array(datasize + 1).join('a');
57 ws.send(data);
58 });
59 ws.onmessage = t.step_func(function(e) {
60 assert_equals(e.data, data);
61 t.done();
62 });
63}, "Application data is (0xFFFF + 1) byte which starts to use the 64 bit 'Extended payload length' field", {timeout:20000});
64
65</script>