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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/serviceworker/resources/response-content-worker.js
diff --git a/LayoutTests/http/tests/serviceworker/resources/response-content-worker.js b/LayoutTests/http/tests/serviceworker/resources/response-content-worker.js
index e133b7f57570d83cd347073f5d919ece45f51ca2..c97b0c82f9ead7e14fa57e4b9c3c75eabed6de41 100644
--- a/LayoutTests/http/tests/serviceworker/resources/response-content-worker.js
+++ b/LayoutTests/http/tests/serviceworker/resources/response-content-worker.js
@@ -101,3 +101,32 @@ promise_test(function() {
'Response clone response body text should match.');
});
}, 'Behavior of bodyUsed in Response and clone behavior.');
+
+promise_test(function() {
+ var response = new Response(null);
+ assert_equals(
+ response.headers.get('Content-Type'),
+ 'text/plain;charset=UTF-8',
+ 'A Response constructed with a value coerced to string should have a ' +
+ 'text Content-Type.');
+ return response.text()
+ .then(function(text) {
+ assert_equals(text, 'null',
+ 'A null value passed to Response constructor should ' +
+ 'be coerced to the string "null".');
+ });
+ }, 'Behavior of Response passed null for body.');
+
+promise_test(function() {
+ var response = new Response();
+ assert_equals(
+ response.headers.get('Content-Type'),
+ null,
+ 'A Response constructed with no body should have no Content-Type.');
+ return response.text()
+ .then(function(text) {
+ assert_equals(text, '',
+ 'Response with no body accessed as text should ' +
+ 'resolve to the empty string.');
+ });
+ }, 'Behavior of Response with no body.');
« 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