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

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

Issue 1816473002: Add layout tests to check that a FetchEvent includes the right headers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use const Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-event-test-worker.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-request-xhr-iframe.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-request-xhr-iframe.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-request-xhr-iframe.html
index b485ee2e7a6736b6ab361a1c8c08594f83fc4a5f..609ac6e433a88b35191f40879e3eddad4a4fc429 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-request-xhr-iframe.html
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-request-xhr-iframe.html
@@ -55,6 +55,59 @@ function xhr_send(url_base, method, data, with_credentials) {
});
}
+function get_sorted_header_name_list(headers) {
+ const header_names = [];
+ for (const [name, value] of headers) {
+ header_names.push(name);
+ }
+ header_names.sort();
+ return header_names;
+}
+
+function get_header_test() {
+ return xhr_send(host_info['HTTP_ORIGIN'], 'GET', '', false)
+ .then(function(response) {
+ assert_array_equals(
+ get_sorted_header_name_list(response.headers),
+ ["accept", "user-agent"],
+ 'event.request has the expected headers for same-origin GET.');
+ });
+}
+
+// TODO(tyoshino): Fix the stack not to include the Origin header as specified
+// in the spec.
+function post_header_test() {
+ return xhr_send(host_info['HTTP_ORIGIN'], 'POST', '', false)
+ .then(function(response) {
+ assert_array_equals(
+ get_sorted_header_name_list(response.headers),
+ ["accept", "content-type", "origin", "user-agent"],
+ 'event.request has the expected headers for same-origin POST.');
+ });
+}
+
+function cross_origin_get_header_test() {
+ return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'GET', '', false)
+ .then(function(response) {
+ assert_array_equals(
+ get_sorted_header_name_list(response.headers),
+ ["accept", "user-agent"],
+ 'event.request has the expected headers for cross-origin GET.');
+ });
+}
+
+// TODO(tyoshino): Fix the stack not to include the Origin header as specified
+// in the spec.
+function cross_origin_post_header_test() {
+ return xhr_send(host_info['HTTP_REMOTE_ORIGIN'], 'POST', '', false)
+ .then(function(response) {
+ assert_array_equals(
+ get_sorted_header_name_list(response.headers),
+ ["accept", "content-type", "origin", "user-agent"],
+ 'event.request has the expected headers for cross-origin POST.');
+ });
+}
+
function string_test() {
return xhr_send(host_info['HTTP_ORIGIN'], 'POST', 'test string', false)
.then(function(response) {
@@ -172,7 +225,11 @@ function data_url_test() {
window.addEventListener('message', function(evt) {
var 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)
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/fetch-event-test-worker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698