send-entity-body-get-head-async.htm (1479B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>XMLHttpRequest: send() - non-empty data argument and GET/HEAD - async, no upload events should fire</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::OL[1]/LI[3] following::OL[1]/LI[7] following::OL[1]/LI[8]" /> 8 9 </head> 10 <body> 11 <div id="log"></div> 12 <script> 13 function request(method) { 14 var test = async_test( document.title + " (" + method + ")") 15 var events=[] 16 var logEvt = function (e) { 17 events.push(e.type) 18 } 19 var client = new XMLHttpRequest() 20 client.open(method, "resources/content.py") 21 client.upload.addEventListener('progress', logEvt) 22 client.upload.addEventListener('loadend', logEvt) 23 client.upload.addEventListener('loadstart', logEvt) 24 client.addEventListener('loadend', function(){ 25 test.step(function(){ 26 assert_equals(client.getResponseHeader("x-request-content-length"), "NO") 27 assert_equals(client.getResponseHeader("x-request-method"), method) 28 assert_equals(client.responseText, "") 29 assert_array_equals(events, []) 30 test.done() 31 }) 32 }) 33 client.send("TEST") 34 } 35 request("GET") 36 request("HEAD") 37 </script> 38 </body> 39 </html>