summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/xhr/open-send-during-abort.htm
blob: dc6f86bfc2c72e9ee3f9ac88f8859545b71ee2fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!doctype html>
<title>XMLHttpRequest: open() during abort()</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
async_test(t => {
  let result = [],
      client = new XMLHttpRequest(),
      expected = [1, 4, 1, 'hello']
  client.open("GET", "data:text/plain,")
  result.push(client.readyState)
  client.send()
  client.onreadystatechange = t.step_func(() => {
    client.onreadystatechange = null
    result.push(client.readyState)
    client.open("GET", "data:text/plain,hello")
    client.onload = t.step_func_done(() => {
      result.push(client.responseText)
      assert_array_equals(result, expected)
    })
    client.send()
  })
  client.abort()
  result.push(client.readyState)  // surprise! should not be "unsent" even though we called abort()
})
</script>