tor-browser

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

014.html (1145B)


      1 <!doctype html>
      2 <title>WebSockets: serialize establish a connection</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 <div id=log></div>
     10 <script>
     11 
     12 async_test(function(t) {
     13  var ws = [];
     14  var events = 0;
     15  var prevDate;
     16  var date;
     17  for (var i = 0; i < 2; ++i) {
     18    ws[i] = new WebSocket(SCHEME_DOMAIN_PORT+'/handshake_sleep_2');
     19    ws[i].id = i;
     20    ws[i].onopen = t.step_func(function(e) {
     21      events++;
     22      date = new Date();
     23      if (prevDate) {
     24        assert_greater_than(date - prevDate, 1000);
     25      }
     26      prevDate = date;
     27      this.onopen = t.step_func(function() {assert_unreached()});
     28    }.bind(ws[i]))
     29    ws[i].onclose = t.step_func(function() {
     30      events++;
     31      if (events == 4) {
     32        t.done();
     33      }
     34      this.onclose = t.step_func(function() {assert_unreached()});
     35    }.bind(ws[i]));
     36    ws[i].onerror = ws[i].onmessage = t.step_func(function() {assert_unreached()});
     37  }
     38 });
     39 </script>