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

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

Issue 556563002: Adding ArrayBuffer support to ServiceWorker Response and tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Style fixes 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
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
new file mode 100644
index 0000000000000000000000000000000000000000..00d76d5acd2a7158f5a1d97f082055c4b8f8cc61
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/resources/response-content-worker.js
@@ -0,0 +1,31 @@
+importScripts('worker-test-harness.js');
+
+promise_test(function() {
+ var response = new Response('test string');
horo 2014/09/09 01:38:50 +2 indent http://www.chromium.org/blink/servicewor
dmurph 2014/09/09 19:06:02 Done.
+ assert_equals(
+ response.headers.get('Content-Type'),
+ 'text/plain;charset=UTF-8',
+ 'A Response constructed with a string should have a Content-Type.');
+ return response.body.asText()
+ .then(function(text) {
+ assert_equals(text, 'test string',
horo 2014/09/09 01:38:50 +2 indent return response.body.asText() .th
dmurph 2014/09/09 19:06:02 Done.
+ 'Response body text should match the string on construction.');
+ });
+}, 'Behavior of Response with string content.');
+
+promise_test(function() {
+ var intView = new Int32Array([0, 1, 2, 3, 4, 55, 6, 7, 8, 9]);
horo 2014/09/09 01:38:50 ditto
dmurph 2014/09/09 19:06:02 Done.
+ var buffer = intView.buffer;
+
+ var response = new Response(buffer);
+ assert_false(response.headers.has('Content-Type'),
+ 'A Response constructed with ArrayBuffer should not have a content type.');
+ return response.body.asArrayBuffer()
+ .then(function(buffer) {
+ var resultIntView = new Int32Array(buffer);
horo 2014/09/09 01:38:50 ditto
dmurph 2014/09/09 19:06:02 Done.
+ assert_array_equals(
+ resultIntView, [0, 1, 2, 3, 4, 55, 6, 7, 8, 9],
+ 'Response body ArrayBuffer should match ArrayBuffer ' +
+ 'it was constructed with.');
+ });
+}, 'Behavior of Response with arraybuffer content.');
« no previous file with comments | « no previous file | LayoutTests/http/tests/serviceworker/response-content.html » ('j') | Source/modules/serviceworkers/Response.idl » ('J')

Powered by Google App Engine
This is Rietveld 408576698