20
20
import java .net .InetAddress ;
21
21
import java .net .URL ;
22
22
import java .net .UnknownHostException ;
23
+ import java .nio .charset .StandardCharsets ;
23
24
import java .util .ArrayList ;
24
25
import java .util .List ;
25
26
import java .util .Map ;
@@ -152,7 +153,21 @@ public void domain() throws Exception {
152
153
* @throws Exception if the test fails
153
154
*/
154
155
@ Test
155
- @ Alerts ("c1=1; c2=2; c3=3; c4=4" )
156
+ @ Alerts (DEFAULT = {"c1=1; c2=2; c3=3; c4=4" ,
157
+ "c1=1; path=/; domain=.htmlunit.org" ,
158
+ "c2=2; path=/; domain=.htmlunit.org" ,
159
+ "c3=3; path=/; domain=.host1.htmlunit.org" ,
160
+ "c4=4; path=/; domain=.host1.htmlunit.org" },
161
+ FF = {"c1=1; c2=2; c3=3; c4=4" ,
162
+ "c1=1; path=/; domain=.htmlunit.org; sameSite=None" ,
163
+ "c2=2; path=/; domain=.htmlunit.org; sameSite=None" ,
164
+ "c3=3; path=/; domain=.host1.htmlunit.org; sameSite=None" ,
165
+ "c4=4; path=/; domain=.host1.htmlunit.org; sameSite=None" },
166
+ FF_ESR = {"c1=1; c2=2; c3=3; c4=4" ,
167
+ "c1=1; path=/; domain=.htmlunit.org; sameSite=None" ,
168
+ "c2=2; path=/; domain=.htmlunit.org; sameSite=None" ,
169
+ "c3=3; path=/; domain=.host1.htmlunit.org; sameSite=None" ,
170
+ "c4=4; path=/; domain=.host1.htmlunit.org; sameSite=None" })
156
171
public void storedDomain1 () throws Exception {
157
172
final List <NameValuePair > responseHeader = new ArrayList <>();
158
173
responseHeader .add (new NameValuePair ("Set-Cookie" , "c1=1; Domain=." + DOMAIN + "; Path=/" ));
@@ -172,19 +187,26 @@ public void storedDomain1() throws Exception {
172
187
getMockWebConnection ().setDefaultResponse (CookieManagerTest .HTML_ALERT_COOKIE , 200 , "Ok" ,
173
188
MimeType .TEXT_HTML , responseHeader );
174
189
175
- final WebDriver driver = loadPageWithAlerts2 (new URL (URL_HOST1 ));
190
+ final WebDriver driver = loadPage2 (new URL (URL_HOST1 ), StandardCharsets .ISO_8859_1 );
191
+ verifyAlerts (driver , getExpectedAlerts ()[0 ]);
176
192
177
- assertEquals ("c1=1; path=/; domain=.htmlunit.org" , driver .manage ().getCookieNamed ("c1" ).toString ());
178
- assertEquals ("c2=2; path=/; domain=.htmlunit.org" , driver .manage ().getCookieNamed ("c2" ).toString ());
179
- assertEquals ("c3=3; path=/; domain=.host1.htmlunit.org" , driver .manage ().getCookieNamed ("c3" ).toString ());
180
- assertEquals ("c4=4; path=/; domain=.host1.htmlunit.org" , driver .manage ().getCookieNamed ("c4" ).toString ());
193
+ assertEquals (getExpectedAlerts ()[ 1 ] , driver .manage ().getCookieNamed ("c1" ).toString ());
194
+ assertEquals (getExpectedAlerts ()[ 2 ] , driver .manage ().getCookieNamed ("c2" ).toString ());
195
+ assertEquals (getExpectedAlerts ()[ 3 ] , driver .manage ().getCookieNamed ("c3" ).toString ());
196
+ assertEquals (getExpectedAlerts ()[ 4 ] , driver .manage ().getCookieNamed ("c4" ).toString ());
181
197
}
182
198
183
199
/**
184
200
* @throws Exception if the test fails
185
201
*/
186
202
@ Test
187
- @ Alerts ("c1=1; c2=2" )
203
+ @ Alerts (DEFAULT = {"c1=1; c2=2" , "c1=1; path=/; domain=.htmlunit.org" , "c2=2; path=/; domain=.htmlunit.org" },
204
+ FF = {"c1=1; c2=2" ,
205
+ "c1=1; path=/; domain=.htmlunit.org; sameSite=None" ,
206
+ "c2=2; path=/; domain=.htmlunit.org; sameSite=None" },
207
+ FF_ESR = {"c1=1; c2=2" ,
208
+ "c1=1; path=/; domain=.htmlunit.org; sameSite=None" ,
209
+ "c2=2; path=/; domain=.htmlunit.org; sameSite=None" })
188
210
public void storedDomain2 () throws Exception {
189
211
final List <NameValuePair > responseHeader = new ArrayList <>();
190
212
responseHeader .add (new NameValuePair ("Set-Cookie" , "c1=1; Domain=." + DOMAIN + "; Path=/" ));
@@ -204,17 +226,24 @@ public void storedDomain2() throws Exception {
204
226
getMockWebConnection ().setDefaultResponse (CookieManagerTest .HTML_ALERT_COOKIE , 200 , "Ok" ,
205
227
MimeType .TEXT_HTML , responseHeader );
206
228
207
- final WebDriver driver = loadPageWithAlerts2 (new URL (URL_HOST2 ));
229
+ final WebDriver driver = loadPage2 (new URL (URL_HOST2 ), StandardCharsets .ISO_8859_1 );
230
+ verifyAlerts (driver , getExpectedAlerts ()[0 ]);
208
231
209
- assertEquals ("c1=1; path=/; domain=.htmlunit.org" , driver .manage ().getCookieNamed ("c1" ).toString ());
210
- assertEquals ("c2=2; path=/; domain=.htmlunit.org" , driver .manage ().getCookieNamed ("c2" ).toString ());
232
+ assertEquals (getExpectedAlerts ()[ 1 ] , driver .manage ().getCookieNamed ("c1" ).toString ());
233
+ assertEquals (getExpectedAlerts ()[ 2 ] , driver .manage ().getCookieNamed ("c2" ).toString ());
211
234
}
212
235
213
236
/**
214
237
* @throws Exception if the test fails
215
238
*/
216
239
@ Test
217
- @ Alerts ("c1=1; c2=2" )
240
+ @ Alerts (DEFAULT = {"c1=1; c2=2" , "c1=1; path=/; domain=.htmlunit.org" , "c2=2; path=/; domain=.htmlunit.org" },
241
+ FF = {"c1=1; c2=2" ,
242
+ "c1=1; path=/; domain=.htmlunit.org; sameSite=None" ,
243
+ "c2=2; path=/; domain=.htmlunit.org; sameSite=None" },
244
+ FF_ESR = {"c1=1; c2=2" ,
245
+ "c1=1; path=/; domain=.htmlunit.org; sameSite=None" ,
246
+ "c2=2; path=/; domain=.htmlunit.org; sameSite=None" })
218
247
public void storedDomain3 () throws Exception {
219
248
final List <NameValuePair > responseHeader = new ArrayList <>();
220
249
responseHeader .add (new NameValuePair ("Set-Cookie" , "c1=1; Domain=." + DOMAIN + "; Path=/" ));
@@ -234,19 +263,26 @@ public void storedDomain3() throws Exception {
234
263
getMockWebConnection ().setDefaultResponse (CookieManagerTest .HTML_ALERT_COOKIE , 200 , "Ok" ,
235
264
MimeType .TEXT_HTML , responseHeader );
236
265
237
- final WebDriver driver = loadPageWithAlerts2 (new URL (URL_HOST3 ));
266
+ final WebDriver driver = loadPage2 (new URL (URL_HOST3 ), StandardCharsets .ISO_8859_1 );
267
+ verifyAlerts (driver , getExpectedAlerts ()[0 ]);
238
268
239
- assertEquals ("c1=1; path=/; domain=.htmlunit.org" , driver .manage ().getCookieNamed ("c1" ).toString ());
240
- assertEquals ("c2=2; path=/; domain=.htmlunit.org" , driver .manage ().getCookieNamed ("c2" ).toString ());
269
+ assertEquals (getExpectedAlerts ()[ 1 ] , driver .manage ().getCookieNamed ("c1" ).toString ());
270
+ assertEquals (getExpectedAlerts ()[ 2 ] , driver .manage ().getCookieNamed ("c2" ).toString ());
241
271
}
242
272
243
273
/**
244
274
* @throws Exception if the test fails
245
275
*/
246
276
@ Test
247
- @ Alerts (DEFAULT = "c11=11; c12=12" ,
248
- CHROME = "c12=12" ,
249
- EDGE = "c12=12" )
277
+ @ Alerts (CHROME = {"c12=12" , "c12=12; path=/; domain=htmlunit" , "c11=11; path=/; domain=htmlunit" },
278
+ EDGE = {"c12=12" , "c12=12; path=/; domain=htmlunit" , "c11=11; path=/; domain=htmlunit" },
279
+ FF = {"c11=11; c12=12" ,
280
+ "c12=12; path=/; domain=htmlunit; sameSite=None" ,
281
+ "c11=11; path=/; domain=htmlunit; sameSite=None" },
282
+ FF_ESR = {"c11=11; c12=12" ,
283
+ "c12=12; path=/; domain=htmlunit; sameSite=None" ,
284
+ "c11=11; path=/; domain=htmlunit; sameSite=None" },
285
+ IE = {"c11=11; c12=12" , "c12=12; path=/; domain=htmlunit" , "c11=11; path=/; domain=htmlunit" })
250
286
public void storedDomain4 () throws Exception {
251
287
final List <NameValuePair > responseHeader = new ArrayList <>();
252
288
responseHeader .add (new NameValuePair ("Set-Cookie" , "c1=1; Domain=." + DOMAIN + "; Path=/" ));
@@ -266,18 +302,29 @@ public void storedDomain4() throws Exception {
266
302
getMockWebConnection ().setDefaultResponse (CookieManagerTest .HTML_ALERT_COOKIE , 200 , "Ok" ,
267
303
MimeType .TEXT_HTML , responseHeader );
268
304
269
- final WebDriver driver = loadPageWithAlerts2 (new URL (URL_HOST4 ));
305
+ final WebDriver driver = loadPage2 (new URL (URL_HOST4 ), StandardCharsets .ISO_8859_1 );
306
+ verifyAlerts (driver , getExpectedAlerts ()[0 ]);
270
307
271
- assertEquals ("c12=12; path=/; domain=htmlunit" , driver .manage ().getCookieNamed ("c12" ).toString ());
308
+ assertEquals (getExpectedAlerts ()[ 1 ] , driver .manage ().getCookieNamed ("c12" ).toString ());
272
309
if (driver .manage ().getCookieNamed ("c11" ) != null ) {
273
- assertEquals ("c11=11; path=/; domain=htmlunit" , driver .manage ().getCookieNamed ("c11" ).toString ());
310
+ assertEquals (getExpectedAlerts ()[ 2 ] , driver .manage ().getCookieNamed ("c11" ).toString ());
274
311
}
275
312
}
276
313
277
314
/**
278
315
* @throws Exception if the test fails
279
316
*/
280
317
@ Test
318
+ @ Alerts (DEFAULT = {"c1=1; path=/; domain=.htmlunit.org" , "c2=2; path=/; domain=.htmlunit.org" ,
319
+ "c3=3; path=/; domain=.host1.htmlunit.org" , "c4=4; path=/; domain=.host1.htmlunit.org" },
320
+ FF = {"c1=1; path=/; domain=.htmlunit.org; sameSite=None" ,
321
+ "c2=2; path=/; domain=.htmlunit.org; sameSite=None" ,
322
+ "c3=3; path=/; domain=.host1.htmlunit.org; sameSite=None" ,
323
+ "c4=4; path=/; domain=.host1.htmlunit.org; sameSite=None" },
324
+ FF_ESR = {"c1=1; path=/; domain=.htmlunit.org; sameSite=None" ,
325
+ "c2=2; path=/; domain=.htmlunit.org; sameSite=None" ,
326
+ "c3=3; path=/; domain=.host1.htmlunit.org; sameSite=None" ,
327
+ "c4=4; path=/; domain=.host1.htmlunit.org; sameSite=None" })
281
328
public void storedDomainFromJs1 () throws Exception {
282
329
final String html = "<html>\n "
283
330
+ "<head>\n "
@@ -301,19 +348,25 @@ public void storedDomainFromJs1() throws Exception {
301
348
+ "</body>\n "
302
349
+ "</html>" ;
303
350
304
- final WebDriver driver = loadPageWithAlerts2 (html , new URL (URL_HOST1 ));
351
+ final WebDriver driver = loadPage2 (html , new URL (URL_HOST1 ));
352
+ verifyAlerts (driver );
305
353
306
354
assertEquals (4 , driver .manage ().getCookies ().size ());
307
- assertEquals ("c1=1; path=/; domain=.htmlunit.org" , driver .manage ().getCookieNamed ("c1" ).toString ());
308
- assertEquals ("c2=2; path=/; domain=.htmlunit.org" , driver .manage ().getCookieNamed ("c2" ).toString ());
309
- assertEquals ("c3=3; path=/; domain=.host1.htmlunit.org" , driver .manage ().getCookieNamed ("c3" ).toString ());
310
- assertEquals ("c4=4; path=/; domain=.host1.htmlunit.org" , driver .manage ().getCookieNamed ("c4" ).toString ());
355
+ assertEquals (getExpectedAlerts ()[ 0 ] , driver .manage ().getCookieNamed ("c1" ).toString ());
356
+ assertEquals (getExpectedAlerts ()[ 1 ] , driver .manage ().getCookieNamed ("c2" ).toString ());
357
+ assertEquals (getExpectedAlerts ()[ 2 ] , driver .manage ().getCookieNamed ("c3" ).toString ());
358
+ assertEquals (getExpectedAlerts ()[ 3 ] , driver .manage ().getCookieNamed ("c4" ).toString ());
311
359
}
312
360
313
361
/**
314
362
* @throws Exception if the test fails
315
363
*/
316
364
@ Test
365
+ @ Alerts (DEFAULT = {"c1=1; path=/; domain=.htmlunit.org" , "c2=2; path=/; domain=.htmlunit.org" },
366
+ FF = {"c1=1; path=/; domain=.htmlunit.org; sameSite=None" ,
367
+ "c2=2; path=/; domain=.htmlunit.org; sameSite=None" },
368
+ FF_ESR = {"c1=1; path=/; domain=.htmlunit.org; sameSite=None" ,
369
+ "c2=2; path=/; domain=.htmlunit.org; sameSite=None" })
317
370
public void storedDomainFromJs2 () throws Exception {
318
371
final String html = "<html>\n "
319
372
+ "<head>\n "
@@ -337,17 +390,23 @@ public void storedDomainFromJs2() throws Exception {
337
390
+ "</body>\n "
338
391
+ "</html>" ;
339
392
340
- final WebDriver driver = loadPageWithAlerts2 (html , new URL (URL_HOST2 ));
393
+ final WebDriver driver = loadPage2 (html , new URL (URL_HOST2 ));
394
+ verifyAlerts (driver );
341
395
342
396
assertEquals (2 , driver .manage ().getCookies ().size ());
343
- assertEquals ("c1=1; path=/; domain=.htmlunit.org" , driver .manage ().getCookieNamed ("c1" ).toString ());
344
- assertEquals ("c2=2; path=/; domain=.htmlunit.org" , driver .manage ().getCookieNamed ("c2" ).toString ());
397
+ assertEquals (getExpectedAlerts ()[ 0 ] , driver .manage ().getCookieNamed ("c1" ).toString ());
398
+ assertEquals (getExpectedAlerts ()[ 1 ] , driver .manage ().getCookieNamed ("c2" ).toString ());
345
399
}
346
400
347
401
/**
348
402
* @throws Exception if the test fails
349
403
*/
350
404
@ Test
405
+ @ Alerts (DEFAULT = {"c1=1; path=/; domain=.htmlunit.org" , "c2=2; path=/; domain=.htmlunit.org" },
406
+ FF = {"c1=1; path=/; domain=.htmlunit.org; sameSite=None" ,
407
+ "c2=2; path=/; domain=.htmlunit.org; sameSite=None" },
408
+ FF_ESR = {"c1=1; path=/; domain=.htmlunit.org; sameSite=None" ,
409
+ "c2=2; path=/; domain=.htmlunit.org; sameSite=None" })
351
410
public void storedDomainFromJs3 () throws Exception {
352
411
final String html = "<html>\n "
353
412
+ "<head>\n "
@@ -371,20 +430,27 @@ public void storedDomainFromJs3() throws Exception {
371
430
+ "</body>\n "
372
431
+ "</html>" ;
373
432
374
- final WebDriver driver = loadPageWithAlerts2 (html , new URL (URL_HOST3 ));
433
+ final WebDriver driver = loadPage2 (html , new URL (URL_HOST3 ));
434
+ verifyAlerts (driver );
375
435
376
436
assertEquals (2 , driver .manage ().getCookies ().size ());
377
- assertEquals ("c1=1; path=/; domain=.htmlunit.org" , driver .manage ().getCookieNamed ("c1" ).toString ());
378
- assertEquals ("c2=2; path=/; domain=.htmlunit.org" , driver .manage ().getCookieNamed ("c2" ).toString ());
437
+ assertEquals (getExpectedAlerts ()[ 0 ] , driver .manage ().getCookieNamed ("c1" ).toString ());
438
+ assertEquals (getExpectedAlerts ()[ 1 ] , driver .manage ().getCookieNamed ("c2" ).toString ());
379
439
}
380
440
381
441
/**
382
442
* @throws Exception if the test fails
383
443
*/
384
444
@ Test
385
- @ Alerts (DEFAULT = {"2" , "c12=12; path=/; domain=htmlunit" , "c11=11; path=/; domain=htmlunit" },
386
- CHROME = {"1" , "c12=12; path=/; domain=htmlunit" },
387
- EDGE = {"1" , "c12=12; path=/; domain=htmlunit" })
445
+ @ Alerts (CHROME = {"1" , "c12=12; path=/; domain=htmlunit" },
446
+ EDGE = {"1" , "c12=12; path=/; domain=htmlunit" },
447
+ FF = {"2" ,
448
+ "c12=12; path=/; domain=htmlunit; sameSite=None" ,
449
+ "c11=11; path=/; domain=htmlunit; sameSite=None" },
450
+ FF_ESR = {"2" ,
451
+ "c12=12; path=/; domain=htmlunit; sameSite=None" ,
452
+ "c11=11; path=/; domain=htmlunit; sameSite=None" },
453
+ IE = {"2" , "c12=12; path=/; domain=htmlunit" , "c11=11; path=/; domain=htmlunit" })
388
454
public void storedDomainFromJs4 () throws Exception {
389
455
final String html = "<html>\n "
390
456
+ "<head>\n "
@@ -409,6 +475,7 @@ public void storedDomainFromJs4() throws Exception {
409
475
+ "</html>" ;
410
476
411
477
final WebDriver driver = loadPage2 (html , new URL (URL_HOST4 ));
478
+ verifyAlerts (driver );
412
479
413
480
final String [] expected = getExpectedAlerts ();
414
481
assertEquals (Integer .parseInt (expected [0 ]), driver .manage ().getCookies ().size ());
0 commit comments