Sync web-platform-tests up to revision a5b95cb31914507088a4eda16f7674bbc6f3313f
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / fetch / api / response / response-trailer.html
1 <!doctype html>
2 <title>trailer() test</title>
3 <script src=/resources/testharness.js></script>
4 <script src=/resources/testharnessreport.js></script>
5 <div id=log></div>
6 <!--  based on /XMLHttpRequest/getresponseheader-chunked-trailer.htm  -->
7 <script>
8 promise_test(() => {
9   return fetch("/XMLHttpRequest/resources/chunked.py").then(res => {
10     assert_equals(res.headers.get("Trailer"), "X-Test-Me")
11     assert_equals(res.headers.get("X-Test-Me"), null)
12     assert_equals(res.headers.get("Content-Type"), "text/plain")
13     return Promise.all([
14       res.text().then(text => {
15         assert_equals(text, "First chunk\r\nSecond chunk\r\nYet another (third) chunk\r\nYet another (fourth) chunk\r\n")
16       }),
17       res.trailer.then(trailers => {
18         assert_equals(trailers.get("X-Test-Me"), "Trailer header value")
19         assert_throws(new TypeError, () => trailers.append("Immutable-My-Ass", "Hi!"))
20       })
21     ])
22   })
23 })
24 </script>