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

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

Issue 558793002: Adding ArrayBufferView as a constructor type to Response (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@response-work1
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/modules/serviceworkers/Response.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 755b3c96b5ac01d9cf8cf7e507bc1f6bb57e8e5a..a2d5270a945077b2d6b94e80a5a7c860153b9396 100644
--- a/LayoutTests/http/tests/serviceworker/resources/response-content-worker.js
+++ b/LayoutTests/http/tests/serviceworker/resources/response-content-worker.js
@@ -14,7 +14,7 @@ promise_test(function() {
}, 'Behavior of Response with string content.');
promise_test(function() {
- var intView = new Int32Array([0, 1, 2, 3, 4, 55, 6, 7, 8, 9]);
+ var intView = new Int32Array([0, 1, 2, 3, 4, 55, 6, 7, 8, 9]);
var buffer = intView.buffer;
var response = new Response(buffer);
@@ -28,4 +28,38 @@ promise_test(function() {
'Response body ArrayBuffer should match ArrayBuffer ' +
'it was constructed with.');
});
- }, 'Behavior of Response with arraybuffer content.');
+ }, 'Behavior of Response with ArrayBuffer content.');
+
+promise_test(function() {
+ var intView = new Int32Array([0, 1, 2, 3, 4, 55, 6, 7, 8, 9]);
+
+ var response = new Response(intView);
+ assert_false(response.headers.has('Content-Type'),
+ 'A Response constructed with ArrayBufferView ' +
+ 'should not have a content type.');
+ return response.body.asArrayBuffer()
+ .then(function(buffer) {
+ var resultIntView = new Int32Array(buffer);
+ assert_array_equals(
+ resultIntView, [0, 1, 2, 3, 4, 55, 6, 7, 8, 9],
+ 'Response body ArrayBuffer should match ArrayBufferView ' +
+ 'it was constructed with.');
+ });
+ }, 'Behavior of Response with ArrayBufferView content without a slice.');
+
+promise_test(function() {
+ var intView = new Int32Array([0, 1, 2, 3, 4, 55, 6, 7, 8, 9]);
+ var slice = intView.subarray(1, 4); // Should be [1, 2, 3]
+ var response = new Response(slice);
+ assert_false(response.headers.has('Content-Type'),
+ 'A Response constructed with ArrayBufferView ' +
+ 'should not have a content type.');
+ return response.body.asArrayBuffer()
+ .then(function(buffer) {
+ var resultIntView = new Int32Array(buffer);
+ assert_array_equals(
+ resultIntView, [1, 2, 3],
+ 'Response body ArrayBuffer should match ArrayBufferView ' +
+ 'slice it was constructed with.');
+ });
+ }, 'Behavior of Response with ArrayBufferView content with a slice.');
« no previous file with comments | « no previous file | Source/modules/serviceworkers/Response.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698