diff --git a/testing/web-platform/tests/fetch/api/redirect/redirect-method.any.js b/testing/web-platform/tests/fetch/api/redirect/redirect-method.any.js index c0cdaa85dc063..2fb6537ff5087 100644 --- a/testing/web-platform/tests/fetch/api/redirect/redirect-method.any.js +++ b/testing/web-platform/tests/fetch/api/redirect/redirect-method.any.js @@ -10,12 +10,12 @@ expectedMethod opts ) { -var +let url = redirectUrl ; -var +let urlParameters = " @@ -40,7 +40,42 @@ encodeURIComponent redirectLocation ) ; -var +let +requestHeaders += +{ +" +Content +- +Encoding +" +: +" +Identity +" +" +Content +- +Language +" +: +" +en +- +US +" +" +Content +- +Location +" +: +" +foo +" +} +; +let requestInit = { @@ -56,6 +91,11 @@ redirect " follow " +" +headers +" +: +requestHeaders } ; opts @@ -72,6 +112,7 @@ opts . body ) +{ requestInit . body @@ -80,6 +121,7 @@ opts . body ; +} promise_test ( function @@ -103,6 +145,27 @@ function resp ) { +let +expectedRequestContentType += +" +NO +" +; +if +( +opts +. +expectedRequestContentType +) +{ +expectedRequestContentType += +opts +. +expectedRequestContentType +; +} assert_equals ( resp @@ -164,6 +227,141 @@ is expectedMethod ) ; +let +hasRequestBodyHeader += +true +; +if +( +opts +. +expectedStripRequestBodyHeader +) +{ +hasRequestBodyHeader += +! +opts +. +expectedStripRequestBodyHeader +; +} +assert_equals +( +resp +. +headers +. +get +( +" +x +- +request +- +content +- +type +" +) +expectedRequestContentType +" +Request +Content +- +Type +after +redirection +is +" ++ +expectedRequestContentType +) +; +[ +" +Content +- +Encoding +" +" +Content +- +Language +" +" +Content +- +Location +" +] +. +forEach +( +header += +> +{ +let +xHeader += +" +x +- +request +- +" ++ +header +. +toLowerCase +( +) +; +let +expectedValue += +hasRequestBodyHeader +? +requestHeaders +[ +header +] +: +" +NO +" +; +assert_equals +( +resp +. +headers +. +get +( +xHeader +) +expectedValue +" +Request +" ++ +header ++ +" +after +redirection +is +" ++ +expectedValue +) +; +} +) +; assert_true ( resp @@ -200,6 +398,7 @@ expectedMethod POST " ) +{ expectedBody = opts @@ -211,6 +410,24 @@ requestInit . body ; +} +let +expectedContentLength += +expectedBody +? +expectedBody +. +length +. +toString +( +) +: +" +NO +" +; assert_equals ( text @@ -221,6 +438,38 @@ body " ) ; +assert_equals +( +resp +. +headers +. +get +( +" +x +- +request +- +content +- +length +" +) +expectedContentLength +" +Request +Content +- +Length +after +redirection +is +" ++ +expectedContentLength +) +; } ) ; @@ -424,6 +673,9 @@ GET body : stringBody +expectedStripRequestBodyHeader +: +true } ) ; @@ -486,6 +738,9 @@ GET body : stringBody +expectedStripRequestBodyHeader +: +true } ) ; @@ -548,6 +803,9 @@ GET body : stringBody +expectedStripRequestBodyHeader +: +true } ) ; @@ -574,6 +832,30 @@ redirectMethod ( " Redirect +303 +with +TESTING +" +redirUrl +locationUrl +303 +" +TESTING +" +" +GET +" +{ +expectedStripRequestBodyHeader +: +true +} +) +; +redirectMethod +( +" +Redirect 307 with GET @@ -614,6 +896,19 @@ POST body : stringBody +expectedRequestContentType +: +" +text +/ +plain +; +charset += +UTF +- +8 +" } ) ; diff --git a/testing/web-platform/tests/fetch/api/resources/method.py b/testing/web-platform/tests/fetch/api/resources/method.py index a0ab70c40fe29..8f1886d4a8f24 100644 --- a/testing/web-platform/tests/fetch/api/resources/method.py +++ b/testing/web-platform/tests/fetch/api/resources/method.py @@ -151,6 +151,166 @@ ) ) +headers +. +append +( +( +" +x +- +request +- +content +- +type +" +request +. +headers +. +get +( +" +Content +- +Type +" +" +NO +" +) +) +) + +headers +. +append +( +( +" +x +- +request +- +content +- +length +" +request +. +headers +. +get +( +" +Content +- +Length +" +" +NO +" +) +) +) + +headers +. +append +( +( +" +x +- +request +- +content +- +encoding +" +request +. +headers +. +get +( +" +Content +- +Encoding +" +" +NO +" +) +) +) + +headers +. +append +( +( +" +x +- +request +- +content +- +language +" +request +. +headers +. +get +( +" +Content +- +Language +" +" +NO +" +) +) +) + +headers +. +append +( +( +" +x +- +request +- +content +- +location +" +request +. +headers +. +get +( +" +Content +- +Location +" +" +NO +" +) +) +) + return headers request