@@ -94,25 +94,50 @@ public void orderFromServer() throws Exception {
9494 * @throws Exception if the test fails
9595 */
9696 @ Test
97+ @ Alerts ({"b=2; a=1" ,
98+ "c=1; d=2" ,
99+ "lA=2; lB=3; sA=1; sB=4" })
97100 public void orderCookiesByPath_fromJs () throws Exception {
98101 final String html = DOCTYPE_HTML
99- + "<html><body><script>\n "
100- + "document.cookie = 'exampleCookie=rootPath;path=/';\n "
101- + "document.cookie = 'exampleCookie=currentPath;path=/testpages/';\n "
102- + "</script>\n "
102+ + "<html><head><script>\n "
103+ + LOG_TITLE_FUNCTION
104+ + " function clear(n, p) {\n "
105+ + " document.cookie = n + '=; path=' + p + '; max-age=0';\n "
106+ + " }\n "
107+ + " function test() {\n "
108+ + " document.cookie = 'a=1; path=/';\n "
109+ + " document.cookie = 'b=2; path=/testpages';\n "
110+ + " log(document.cookie);\n "
111+ + " clear('a', '/'); clear('b', '/testpages');\n "
112+ + " document.cookie = 'c=1; path=/testpages';\n "
113+ + " document.cookie = 'd=2; path=/testpages';\n "
114+ + " log(document.cookie);\n "
115+ + " clear('c', '/testpages'); clear('d', '/testpages');\n "
116+ + " document.cookie = 'sA=1; path=/';\n "
117+ + " document.cookie = 'lA=2; path=/testpages';\n "
118+ + " document.cookie = 'lB=3; path=/testpages';\n "
119+ + " document.cookie = 'sB=4; path=/';\n "
120+ + " log(document.cookie);\n "
121+ + " }\n "
122+ + "</script></head>\n "
123+ + "<body onload='test()'>\n "
103124 + "<a href='/testpages/next.html'>next page</a>\n "
104125 + "</body></html>" ;
105126
127+ final URL pageUrl = new URL (URL_FIRST , "testpages/test.html" );
128+ getMockWebConnection ().setResponse (pageUrl , html );
106129 getMockWebConnection ().setDefaultResponse ("" );
107130
108131 final WebDriver webDriver = getWebDriver ();
109132 webDriver .manage ().deleteAllCookies ();
110133
111- loadPage2 (html );
134+ loadPage2 (pageUrl , StandardCharsets .ISO_8859_1 );
135+ verifyTitle2 (getWebDriver (), getExpectedAlerts ());
136+
112137 webDriver .findElement (By .linkText ("next page" )).click ();
113138
114139 final WebRequest lastRequest = getMockWebConnection ().getLastWebRequest ();
115- assertEquals ("exampleCookie=currentPath; exampleCookie=rootPath " ,
140+ assertEquals ("lA=2; lB=3; sA=1; sB=4 " ,
116141 lastRequest .getAdditionalHeaders ().get (HttpHeader .COOKIE ));
117142 }
118143
0 commit comments