Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: LayoutTests/http/tests/fetch/script-tests/response.js

Issue 1258933002: Make the Response constructor throw when status is a null body status and body is non-null (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/modules/fetch/Response.cpp » ('j') | Source/modules/fetch/Response.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, 204, 205, 304, 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 [300, 0, 304, 305, 306, 309, 500].forEach(function(status) { 124 [300, 0, 304, 305, 306, 309, 500].forEach(function(status) {
125 assert_throws({name: 'RangeError'}, 125 assert_throws({name: 'RangeError'},
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 test(function() { 514 test(function() {
515 ['http://ex\x0aample.com', 515 ['http://ex\x0aample.com',
516 'http://ex\x0dample.com'].forEach(function(url) { 516 'http://ex\x0dample.com'].forEach(function(url) {
517 assert_equals(Response.redirect(url).headers.get('Location'), 517 assert_equals(Response.redirect(url).headers.get('Location'),
518 'http://example.com/', 518 'http://example.com/',
519 'Location header value must not contain CR or LF'); 519 'Location header value must not contain CR or LF');
520 }); 520 });
521 }, 'Response.redirect() with URLs with CR or LF'); 521 }, 'Response.redirect() with URLs with CR or LF');
522 522
523 done(); 523 done();
OLDNEW
« no previous file with comments | « no previous file | Source/modules/fetch/Response.cpp » ('j') | Source/modules/fetch/Response.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698