tor-browser

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

004.html (1175B)


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