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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-request-xhr-iframe.html

Issue 2254693002: Delay generation of User-Agent header to URLRequestHttpJob and accept custom User-Agent from XHR/Fe… Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed Android test Created 4 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 unified diff | Download patch
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 assert_array_equals( 70 assert_array_equals(
71 get_sorted_header_name_list(response.headers), 71 get_sorted_header_name_list(response.headers),
72 ["accept", "user-agent"], 72 ["accept"],
73 'event.request has the expected headers for same-origin GET.'); 73 'event.request has the expected headers for same-origin GET.');
74 }); 74 });
75 } 75 }
76 76
77 // TODO(tyoshino): Fix the stack not to include the Origin header as specified 77 // TODO(tyoshino): Fix the stack not to include the Origin header as specified
78 // in the spec. 78 // in the spec.
79 function post_header_test() { 79 function post_header_test() {
80 return xhr_send(host_info['HTTP_ORIGIN'], 'POST', '', false) 80 return xhr_send(host_info['HTTP_ORIGIN'], 'POST', '', false)
81 .then(function(response) { 81 .then(function(response) {
82 assert_array_equals( 82 assert_array_equals(
83 get_sorted_header_name_list(response.headers), 83 get_sorted_header_name_list(response.headers),
84 ["accept", "content-type", "origin", "user-agent"], 84 ["accept", "content-type", "origin"],
85 'event.request has the expected headers for same-origin POST.'); 85 'event.request has the expected headers for same-origin POST.');
86 }); 86 });
87 } 87 }
88 88
89 function cross_origin_get_header_test() { 89 function cross_origin_get_header_test() {
90 return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'GET', '', false) 90 return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'GET', '', false)
91 .then(function(response) { 91 .then(function(response) {
92 assert_array_equals( 92 assert_array_equals(
93 get_sorted_header_name_list(response.headers), 93 get_sorted_header_name_list(response.headers),
94 ["accept", "user-agent"], 94 ["accept"],
95 'event.request has the expected headers for cross-origin GET.'); 95 'event.request has the expected headers for cross-origin GET.');
96 }); 96 });
97 } 97 }
98 98
99 // TODO(tyoshino): Fix the stack not to include the Origin header as specified 99 // TODO(tyoshino): Fix the stack not to include the Origin header as specified
100 // in the spec. 100 // in the spec.
101 function cross_origin_post_header_test() { 101 function cross_origin_post_header_test() {
102 return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'POST', '', false) 102 return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'POST', '', false)
103 .then(function(response) { 103 .then(function(response) {
104 assert_array_equals( 104 assert_array_equals(
105 get_sorted_header_name_list(response.headers), 105 get_sorted_header_name_list(response.headers),
106 ["accept", "content-type", "origin", "user-agent"], 106 ["accept", "content-type", "origin"],
107 'event.request has the expected headers for cross-origin POST.'); 107 'event.request has the expected headers for cross-origin POST.');
108 }); 108 });
109 } 109 }
110 110
111 function string_test() { 111 function string_test() {
112 return xhr_send(host_info['HTTP_ORIGIN'], 'POST', 'test string', false) 112 return xhr_send(host_info['HTTP_ORIGIN'], 'POST', 'test string', false)
113 .then(function(response) { 113 .then(function(response) {
114 assert_equals(response.method, 'POST'); 114 assert_equals(response.method, 'POST');
115 assert_equals(response.body, 'test string'); 115 assert_equals(response.body, 'test string');
116 }); 116 });
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 .then(blob_test) 233 .then(blob_test)
234 .then(custom_method_test) 234 .then(custom_method_test)
235 .then(options_method_test) 235 .then(options_method_test)
236 .then(form_data_test) 236 .then(form_data_test)
237 .then(mode_credentials_test) 237 .then(mode_credentials_test)
238 .then(data_url_test) 238 .then(data_url_test)
239 .then(function() { port.postMessage({results: 'finish'}); }) 239 .then(function() { port.postMessage({results: 'finish'}); })
240 .catch(function(e) { port.postMessage({results: 'failure:' + e}); }); 240 .catch(function(e) { port.postMessage({results: 'failure:' + e}); });
241 }); 241 });
242 </script> 242 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698