| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 assert_equals(response.mode, 'cors'); | 136 assert_equals(response.mode, 'cors'); |
| 137 assert_equals(response.credentials, 'same-origin'); | 137 assert_equals(response.credentials, 'same-origin'); |
| 138 return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'GET', '', true); | 138 return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'GET', '', true); |
| 139 }) | 139 }) |
| 140 .then(function(response){ | 140 .then(function(response){ |
| 141 assert_equals(response.mode, 'cors'); | 141 assert_equals(response.mode, 'cors'); |
| 142 assert_equals(response.credentials, 'include'); | 142 assert_equals(response.credentials, 'include'); |
| 143 }); | 143 }); |
| 144 } | 144 } |
| 145 | 145 |
| 146 function data_url_test() { |
| 147 return new Promise(function(resolve, reject) { |
| 148 var xhr = new XMLHttpRequest(); |
| 149 xhr.onload = function() { |
| 150 resolve(xhr.response); |
| 151 }; |
| 152 xhr.onerror = function() { |
| 153 reject('XHR should succeed.'); |
| 154 }; |
| 155 xhr.responseType = 'text'; |
| 156 xhr.open('GET', 'data:text/html,Foobar', true); |
| 157 xhr.send(); |
| 158 }) |
| 159 .then(function(data) { |
| 160 assert_equals(data, 'Foobar'); |
| 161 }); |
| 162 } |
| 163 |
| 164 function xhr_options_test() { |
| 165 return new Promise(function(resolve, reject) { |
| 166 var xhr = new XMLHttpRequest(); |
| 167 xhr.onload = function() { |
| 168 resolve(xhr.response); |
| 169 }; |
| 170 xhr.onerror = function() { |
| 171 reject('XHR should succeed.'); |
| 172 }; |
| 173 xhr.responseType = 'text'; |
| 174 xhr.open('OpTiOnS', 'fetch-access-control.php', true); |
| 175 xhr.send(); |
| 176 }) |
| 177 .then(function(data) { |
| 178 var result; |
| 179 var report = function(arg) { |
| 180 result = arg; |
| 181 }; |
| 182 eval(data); |
| 183 assert_equals(result['jsonpResult'], 'success'); |
| 184 assert_equals(result['method'], 'OPTIONS'); |
| 185 }) |
| 186 } |
| 187 |
| 146 window.addEventListener('message', function(evt) { | 188 window.addEventListener('message', function(evt) { |
| 147 var port = evt.ports[0]; | 189 var port = evt.ports[0]; |
| 148 string_test() | 190 string_test() |
| 149 .then(blob_test) | 191 .then(blob_test) |
| 150 .then(custom_method_test) | 192 .then(custom_method_test) |
| 151 .then(form_data_test) | 193 .then(form_data_test) |
| 152 .then(mode_credentials_test) | 194 .then(mode_credentials_test) |
| 195 .then(data_url_test) |
| 196 .then(xhr_options_test) |
| 153 .then(function() { port.postMessage({results: 'finish'}); }) | 197 .then(function() { port.postMessage({results: 'finish'}); }) |
| 154 .catch(function(e) { port.postMessage({results: 'failure:' + e}); }); | 198 .catch(function(e) { port.postMessage({results: 'failure:' + e}); }); |
| 155 }); | 199 }); |
| 156 </script> | 200 </script> |
| OLD | NEW |