OLD | NEW |
1 importScripts('worker-test-harness.js'); | 1 importScripts('worker-test-harness.js'); |
2 | 2 |
3 promise_test(function() { | 3 promise_test(function() { |
4 var response = new Response('test string'); | 4 var response = new Response('test string'); |
5 assert_equals( | 5 assert_equals( |
6 response.headers.get('Content-Type'), | 6 response.headers.get('Content-Type'), |
7 'text/plain;charset=UTF-8', | 7 'text/plain;charset=UTF-8', |
8 'A Response constructed with a string should have a Content-Type.'); | 8 'A Response constructed with a string should have a Content-Type.'); |
9 return response.body.asText() | 9 return response.text() |
10 .then(function(text) { | 10 .then(function(text) { |
11 assert_equals(text, 'test string', | 11 assert_equals(text, 'test string', |
12 'Response body text should match the string on construction.'); | 12 'Response body text should match the string on construction.'); |
13 }); | 13 }); |
14 }, 'Behavior of Response with string content.'); | 14 }, 'Behavior of Response with string content.'); |
15 | 15 |
16 promise_test(function() { | 16 promise_test(function() { |
17 var intView = new Int32Array([0, 1, 2, 3, 4, 55, 6, 7, 8, 9]); | 17 var intView = new Int32Array([0, 1, 2, 3, 4, 55, 6, 7, 8, 9]); |
18 var buffer = intView.buffer; | 18 var buffer = intView.buffer; |
19 | 19 |
20 var response = new Response(buffer); | 20 var response = new Response(buffer); |
21 assert_false(response.headers.has('Content-Type'), | 21 assert_false(response.headers.has('Content-Type'), |
22 'A Response constructed with ArrayBuffer should not have a content type.')
; | 22 'A Response constructed with ArrayBuffer should not have a content type.')
; |
23 return response.body.asArrayBuffer() | 23 return response.arrayBuffer() |
24 .then(function(buffer) { | 24 .then(function(buffer) { |
25 var resultIntView = new Int32Array(buffer); | 25 var resultIntView = new Int32Array(buffer); |
26 assert_array_equals( | 26 assert_array_equals( |
27 resultIntView, [0, 1, 2, 3, 4, 55, 6, 7, 8, 9], | 27 resultIntView, [0, 1, 2, 3, 4, 55, 6, 7, 8, 9], |
28 'Response body ArrayBuffer should match ArrayBuffer ' + | 28 'Response body ArrayBuffer should match ArrayBuffer ' + |
29 'it was constructed with.'); | 29 'it was constructed with.'); |
30 }); | 30 }); |
31 }, 'Behavior of Response with ArrayBuffer content.'); | 31 }, 'Behavior of Response with ArrayBuffer content.'); |
32 | 32 |
33 promise_test(function() { | 33 promise_test(function() { |
34 var intView = new Int32Array([0, 1, 2, 3, 4, 55, 6, 7, 8, 9]); | 34 var intView = new Int32Array([0, 1, 2, 3, 4, 55, 6, 7, 8, 9]); |
35 | 35 |
36 var response = new Response(intView); | 36 var response = new Response(intView); |
37 assert_false(response.headers.has('Content-Type'), | 37 assert_false(response.headers.has('Content-Type'), |
38 'A Response constructed with ArrayBufferView ' + | 38 'A Response constructed with ArrayBufferView ' + |
39 'should not have a content type.'); | 39 'should not have a content type.'); |
40 return response.body.asArrayBuffer() | 40 return response.arrayBuffer() |
41 .then(function(buffer) { | 41 .then(function(buffer) { |
42 var resultIntView = new Int32Array(buffer); | 42 var resultIntView = new Int32Array(buffer); |
43 assert_array_equals( | 43 assert_array_equals( |
44 resultIntView, [0, 1, 2, 3, 4, 55, 6, 7, 8, 9], | 44 resultIntView, [0, 1, 2, 3, 4, 55, 6, 7, 8, 9], |
45 'Response body ArrayBuffer should match ArrayBufferView ' + | 45 'Response body ArrayBuffer should match ArrayBufferView ' + |
46 'it was constructed with.'); | 46 'it was constructed with.'); |
47 }); | 47 }); |
48 }, 'Behavior of Response with ArrayBufferView content without a slice.'); | 48 }, 'Behavior of Response with ArrayBufferView content without a slice.'); |
49 | 49 |
50 promise_test(function() { | 50 promise_test(function() { |
51 var intView = new Int32Array([0, 1, 2, 3, 4, 55, 6, 7, 8, 9]); | 51 var intView = new Int32Array([0, 1, 2, 3, 4, 55, 6, 7, 8, 9]); |
52 var slice = intView.subarray(1, 4); // Should be [1, 2, 3] | 52 var slice = intView.subarray(1, 4); // Should be [1, 2, 3] |
53 var response = new Response(slice); | 53 var response = new Response(slice); |
54 assert_false(response.headers.has('Content-Type'), | 54 assert_false(response.headers.has('Content-Type'), |
55 'A Response constructed with ArrayBufferView ' + | 55 'A Response constructed with ArrayBufferView ' + |
56 'should not have a content type.'); | 56 'should not have a content type.'); |
57 return response.body.asArrayBuffer() | 57 return response.arrayBuffer() |
58 .then(function(buffer) { | 58 .then(function(buffer) { |
59 var resultIntView = new Int32Array(buffer); | 59 var resultIntView = new Int32Array(buffer); |
60 assert_array_equals( | 60 assert_array_equals( |
61 resultIntView, [1, 2, 3], | 61 resultIntView, [1, 2, 3], |
62 'Response body ArrayBuffer should match ArrayBufferView ' + | 62 'Response body ArrayBuffer should match ArrayBufferView ' + |
63 'slice it was constructed with.'); | 63 'slice it was constructed with.'); |
64 }); | 64 }); |
65 }, 'Behavior of Response with ArrayBufferView content with a slice.'); | 65 }, 'Behavior of Response with ArrayBufferView content with a slice.'); |
OLD | NEW |