tor-browser

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

015.html (1219B)


      1 <!doctype html>
      2 <title>WebSockets: instanceof on events</title>
      3 <script src=/resources/testharness.js></script>
      4 <script src=/resources/testharnessreport.js></script>
      5 <script src=../../../constants.sub.js></script>
      6 <meta name="variant" content="?default">
      7 <meta name="variant" content="?wss">
      8 <meta name="variant" content="?wpt_flags=h2">
      9 <div id=log></div>
     10 <script>
     11 async_test(function(t) {
     12  var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo_raw');
     13  ws.onopen = t.step_func(function(e) {
     14    assert_true(e instanceof Event);
     15    // first a text frame, then a frame with reserved opcode 3
     16    // which should fail the connection
     17 
     18    // send '\\x81\\x04test\\x83\\x03LOL' in bytes
     19    ws.send(new Uint8Array([129, 4, 116, 101, 115, 116, 131, 3, 76, 79, 76]));
     20  });
     21  ws.onmessage = t.step_func(function(e) {
     22    assert_true(e instanceof Event);
     23    assert_true(e instanceof MessageEvent);
     24    assert_equals(ws.readyState, ws.OPEN);
     25  })
     26  ws.onerror = t.step_func(function(e) {
     27    assert_true(e instanceof Event);
     28    assert_equals(ws.readyState, ws.CLOSED);
     29  })
     30  ws.onclose = t.step_func(function(e) {
     31    assert_true(e instanceof Event);
     32    assert_true(e instanceof CloseEvent);
     33    t.done();
     34  })
     35 });
     36 </script>