tor-browser

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

017.html (1807B)


      1 <!doctype html>
      2 <title>WebSockets: this, e.target, e.currentTarget, e.eventPhase</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.addEventListener('open', function(e) {
     14    var this_val = this;
     15    t.step(function() {
     16      // first a text frame, then a frame with reserved opcode 3
     17      // which should fail the connection
     18 
     19      // send '\\x81\\x04test\\x83\\x03LOL' in bytes
     20      ws.send(new Uint8Array([129, 4, 116, 101, 115, 116, 131, 3, 76, 79, 76]));
     21      assert_equals(this_val, ws);
     22      assert_equals(e.target, ws);
     23      assert_equals(e.currentTarget, ws);
     24      assert_equals(e.eventPhase, 2);
     25    });
     26  }, false);
     27  ws.addEventListener('message', function(e) {
     28    var this_val = this;
     29    t.step(function() {
     30      assert_equals(this_val, ws);
     31      assert_equals(e.target, ws);
     32      assert_equals(e.currentTarget, ws);
     33      assert_equals(e.eventPhase, 2);
     34    });
     35  }, false);
     36  ws.addEventListener('error', function(e) {
     37    var this_val = this;
     38    t.step(function() {
     39      assert_equals(this_val, ws);
     40      assert_equals(e.target, ws);
     41      assert_equals(e.currentTarget, ws);
     42      assert_equals(e.eventPhase, 2);
     43    });
     44  }, false);
     45  ws.addEventListener('close', function(e) {
     46    var this_val = this;
     47    t.step(function() {
     48      assert_equals(this_val, ws);
     49      assert_equals(e.target, ws);
     50      assert_equals(e.currentTarget, ws);
     51      assert_equals(e.eventPhase, 2);
     52      t.done();
     53    });
     54  }, false);
     55 });
     56 </script>