tor-browser

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

send-data-unexpected-tostring.htm (1929B)


      1 <!doctype html>
      2 <meta charset=utf-8>
      3 <title>XMLHttpRequest: passing objects that interfere with the XHR instance to send()</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol/li[4]" />
      7 <link rel="help" href="https://webidl.spec.whatwg.org/#es-union" data-tested-assertations="following::ol/li[16]" />
      8 
      9 
     10 <div id="log"></div>
     11 
     12 <script>
     13  var test1 = async_test('abort() called from data stringification')
     14  test1.step(function() {
     15    var client = new XMLHttpRequest()
     16    var objAbortsOnStringification = {toString:function(){
     17      client.abort();
     18    }}
     19    client.open('POST', 'resources/content.py')
     20    client.send(objAbortsOnStringification)
     21    assert_equals(client.readyState, 1)
     22    test1.done()
     23  });
     24 
     25  var test2 = async_test('open() called from data stringification')
     26  test2.step(function() {
     27    var client = new XMLHttpRequest()
     28    var objOpensOnStringification = {toString:function(){
     29      client.open('POST', 'resources/status.py?text=second_open_wins');
     30    }}
     31    client.onloadend = test2.step_func(function(){
     32      assert_equals(client.statusText, 'second_open_wins')
     33      test2.done()
     34    })
     35    client.open('POST', 'resources/status.py?text=first_open_wins')
     36    client.send(objOpensOnStringification)
     37  });
     38 
     39  var test3 = async_test('send() called from data stringification')
     40  test3.step(function() {
     41    var client = new XMLHttpRequest()
     42    var objSendsOnStringification = {toString:function(){
     43      client.send('bomb!');
     44    }}
     45    client.onload = test3.step_func(function(){
     46      assert_equals(client.responseText, 'bomb!')
     47      test3.done()
     48    })
     49    client.open('POST', 'resources/content.py')
     50    assert_throws_dom('InvalidStateError', function(){
     51      client.send(objSendsOnStringification)
     52    })
     53  });
     54 
     55 
     56 </script>