@@ -3987,6 +3987,157 @@ public void redirectChainBackToOriginStaysCrossSite() throws Exception {
39873987 }
39883988 }
39893989
3990+ /**
3991+ * Tests the Sec-Fetch-* headers sent for an <iframe src> auto-load. Unlike an
3992+ * anchor/form navigation, there is no click or user gesture involved at all here, so
3993+ * real browsers never send Sec-Fetch-User for it - not even the (hardcoded, still
3994+ * wrong for anchor/area) "?1" HtmlUnit currently sends for those.
3995+ *
3996+ * @throws Exception if the test fails
3997+ */
3998+ @ Test
3999+ @ Alerts (
4000+ CHROME = {"GET /frame.html HTTP/1.1" ,
4001+ "Host: localhost:§§PORT§§" ,
4002+ "Connection: keep-alive" ,
4003+ "sec-ch-ua: §§SEC_USER_AGENT§§" ,
4004+ "sec-ch-ua-mobile: ?0" ,
4005+ "sec-ch-ua-platform: \" Windows\" " ,
4006+ "Upgrade-Insecure-Requests: 1" ,
4007+ "User-Agent: §§USER_AGENT§§" ,
4008+ "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" ,
4009+ "Sec-Fetch-Site: same-origin" ,
4010+ "Sec-Fetch-Mode: navigate" ,
4011+ "Sec-Fetch-Dest: frame" ,
4012+ "Referer: http://localhost:§§PORT§§/" ,
4013+ "Accept-Encoding: gzip, deflate, br, zstd" ,
4014+ "Accept-Language: en-US,en;q=0.9" },
4015+ EDGE = {"GET /frame.html HTTP/1.1" ,
4016+ "Host: localhost:§§PORT§§" ,
4017+ "Connection: keep-alive" ,
4018+ "sec-ch-ua: §§SEC_USER_AGENT§§" ,
4019+ "sec-ch-ua-mobile: ?0" ,
4020+ "sec-ch-ua-platform: \" Windows\" " ,
4021+ "Upgrade-Insecure-Requests: 1" ,
4022+ "User-Agent: §§USER_AGENT§§" ,
4023+ "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" ,
4024+ "Sec-Fetch-Site: same-origin" ,
4025+ "Sec-Fetch-Mode: navigate" ,
4026+ "Sec-Fetch-Dest: frame" ,
4027+ "Referer: http://localhost:§§PORT§§/" ,
4028+ "Accept-Encoding: gzip, deflate, br, zstd" ,
4029+ "Accept-Language: en-US,en;q=0.9" },
4030+ FF = {"GET /frame.html HTTP/1.1" ,
4031+ "Host: localhost:§§PORT§§" ,
4032+ "User-Agent: §§USER_AGENT§§" ,
4033+ "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" ,
4034+ "Accept-Language: en-US,en;q=0.9" ,
4035+ "Accept-Encoding: gzip, deflate, br, zstd" ,
4036+ "Connection: keep-alive" ,
4037+ "Referer: http://localhost:§§PORT§§/" ,
4038+ "Upgrade-Insecure-Requests: 1" ,
4039+ "Sec-Fetch-Dest: frame" ,
4040+ "Sec-Fetch-Mode: navigate" ,
4041+ "Sec-Fetch-Site: same-origin" ,
4042+ "Priority: u=4" },
4043+ FF_ESR = {"GET /frame.html HTTP/1.1" ,
4044+ "Host: localhost:§§PORT§§" ,
4045+ "User-Agent: §§USER_AGENT§§" ,
4046+ "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" ,
4047+ "Accept-Language: en-US,en;q=0.5" ,
4048+ "Accept-Encoding: gzip, deflate, br, zstd" ,
4049+ "Connection: keep-alive" ,
4050+ "Referer: http://localhost:§§PORT§§/" ,
4051+ "Upgrade-Insecure-Requests: 1" ,
4052+ "Sec-Fetch-Dest: frame" ,
4053+ "Sec-Fetch-Mode: navigate" ,
4054+ "Sec-Fetch-Site: same-origin" ,
4055+ "Priority: u=4" })
4056+ @ HtmlUnitNYI (
4057+ CHROME = {"GET /frame.html HTTP/1.1" ,
4058+ "Host: localhost:§§PORT§§" ,
4059+ "Connection: keep-alive" ,
4060+ "sec-ch-ua: §§SEC_USER_AGENT§§" ,
4061+ "sec-ch-ua-mobile: ?0" ,
4062+ "sec-ch-ua-platform: \" Windows\" " ,
4063+ "Upgrade-Insecure-Requests: 1" ,
4064+ "User-Agent: §§USER_AGENT§§" ,
4065+ "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" ,
4066+ "Sec-Fetch-Site: same-origin" ,
4067+ "Sec-Fetch-Mode: navigate" ,
4068+ "Sec-Fetch-Dest: frame" ,
4069+ "Referer: http://localhost:§§PORT§§/" ,
4070+ "Accept-Encoding: gzip, deflate, br" ,
4071+ "Accept-Language: en-US,en;q=0.9" },
4072+ EDGE = {"GET /frame.html HTTP/1.1" ,
4073+ "Host: localhost:§§PORT§§" ,
4074+ "Connection: keep-alive" ,
4075+ "sec-ch-ua: §§SEC_USER_AGENT§§" ,
4076+ "sec-ch-ua-mobile: ?0" ,
4077+ "sec-ch-ua-platform: \" Windows\" " ,
4078+ "Upgrade-Insecure-Requests: 1" ,
4079+ "User-Agent: §§USER_AGENT§§" ,
4080+ "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" ,
4081+ "Sec-Fetch-Site: same-origin" ,
4082+ "Sec-Fetch-Mode: navigate" ,
4083+ "Sec-Fetch-Dest: frame" ,
4084+ "Referer: http://localhost:§§PORT§§/" ,
4085+ "Accept-Encoding: gzip, deflate, br" ,
4086+ "Accept-Language: en-US,en;q=0.9" },
4087+ FF = {"GET /frame.html HTTP/1.1" ,
4088+ "Host: localhost:§§PORT§§" ,
4089+ "User-Agent: §§USER_AGENT§§" ,
4090+ "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" ,
4091+ "Accept-Language: en-US,en;q=0.9" ,
4092+ "Accept-Encoding: gzip, deflate, br" ,
4093+ "Connection: keep-alive" ,
4094+ "Referer: http://localhost:§§PORT§§/" ,
4095+ "Upgrade-Insecure-Requests: 1" ,
4096+ "Sec-Fetch-Dest: frame" ,
4097+ "Sec-Fetch-Mode: navigate" ,
4098+ "Sec-Fetch-Site: same-origin" ,
4099+ "Priority: u=0, i" },
4100+ FF_ESR = {"GET /frame.html HTTP/1.1" ,
4101+ "Host: localhost:§§PORT§§" ,
4102+ "User-Agent: §§USER_AGENT§§" ,
4103+ "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" ,
4104+ "Accept-Language: en-US,en;q=0.5" ,
4105+ "Accept-Encoding: gzip, deflate, br" ,
4106+ "Connection: keep-alive" ,
4107+ "Referer: http://localhost:§§PORT§§/" ,
4108+ "Upgrade-Insecure-Requests: 1" ,
4109+ "Sec-Fetch-Dest: frame" ,
4110+ "Sec-Fetch-Mode: navigate" ,
4111+ "Sec-Fetch-Site: same-origin" ,
4112+ "Priority: u=0, i" })
4113+ public void frameLoad () throws Exception {
4114+ final String html = DOCTYPE_HTML
4115+ + "<html><frameset><frame src='frame.html'></frameset></html>" ;
4116+ final String htmlResponse = "HTTP/1.1 200 OK\r \n "
4117+ + "Content-Length: " + html .length () + "\r \n "
4118+ + "Content-Type: text/html\r \n "
4119+ + "\r \n "
4120+ + html ;
4121+ final String frameResponse = "HTTP/1.1 200 OK\r \n "
4122+ + "Content-Length: 2\r \n "
4123+ + "Content-Type: text/html\r \n "
4124+ + "\r \n "
4125+ + "Hi" ;
4126+
4127+ shutDownAll ();
4128+ try (PrimitiveWebServer primitiveWebServer = new PrimitiveWebServer (null , htmlResponse , frameResponse )) {
4129+ final WebDriver driver = getWebDriver ();
4130+
4131+ driver .get ("http://localhost:" + primitiveWebServer .getPort ());
4132+
4133+ final String [] expectedHeaders = getExpectedAlertsWithHtmlReplacement (primitiveWebServer );
4134+
4135+ final String request = primitiveWebServer .getRequests ().get (1 );
4136+ final String [] headers = request .split ("\\ r\\ n" );
4137+ assertEquals (Arrays .asList (expectedHeaders ).toString (), Arrays .asList (headers ).toString ());
4138+ }
4139+ }
4140+
39904141 /**
39914142 * Tests the Sec-Fetch-* headers sent for an <iframe src> auto-load. Unlike an
39924143 * anchor/form navigation, there is no click or user gesture involved at all here, so
0 commit comments