OLD | NEW |
1 <script src="../../resources/testharness.js"></script> | 1 <script src="../../resources/testharness.js"></script> |
2 <script src="test-helpers.js?pipe=sub"></script> | 2 <script src="test-helpers.js?pipe=sub"></script> |
3 <script> | 3 <script> |
4 var host_info = get_host_info(); | 4 var host_info = get_host_info(); |
5 | 5 |
6 function get_boundary(headers) { | 6 function get_boundary(headers) { |
7 var reg = new RegExp('multipart\/form-data; boundary=(.*)'); | 7 var reg = new RegExp('multipart\/form-data; boundary=(.*)'); |
8 for (var i = 0; i < headers.length; ++i) { | 8 for (var i = 0; i < headers.length; ++i) { |
9 if (headers[i][0] != 'content-type') { | 9 if (headers[i][0] != 'content-type') { |
10 continue; | 10 continue; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 xhr.withCredentials = true; | 50 xhr.withCredentials = true; |
51 } | 51 } |
52 xhr.open(method, url_base + '/dummy?test', true); | 52 xhr.open(method, url_base + '/dummy?test', true); |
53 xhr.send(data); | 53 xhr.send(data); |
54 }); | 54 }); |
55 } | 55 } |
56 | 56 |
57 function string_test() { | 57 function string_test() { |
58 return xhr_send(host_info['HTTP_ORIGIN'], 'POST', 'test string', false) | 58 return xhr_send(host_info['HTTP_ORIGIN'], 'POST', 'test string', false) |
59 .then(function(response) { | 59 .then(function(response) { |
| 60 assert_equals(response.context, 'xmlhttprequest'); |
60 assert_equals(response.method, 'POST'); | 61 assert_equals(response.method, 'POST'); |
61 assert_equals(response.body, 'test string'); | 62 assert_equals(response.body, 'test string'); |
62 }); | 63 }); |
63 } | 64 } |
64 | 65 |
65 function blob_test() { | 66 function blob_test() { |
66 return xhr_send(host_info['HTTP_ORIGIN'], 'POST', new Blob(['test blob']), | 67 return xhr_send(host_info['HTTP_ORIGIN'], 'POST', new Blob(['test blob']), |
67 false) | 68 false) |
68 .then(function(response) { | 69 .then(function(response) { |
| 70 assert_equals(response.context, 'xmlhttprequest'); |
69 assert_equals(response.method, 'POST'); | 71 assert_equals(response.method, 'POST'); |
70 assert_equals(response.body, 'test blob'); | 72 assert_equals(response.body, 'test blob'); |
71 }); | 73 }); |
72 } | 74 } |
73 | 75 |
74 function custom_method_test() { | 76 function custom_method_test() { |
75 return xhr_send(host_info['HTTP_ORIGIN'], 'XXX', 'test string xxx', false) | 77 return xhr_send(host_info['HTTP_ORIGIN'], 'XXX', 'test string xxx', false) |
76 .then(function(response) { | 78 .then(function(response) { |
77 assert_equals(response.method, 'XXX'); | 79 assert_equals(response.method, 'XXX'); |
78 assert_equals(response.body, 'test string xxx'); | 80 assert_equals(response.body, 'test string xxx'); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 .then(blob_test) | 177 .then(blob_test) |
176 .then(custom_method_test) | 178 .then(custom_method_test) |
177 .then(options_method_test) | 179 .then(options_method_test) |
178 .then(form_data_test) | 180 .then(form_data_test) |
179 .then(mode_credentials_test) | 181 .then(mode_credentials_test) |
180 .then(data_url_test) | 182 .then(data_url_test) |
181 .then(function() { port.postMessage({results: 'finish'}); }) | 183 .then(function() { port.postMessage({results: 'finish'}); }) |
182 .catch(function(e) { port.postMessage({results: 'failure:' + e}); }); | 184 .catch(function(e) { port.postMessage({results: 'failure:' + e}); }); |
183 }); | 185 }); |
184 </script> | 186 </script> |
OLD | NEW |