| <!doctype html> |
| <title>trailer() test</title> |
| <script src=/resources/testharness.js></script> |
| <script src=/resources/testharnessreport.js></script> |
| <div id=log></div> |
| <!-- based on /XMLHttpRequest/getresponseheader-chunked-trailer.htm --> |
| <script> |
| promise_test(() => { |
| return fetch("/XMLHttpRequest/resources/chunked.py").then(res => { |
| assert_equals(res.headers.get("Trailer"), "X-Test-Me") |
| assert_equals(res.headers.get("X-Test-Me"), null) |
| assert_equals(res.headers.get("Content-Type"), "text/plain") |
| return Promise.all([ |
| res.text().then(text => { |
| assert_equals(text, "First chunk\r\nSecond chunk\r\nYet another (third) chunk\r\nYet another (fourth) chunk\r\n") |
| }), |
| res.trailer.then(trailers => { |
| assert_equals(trailers.get("X-Test-Me"), "Trailer header value") |
| assert_throws(new TypeError, () => trailers.append("Immutable-My-Ass", "Hi!")) |
| }) |
| ]) |
| }) |
| }) |
| </script> |