| Index: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html
|
| diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html
|
| index ef2f925aa5f1ef7721d4e0325e77f4bd8fc6dd90..8afa237dc0ecb9bb6c52e87aedd014feb1a10ee9 100644
|
| --- a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html
|
| +++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/fetch-request-xhr-iframe.https.html
|
| @@ -8,6 +8,10 @@ function assert_equals(a, b) {
|
| port.postMessage({results: 'equals', got: a, expected: b});
|
| }
|
|
|
| +function assert_array_equals(a, b, msg) {
|
| + port.postMessage({results: 'array_equals', got: a, expected: b, msg: msg});
|
| +}
|
| +
|
| function get_boundary(headers) {
|
| var reg = new RegExp('multipart\/form-data; boundary=(.*)');
|
| for (var i = 0; i < headers.length; ++i) {
|
| @@ -59,6 +63,70 @@ function xhr_send(url_base, method, data, with_credentials) {
|
| });
|
| }
|
|
|
| +function get_sorted_header_name_list(headers) {
|
| + var header_names = [];
|
| + var idx, name;
|
| +
|
| + for (idx = 0; idx < headers.length; ++idx) {
|
| + name = headers[idx][0];
|
| + // The `Accept-Language` header is optional; its presence should not
|
| + // influence test results.
|
| + //
|
| + // > 4. If request’s header list does not contain `Accept-Language`, user
|
| + // > agents should append `Accept-Language`/an appropriate value to
|
| + // > request's header list.
|
| + //
|
| + // https://fetch.spec.whatwg.org/#fetching
|
| + if (name === 'accept-language') {
|
| + continue;
|
| + }
|
| +
|
| + header_names.push(name);
|
| + }
|
| + header_names.sort();
|
| + return header_names;
|
| +}
|
| +
|
| +function get_header_test() {
|
| + return xhr_send(host_info['HTTPS_ORIGIN'], 'GET', '', false)
|
| + .then(function(response) {
|
| + assert_array_equals(
|
| + get_sorted_header_name_list(response.headers),
|
| + ["accept"],
|
| + 'event.request has the expected headers for same-origin GET.');
|
| + });
|
| +}
|
| +
|
| +function post_header_test() {
|
| + return xhr_send(host_info['HTTPS_ORIGIN'], 'POST', '', false)
|
| + .then(function(response) {
|
| + assert_array_equals(
|
| + get_sorted_header_name_list(response.headers),
|
| + ["accept", "content-type"],
|
| + 'event.request has the expected headers for same-origin POST.');
|
| + });
|
| +}
|
| +
|
| +function cross_origin_get_header_test() {
|
| + return xhr_send(host_info['HTTPS_REMOTE_ORIGIN'], 'GET', '', false)
|
| + .then(function(response) {
|
| + assert_array_equals(
|
| + get_sorted_header_name_list(response.headers),
|
| + ["accept"],
|
| + 'event.request has the expected headers for cross-origin GET.');
|
| + });
|
| +}
|
| +
|
| +function cross_origin_post_header_test() {
|
| + return xhr_send(host_info['HTTPS_REMOTE_ORIGIN'], 'POST', '', false)
|
| + .then(function(response) {
|
| + assert_array_equals(
|
| + get_sorted_header_name_list(response.headers),
|
| + ["accept", "content-type"],
|
| + 'event.request has the expected headers for cross-origin POST.');
|
| + });
|
| +}
|
| +
|
| function string_test() {
|
| return xhr_send(host_info['HTTPS_ORIGIN'], 'POST', 'test string', false)
|
| .then(function(response) {
|
| @@ -166,7 +234,11 @@ function data_url_test() {
|
|
|
| window.addEventListener('message', function(evt) {
|
| port = evt.ports[0];
|
| - string_test()
|
| + get_header_test()
|
| + .then(post_header_test)
|
| + .then(cross_origin_get_header_test)
|
| + .then(cross_origin_post_header_test)
|
| + .then(string_test)
|
| .then(blob_test)
|
| .then(custom_method_test)
|
| .then(options_method_test)
|
| @@ -174,6 +246,9 @@ window.addEventListener('message', function(evt) {
|
| .then(mode_credentials_test)
|
| .then(data_url_test)
|
| .then(function() { port.postMessage({results: 'finish'}); })
|
| - .catch(function(e) { port.postMessage({results: 'failure:' + e}); });
|
| + .catch(function(reason) {
|
| + var error = String(reason.message || reason);
|
| + port.postMessage({results: 'failure', error: error});
|
| + });
|
| });
|
| </script>
|
|
|