From d4860e32828ea691951e270fa9a1e1ecee627313 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Sat, 9 May 2026 09:12:42 +0200 Subject: [PATCH 1/2] Revert "remove test case that is not synced with spec anymore" This reverts commit 733cc58bc47b0887aa3b9506d52f84307d996e61. --- xhr/setrequestheader-content-type.htm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xhr/setrequestheader-content-type.htm b/xhr/setrequestheader-content-type.htm index c78482142469cf..07238391eb5cc8 100644 --- a/xhr/setrequestheader-content-type.htm +++ b/xhr/setrequestheader-content-type.htm @@ -206,6 +206,15 @@ "application/x-www-form-urlencoded;charset=UTF-8", 'URLSearchParams request has correct default Content-Type of "application/x-www-form-urlencoded;charset=UTF-8"' ) + request( + function _URLSearchParams() { return new URLSearchParams("q=testQ&topic=testTopic") }, + {"Content-Type": "application/xml;charset=ASCII"}, + "application/xml;charset=UTF-8", + "URLSearchParams request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8" + // the default Content-Type for URLSearchParams has a charset specified (utf-8) in + // https://fetch.spec.whatwg.org/#bodyinit, so the user's must be changed to match it + // as per https://xhr.spec.whatwg.org/#the-send%28%29-method step 4. + ) From 4104271bdfc5bc2a74e468e3d2298c6349d58f2d Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Thu, 14 May 2026 15:12:32 +0200 Subject: [PATCH 2/2] test a bit more --- xhr/setrequestheader-content-type.htm | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/xhr/setrequestheader-content-type.htm b/xhr/setrequestheader-content-type.htm index 07238391eb5cc8..856111b1270808 100644 --- a/xhr/setrequestheader-content-type.htm +++ b/xhr/setrequestheader-content-type.htm @@ -68,6 +68,12 @@ "text/javascript;charset=UTF-8", "String request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8" ) + request( + function _String() { return "test"; }, + {"Content-Type": "application/xml"}, + "application/xml", + "String request keeps setRequestHeader() Content-Type without charset" + ) request( function _XMLDocument() { return new DOMParser().parseFromString("", "application/xml"); }, {"Content-Type": ""}, @@ -86,6 +92,12 @@ "application/xhtml+xml;charset=UTF-8", "XML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8" ) + request( + function _XMLDocument() { return new DOMParser().parseFromString("", "application/xml"); }, + {"Content-Type": "application/xhtml+xml"}, + "application/xhtml+xml", + "XML Document request keeps setRequestHeader() Content-Type without charset" + ) request( function _HTMLDocument() { return new DOMParser().parseFromString("", "text/html"); }, {"Content-Type": ""}, @@ -104,6 +116,12 @@ "text/html+junk;charset=UTF-8", "HTML Document request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8" ) + request( + function _HTMLDocument() { return new DOMParser().parseFromString("", "text/html"); }, + {"Content-Type": "text/html+junk"}, + "text/html+junk", + "HTML Document request keeps setRequestHeader() Content-Type without charset" + ) request( function _Blob() { return new Blob(["test"]); }, {"Content-Type": ""}, @@ -211,9 +229,12 @@ {"Content-Type": "application/xml;charset=ASCII"}, "application/xml;charset=UTF-8", "URLSearchParams request keeps setRequestHeader() Content-Type, with charset adjusted to UTF-8" - // the default Content-Type for URLSearchParams has a charset specified (utf-8) in - // https://fetch.spec.whatwg.org/#bodyinit, so the user's must be changed to match it - // as per https://xhr.spec.whatwg.org/#the-send%28%29-method step 4. + ) + request( + function _URLSearchParams() { return new URLSearchParams("q=testQ&topic=testTopic") }, + {"Content-Type": "application/xml"}, + "application/xml", + "URLSearchParams request keeps setRequestHeader() Content-Type without charset" )