OLD | NEW |
1 <script src="../../resources/testharness.js"></script> | 1 <script src="../../resources/testharness.js"></script> |
2 <script src="../../resources/get-host-info.js?pipe=sub"></script> | 2 <script src="../../resources/get-host-info.js?pipe=sub"></script> |
3 <script src="test-helpers.js"></script> | 3 <script src="test-helpers.js"></script> |
4 <script> | 4 <script> |
5 var host_info = get_host_info(); | 5 var host_info = get_host_info(); |
6 | 6 |
7 function get_boundary(headers) { | 7 function get_boundary(headers) { |
8 var reg = new RegExp('multipart\/form-data; boundary=(.*)'); | 8 var reg = new RegExp('multipart\/form-data; boundary=(.*)'); |
9 for (var i = 0; i < headers.length; ++i) { | 9 for (var i = 0; i < headers.length; ++i) { |
10 if (headers[i][0] != 'content-type') { | 10 if (headers[i][0] != 'content-type') { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 for (const [name, value] of headers) { | 60 for (const [name, value] of headers) { |
61 header_names.push(name); | 61 header_names.push(name); |
62 } | 62 } |
63 header_names.sort(); | 63 header_names.sort(); |
64 return header_names; | 64 return header_names; |
65 } | 65 } |
66 | 66 |
67 function get_header_test() { | 67 function get_header_test() { |
68 return xhr_send(host_info['HTTP_ORIGIN'], 'GET', '', false) | 68 return xhr_send(host_info['HTTP_ORIGIN'], 'GET', '', false) |
69 .then(function(response) { | 69 .then(function(response) { |
| 70 // This assertion is invalid because the User-Agent header should not |
| 71 // be present. |
70 assert_array_equals( | 72 assert_array_equals( |
71 get_sorted_header_name_list(response.headers), | 73 get_sorted_header_name_list(response.headers), |
72 ["accept", "user-agent"], | 74 ["accept", "user-agent"], |
73 'event.request has the expected headers for same-origin GET.'); | 75 'event.request has the expected headers for same-origin GET.'); |
74 }); | 76 }); |
75 } | 77 } |
76 | 78 |
77 // TODO(tyoshino): Fix the stack not to include the Origin header as specified | 79 // TODO(tyoshino): Fix the stack not to include the Origin header as specified |
78 // in the spec. | 80 // in the spec. Likewise, the User-Agent header should not be present. |
79 function post_header_test() { | 81 function post_header_test() { |
80 return xhr_send(host_info['HTTP_ORIGIN'], 'POST', '', false) | 82 return xhr_send(host_info['HTTP_ORIGIN'], 'POST', '', false) |
81 .then(function(response) { | 83 .then(function(response) { |
82 assert_array_equals( | 84 assert_array_equals( |
83 get_sorted_header_name_list(response.headers), | 85 get_sorted_header_name_list(response.headers), |
84 ["accept", "content-type", "origin", "user-agent"], | 86 ["accept", "content-type", "origin", "user-agent"], |
85 'event.request has the expected headers for same-origin POST.'); | 87 'event.request has the expected headers for same-origin POST.'); |
86 }); | 88 }); |
87 } | 89 } |
88 | 90 |
89 function cross_origin_get_header_test() { | 91 function cross_origin_get_header_test() { |
90 return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'GET', '', false) | 92 return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'GET', '', false) |
91 .then(function(response) { | 93 .then(function(response) { |
| 94 // This assertion is invalid because the User-Agent header should not |
| 95 // be present. |
92 assert_array_equals( | 96 assert_array_equals( |
93 get_sorted_header_name_list(response.headers), | 97 get_sorted_header_name_list(response.headers), |
94 ["accept", "user-agent"], | 98 ["accept", "user-agent"], |
95 'event.request has the expected headers for cross-origin GET.'); | 99 'event.request has the expected headers for cross-origin GET.'); |
96 }); | 100 }); |
97 } | 101 } |
98 | 102 |
99 // TODO(tyoshino): Fix the stack not to include the Origin header as specified | 103 // TODO(tyoshino): Fix the stack not to include the Origin header as specified |
100 // in the spec. | 104 // in the spec. Likewise, the User-Agent header should not be present. |
101 function cross_origin_post_header_test() { | 105 function cross_origin_post_header_test() { |
102 return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'POST', '', false) | 106 return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'POST', '', false) |
103 .then(function(response) { | 107 .then(function(response) { |
104 assert_array_equals( | 108 assert_array_equals( |
105 get_sorted_header_name_list(response.headers), | 109 get_sorted_header_name_list(response.headers), |
106 ["accept", "content-type", "origin", "user-agent"], | 110 ["accept", "content-type", "origin", "user-agent"], |
107 'event.request has the expected headers for cross-origin POST.'); | 111 'event.request has the expected headers for cross-origin POST.'); |
108 }); | 112 }); |
109 } | 113 } |
110 | 114 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 .then(blob_test) | 237 .then(blob_test) |
234 .then(custom_method_test) | 238 .then(custom_method_test) |
235 .then(options_method_test) | 239 .then(options_method_test) |
236 .then(form_data_test) | 240 .then(form_data_test) |
237 .then(mode_credentials_test) | 241 .then(mode_credentials_test) |
238 .then(data_url_test) | 242 .then(data_url_test) |
239 .then(function() { port.postMessage({results: 'finish'}); }) | 243 .then(function() { port.postMessage({results: 'finish'}); }) |
240 .catch(function(e) { port.postMessage({results: 'failure:' + e}); }); | 244 .catch(function(e) { port.postMessage({results: 'failure:' + e}); }); |
241 }); | 245 }); |
242 </script> | 246 </script> |
OLD | NEW |