tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

extended-payload-length.html (2614B)


      1 <!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.sub.js></script>
      7 <meta name="variant" content="?default">
      8 <meta name="variant" content="?wss">
      9 <meta name="variant" content="?wpt_flags=h2">
     10 <div id=log></div>
     11 <script>
     12 async_test(function(t){
     13    var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
     14    var datasize = 125;
     15    var data = null;
     16    ws.onopen = t.step_func(function(e) {
     17        data = new Array(datasize + 1).join('a');
     18        ws.send(data);
     19    });
     20    ws.onmessage = t.step_func(function(e) {
     21        assert_equals(e.data, data);
     22        t.done();
     23    });
     24    ws.onclose = t.unreached_func('close event should not fire');
     25 }, "Application data is 125 byte which means any 'Extended payload length' field isn't used at all.");
     26 
     27 async_test(function(t){
     28    var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
     29    var datasize = 126;
     30    var data = null;
     31    ws.onopen = t.step_func(function(e) {
     32        data = new Array(datasize + 1).join('a');
     33        ws.send(data);
     34    });
     35    ws.onmessage = t.step_func(function(e) {
     36        assert_equals(e.data, data);
     37        t.done();
     38    });
     39    ws.onclose = t.unreached_func('close event should not fire');
     40 }, "Application data is 126 byte which starts to use the 16 bit 'Extended payload length' field.");
     41 
     42 async_test(function(t){
     43    var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
     44    var datasize = 0xFFFF;
     45    var data = null;
     46    ws.onopen = t.step_func(function(e) {
     47        data = new Array(datasize + 1).join('a');
     48        ws.send(data);
     49    });
     50    ws.onmessage = t.step_func(function(e) {
     51        assert_equals(e.data, data);
     52        t.done();
     53    });
     54    ws.onclose = t.unreached_func('close event should not fire');
     55 }, "Application data is 0xFFFF byte which means the upper bound of the 16 bit 'Extended payload length' field.");
     56 
     57 async_test(function(t){
     58    var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo');
     59    var datasize = 0xFFFF + 1;
     60    var data = null;
     61    ws.onopen = t.step_func(function(e) {
     62        data = new Array(datasize + 1).join('a');
     63        ws.send(data);
     64    });
     65    ws.onmessage = t.step_func(function(e) {
     66        assert_equals(e.data, data);
     67        t.done();
     68    });
     69    ws.onclose = t.unreached_func('close event should not fire');
     70 }, "Application data is (0xFFFF + 1) byte which starts to use the 64 bit 'Extended payload length' field");
     71 
     72 </script>