tor-browser

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

003.html (1331B)


      1 <!doctype html>
      2 <title>WebSockets: sending HttpOnly cookies in ws request</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&wpt_flags=https">
      8 <meta name="variant" content="?wpt_flags=h2">
      9 <div id=log></div>
     10 <script>
     11 setup({explicit_done:true})
     12 var cookie_id = ((new Date())-0) + '.' + Math.random();
     13 
     14 var t = async_test(function(t) {
     15  var iframe = document.createElement('iframe');
     16  t.add_cleanup(function() {
     17    // remove cookie
     18    iframe.src = 'support/set-cookie.py?'+encodeURIComponent('ws_test_'+cookie_id+'=; Path=/; HttpOnly; Expires=Sun, 06 Nov 1994 08:49:37 GMT');
     19    iframe.onload = done;
     20  });
     21  iframe.src = 'support/set-cookie.py?'+encodeURIComponent('ws_test_'+cookie_id+'=test; Path=/; HttpOnly');
     22  iframe.onload = t.step_func(function() {
     23    var ws = new WebSocket(SCHEME_DOMAIN_PORT+'/echo-cookie');
     24    ws.onmessage = t.step_func(function(e) {
     25      ws.close();
     26      ws.onclose = null;
     27      assert_regexp_match(e.data, new RegExp('ws_test_'+cookie_id+'=test'));
     28      t.done();
     29    });
     30    ws.onerror = ws.onclose = t.step_func(function(e) {assert_unreached(e.type)});
     31  });
     32  document.body.appendChild(iframe);
     33 });
     34 </script>