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

Side by Side Diff: LayoutTests/http/tests/serviceworker/resources/response-content-worker.js

Issue 701683005: Service Workers/Fetch: Fix Response constructor for empty/null (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 importScripts('worker-testharness.js'); 1 importScripts('worker-testharness.js');
2 importScripts('../../resources/testharness-helpers.js'); 2 importScripts('../../resources/testharness-helpers.js');
3 3
4 promise_test(function() { 4 promise_test(function() {
5 var response = new Response('test string'); 5 var response = new Response('test string');
6 assert_equals( 6 assert_equals(
7 response.headers.get('Content-Type'), 7 response.headers.get('Content-Type'),
8 'text/plain;charset=UTF-8', 8 'text/plain;charset=UTF-8',
9 'A Response constructed with a string should have a Content-Type.'); 9 'A Response constructed with a string should have a Content-Type.');
10 return response.text() 10 return response.text()
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 response3 = response.clone(); 94 response3 = response.clone();
95 assert_true(response3.bodyUsed, 95 assert_true(response3.bodyUsed,
96 'bodyUsed should be true in clone of consumed response.'); 96 'bodyUsed should be true in clone of consumed response.');
97 return response2.text(); 97 return response2.text();
98 }) 98 })
99 .then(function(text) { 99 .then(function(text) {
100 assert_equals(text, 'test string', 100 assert_equals(text, 'test string',
101 'Response clone response body text should match.'); 101 'Response clone response body text should match.');
102 }); 102 });
103 }, 'Behavior of bodyUsed in Response and clone behavior.'); 103 }, 'Behavior of bodyUsed in Response and clone behavior.');
104
105 promise_test(function() {
106 var response = new Response(null);
107 assert_equals(
108 response.headers.get('Content-Type'),
109 'text/plain;charset=UTF-8',
110 'A Response constructed with a value coerced to string should have a ' +
111 'text Content-Type.');
112 return response.text()
113 .then(function(text) {
114 assert_equals(text, 'null',
115 'A null value passed to Response constructor should ' +
116 'be coerced to the string "null".');
117 });
118 }, 'Behavior of Response passed null for body.');
119
120 promise_test(function() {
121 var response = new Response();
122 assert_equals(
123 response.headers.get('Content-Type'),
124 null,
125 'A Response constructed with no body should have no Content-Type.');
126 return response.text()
127 .then(function(text) {
128 assert_equals(text, '',
129 'Response with no body accessed as text should ' +
130 'resolve to the empty string.');
131 });
132 }, 'Behavior of Response with no body.');
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/fetch-event-test-worker.js ('k') | Source/modules/serviceworkers/Response.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698