OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <script src = "/resources/testharness.js"></script> |
| 3 <script src = "/resources/testharnessreport.js"></script> |
| 4 <script> |
| 5 promise_test(() => { |
| 6 return fetch('/resources/echo-headers.php') |
| 7 .then(response => { |
| 8 return response.text(); |
| 9 }).then(body => { |
| 10 const lines = body.split('\n'); |
| 11 for (let line of lines) { |
| 12 if (line.length == 0) { |
| 13 continue; |
| 14 } |
| 15 const parts = line.split(': ', 2); |
| 16 if (parts.length < 2) { |
| 17 assert_unreached('Invalid line in response: ' + line); |
| 18 } |
| 19 if (parts[0] == 'HTTP_USER_AGENT') { |
| 20 assert_true(parts[1].length > 0); |
| 21 return; |
| 22 } |
| 23 } |
| 24 assert_unreached('User-Agent header not found'); |
| 25 }); |
| 26 }, 'fetch() should send a non-empty User-Agent header'); |
| 27 |
| 28 promise_test(() => { |
| 29 return fetch('/resources/echo-headers.php', {headers: {'user-agent': 'foobar'}
}) |
| 30 .then(response => { |
| 31 return response.text(); |
| 32 }).then(body => { |
| 33 const lines = body.split('\n'); |
| 34 for (let line of lines) { |
| 35 if (line.length == 0) { |
| 36 continue; |
| 37 } |
| 38 const parts = line.split(': ', 2); |
| 39 if (parts.length < 2) { |
| 40 assert_unreached('Invalid line in response: ' + line); |
| 41 } |
| 42 if (parts[0] == 'HTTP_USER_AGENT') { |
| 43 assert_equals(parts[1], 'foobar'); |
| 44 return; |
| 45 } |
| 46 } |
| 47 assert_unreached('User-Agent header not found'); |
| 48 }); |
| 49 }, 'fetch() should send an author provided User-Agent header'); |
| 50 </script> |
OLD | NEW |