header-user-agent-async.htm (816B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Test that async requests (both OPTIONS preflight and regular) are sent with the User-Agent header</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/common/get-host-info.sub.js"></script> 8 </head> 9 <body> 10 <script type="text/javascript"> 11 async_test((test) => { 12 let xhr = new XMLHttpRequest; 13 xhr.open("GET", get_host_info().HTTP_REMOTE_ORIGIN + "/xhr/resources/header-user-agent.py"); 14 xhr.setRequestHeader("x-test", "foobar"); 15 16 xhr.onerror = test.unreached_func("Unexpected error"); 17 18 xhr.onload = test.step_func_done(() => { 19 assert_equals(xhr.responseText, "PASS"); 20 }); 21 22 xhr.send(); 23 }, "Async request has User-Agent header"); 24 </script> 25 </body> 26 </html>