OLD | NEW |
1 if (self.importScripts) { | 1 if (self.importScripts) { |
2 importScripts('../resources/fetch-test-helpers.js'); | 2 importScripts('../resources/fetch-test-helpers.js'); |
3 } | 3 } |
4 | 4 |
5 function consume(reader) { | 5 function consume(reader) { |
6 var chunks = []; | 6 var chunks = []; |
7 function rec(reader) { | 7 function rec(reader) { |
8 return reader.read().then(function(r) { | 8 return reader.read().then(function(r) { |
9 if (r.done) { | 9 if (r.done) { |
10 return chunks; | 10 return chunks; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 'Response.headers must not have Content-Type ' + | 105 'Response.headers must not have Content-Type ' + |
106 'for Blob with type = empty string (1)'); | 106 'for Blob with type = empty string (1)'); |
107 | 107 |
108 response = new Response(new Blob(['dummy'], {type: ''})); | 108 response = new Response(new Blob(['dummy'], {type: ''})); |
109 assert_equals(size(response.headers), 0, | 109 assert_equals(size(response.headers), 0, |
110 'Response.headers must not have Content-Type ' + | 110 'Response.headers must not have Content-Type ' + |
111 'for Blob with type = empty string (2)'); | 111 'for Blob with type = empty string (2)'); |
112 }, 'Response content type test'); | 112 }, 'Response content type test'); |
113 | 113 |
114 test(function() { | 114 test(function() { |
115 [0, 1, 100, 199, 600, 700].forEach(function(status) { | 115 [0, 1, 100, 101, 199, 600, 700].forEach(function(status) { |
116 assert_throws({name: 'RangeError'}, | 116 assert_throws({name: 'RangeError'}, |
117 function() { | 117 function() { |
118 new Response(new Blob(), {status: status}); | 118 new Response(new Blob(), {status: status}); |
119 }, | 119 }, |
120 'new Response with status = ' + status + | 120 'new Response with status = ' + status + |
121 ' should throw'); | 121 ' should throw'); |
122 }); | 122 }); |
123 | 123 |
| 124 [204, 205, 304].forEach(function(status) { |
| 125 assert_throws({name: 'TypeError'}, |
| 126 function() { |
| 127 new Response(new Blob(), {status: status}); |
| 128 }, |
| 129 'new Response with null body status = ' + status + |
| 130 ' and body is non-null should throw'); |
| 131 }); |
| 132 |
124 [300, 0, 304, 305, 306, 309, 500].forEach(function(status) { | 133 [300, 0, 304, 305, 306, 309, 500].forEach(function(status) { |
125 assert_throws({name: 'RangeError'}, | 134 assert_throws({name: 'RangeError'}, |
126 function() { | 135 function() { |
127 Response.redirect('https://www.example.com/test.html', | 136 Response.redirect('https://www.example.com/test.html', |
128 status); | 137 status); |
129 }, | 138 }, |
130 'Response.redirect() with invalid status = ' + status + | 139 'Response.redirect() with invalid status = ' + status + |
131 ' should throw'); | 140 ' should throw'); |
132 }); | 141 }); |
133 | 142 |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 test(function() { | 523 test(function() { |
515 ['http://ex\x0aample.com', | 524 ['http://ex\x0aample.com', |
516 'http://ex\x0dample.com'].forEach(function(url) { | 525 'http://ex\x0dample.com'].forEach(function(url) { |
517 assert_equals(Response.redirect(url).headers.get('Location'), | 526 assert_equals(Response.redirect(url).headers.get('Location'), |
518 'http://example.com/', | 527 'http://example.com/', |
519 'Location header value must not contain CR or LF'); | 528 'Location header value must not contain CR or LF'); |
520 }); | 529 }); |
521 }, 'Response.redirect() with URLs with CR or LF'); | 530 }, 'Response.redirect() with URLs with CR or LF'); |
522 | 531 |
523 done(); | 532 done(); |
OLD | NEW |