tor-browser

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

open-during-abort-processing.htm (1874B)


      1 <!doctype html>
      2 <title>XMLHttpRequest: open() during abort processing - abort() called from onloadstart</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <div id="log"></div>
      6 <script>
      7 async_test(t => {
      8  let client = new XMLHttpRequest(),
      9      test_state = 1,
     10      log = [],
     11      expected = [
     12        "onloadstart readyState before abort() 1",
     13        "onreadystatechange readyState before open() 4",
     14        "onreadystatechange readyState after open() 1",
     15        "onloadstart readyState 1",
     16        "client.onabort 1",
     17        "readyState after abort() 1",
     18        "client.onload 4"
     19      ]
     20 
     21  client.onreadystatechange = t.step_func(() => {
     22    if(test_state === 2){
     23      test_state = 3
     24      log.push('onreadystatechange readyState before open() ' + client.readyState)
     25      client.open("GET", "resources/content.py")
     26      log.push('onreadystatechange readyState after open() ' + client.readyState)
     27      client.send(null)
     28    }
     29  })
     30 
     31  client.onloadstart = t.step_func(() => {
     32    if(test_state === 1){
     33      test_state = 2
     34      log.push('onloadstart readyState before abort() ' + client.readyState)
     35      client.abort()
     36      log.push('readyState after abort() ' + client.readyState)
     37    }else{
     38      log.push('onloadstart readyState ' + client.readyState)
     39    }
     40  })
     41 
     42  client.upload.onabort = t.step_func(() => {
     43    log.push('upload.onabort ' + client.readyState)
     44  })
     45 
     46  client.onabort = t.step_func(() => {
     47    log.push('client.onabort ' + client.readyState)
     48  })
     49 
     50  client.upload.onloadend = t.step_func(() => {
     51    log.push('upload.onloadend ' + client.readyState)
     52  })
     53 
     54  client.onload = t.step_func_done(() => {
     55    log.push('client.onload ' + client.readyState)
     56    assert_array_equals(log, expected)
     57  })
     58 
     59  client.open("POST", "resources/content.py")
     60  client.send('abcd')
     61 })
     62 </script>