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 importScripts('/streams/resources/rs-utils.js'); | 3 importScripts('/streams/resources/rs-utils.js'); |
4 } | 4 } |
5 | 5 |
6 function decode(chunks) { | 6 function decode(chunks) { |
7 var decoder = new TextDecoder(); | 7 var decoder = new TextDecoder(); |
8 var result = ''; | 8 var result = ''; |
9 for (var chunk of chunks) { | 9 for (var chunk of chunks) { |
10 result += decoder.decode(chunk, {stream: true}); | 10 result += decoder.decode(chunk, {stream: true}); |
11 } | 11 } |
12 result += decoder.decode(new Uint8Array(0)); | 12 result += decoder.decode(new Uint8Array(0)); |
13 return result; | 13 return result; |
14 } | 14 } |
15 | 15 |
16 test(function() { | 16 test(function() { |
17 var response = new Response(); | 17 var response = new Response(); |
18 assert_equals(response.type, 'default', | 18 assert_equals(response.type, 'default', |
19 'Default Response.type should be \'default\''); | 19 'Default Response.type should be \'default\''); |
20 assert_equals(response.url, '', 'Response.url should be the empty string'); | 20 assert_equals(response.url, '', 'Response.url should be the empty string'); |
21 assert_equals(response.status, 200, | 21 assert_equals(response.status, 200, |
22 'Default Response.status should be 200'); | 22 'Default Response.status should be 200'); |
23 assert_true(response.ok, 'Default Response.ok must be true'); | 23 assert_true(response.ok, 'Default Response.ok must be true'); |
24 assert_equals(response.statusText, 'OK', | 24 assert_equals(response.statusText, 'OK', |
25 'Default Response.statusText should be \'OK\''); | 25 'Default Response.statusText should be \'OK\''); |
26 assert_equals(size(response.headers), 0, | 26 assert_equals(size(response.headers), 0, |
27 'Default Response should not have any header.'); | 27 'Default Response should not have any header.'); |
28 if (self.internals) { | |
29 var urlList = self.internals.getInternalResponseURLList(response); | |
30 assert_equals(size(urlList), 0, | |
falken
2016/12/09 01:54:15
I think size() is defined in fetch-test-helpers.js
horo
2016/12/09 05:04:11
Done.
| |
31 'The URL list of Default Response should not be empty.'); | |
falken
2016/12/09 01:54:15
The description seems to contradict the assertion.
horo
2016/12/09 05:04:11
Done.
| |
32 } | |
28 | 33 |
29 response.status = 394; | 34 response.status = 394; |
30 response.statusText = 'Sesame Street'; | 35 response.statusText = 'Sesame Street'; |
31 assert_equals(response.status, 200, 'Response.status should be readonly'); | 36 assert_equals(response.status, 200, 'Response.status should be readonly'); |
32 assert_true(response.ok, 'Response.ok must remain unchanged ' + | 37 assert_true(response.ok, 'Response.ok must remain unchanged ' + |
33 'when Response.status is attempted ' + | 38 'when Response.status is attempted ' + |
34 'unsuccessfully to change'); | 39 'unsuccessfully to change'); |
35 assert_equals(response.statusText, 'OK', | 40 assert_equals(response.statusText, 'OK', |
36 'Response.statusText should be readonly'); | 41 'Response.statusText should be readonly'); |
37 response.ok = false; | 42 response.ok = false; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 'X-Fetch-Test of Response.headers should match'); | 96 'X-Fetch-Test of Response.headers should match'); |
92 }); | 97 }); |
93 }, 'Response constructor test'); | 98 }, 'Response constructor test'); |
94 | 99 |
95 test(function() { | 100 test(function() { |
96 var response = new Response(new Blob(['dummy'], {type: 'audio/wav'})); | 101 var response = new Response(new Blob(['dummy'], {type: 'audio/wav'})); |
97 assert_equals(size(response.headers), 1, | 102 assert_equals(size(response.headers), 1, |
98 'Response.headers should have Content-Type'); | 103 'Response.headers should have Content-Type'); |
99 assert_equals(response.headers.get('Content-Type'), 'audio/wav', | 104 assert_equals(response.headers.get('Content-Type'), 'audio/wav', |
100 'Content-Type of Response.headers should be set'); | 105 'Content-Type of Response.headers should be set'); |
106 if (self.internals) { | |
107 var urlList = self.internals.getInternalResponseURLList(response); | |
108 assert_equals(size(urlList), 0, | |
109 'The URL list of generated Response should not be empty.'); | |
falken
2016/12/09 01:54:15
ditto with above
horo
2016/12/09 05:04:11
Done.
| |
110 } | |
101 | 111 |
102 response = new Response(new Blob(['dummy'], {type: 'audio/wav'}), | 112 response = new Response(new Blob(['dummy'], {type: 'audio/wav'}), |
103 { | 113 { |
104 headers: { | 114 headers: { |
105 'Content-Type': 'text/html; charset=UTF-8' | 115 'Content-Type': 'text/html; charset=UTF-8' |
106 } | 116 } |
107 }); | 117 }); |
108 assert_equals(size(response.headers), 1, | 118 assert_equals(size(response.headers), 1, |
109 'Response.headers should have Content-Type'); | 119 'Response.headers should have Content-Type'); |
110 assert_equals(response.headers.get('Content-Type'), | 120 assert_equals(response.headers.get('Content-Type'), |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 test(function() { | 459 test(function() { |
450 ['http://ex\x0aample.com', | 460 ['http://ex\x0aample.com', |
451 'http://ex\x0dample.com'].forEach(function(url) { | 461 'http://ex\x0dample.com'].forEach(function(url) { |
452 assert_equals(Response.redirect(url).headers.get('Location'), | 462 assert_equals(Response.redirect(url).headers.get('Location'), |
453 'http://example.com/', | 463 'http://example.com/', |
454 'Location header value must not contain CR or LF'); | 464 'Location header value must not contain CR or LF'); |
455 }); | 465 }); |
456 }, 'Response.redirect() with URLs with CR or LF'); | 466 }, 'Response.redirect() with URLs with CR or LF'); |
457 | 467 |
458 done(); | 468 done(); |
OLD | NEW |