1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript;
16
17 import java.util.TimeZone;
18
19 import org.htmlunit.BrowserVersion;
20 import org.htmlunit.WebDriverTestCase;
21 import org.htmlunit.junit.BrowserRunner;
22 import org.htmlunit.junit.annotation.Alerts;
23 import org.htmlunit.junit.annotation.BuggyWebDriver;
24 import org.htmlunit.junit.annotation.HtmlUnitNYI;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27
28
29
30
31
32
33 @RunWith(BrowserRunner.class)
34 public class NativeDate2Test extends WebDriverTestCase {
35
36
37
38
39 @Test
40 @Alerts("2021-12-18T22:23:00.000Z")
41 public void ctorDateTimeStringGMT() throws Exception {
42 ctorDateTimeString("new Date('2021-12-18T22:23:00.000+00:00').toISOString()");
43 }
44
45
46
47
48 @Test
49 @Alerts("2021-12-18T22:23:00.000Z")
50 public void ctorDateTimeStringGMT2() throws Exception {
51 ctorDateTimeString("new Date('Sat, 18 Dec 2021 22:23:00 GMT').toISOString()");
52 }
53
54
55
56
57 @Test
58 @Alerts("2021-12-18T22:23:00.000Z")
59 public void ctorDateTimeStringUTC() throws Exception {
60 ctorDateTimeString("new Date('2021-12-18T22:23:00.000+00:00').toISOString()");
61 }
62
63
64
65
66 @Test
67 @Alerts("2021-12-18T22:23:00.000Z")
68 public void ctorDateTimeStringUTC2() throws Exception {
69 ctorDateTimeString("new Date('Sat, 18 Dec 2021 22:23:00 UTC').toISOString()");
70 }
71
72
73
74
75 @Test
76 @Alerts("2021-12-18T22:23:00.000Z")
77 public void ctorDateTimeStringUT() throws Exception {
78 ctorDateTimeString("new Date('Sat, 18 Dec 2021 22:23:00 UT').toISOString()");
79 }
80
81
82
83
84 @Test
85 @Alerts("2021-12-18T12:23:00.000Z")
86 public void ctorDateTimeStringEST() throws Exception {
87 ctorDateTimeString("new Date('2021-12-18T17:23:00.000+05:00').toISOString()");
88 }
89
90
91
92
93 @Test
94 @Alerts("2021-12-19T03:23:00.000Z")
95 public void ctorDateTimeStringEST2() throws Exception {
96 ctorDateTimeString("new Date('Sat, 18 Dec 2021 22:23:00 EST').toISOString()");
97 }
98
99
100
101
102 @Test
103 @Alerts("2021-12-19T02:23:00.000Z")
104 public void ctorDateTimeStringEDT() throws Exception {
105 ctorDateTimeString("new Date('Sat, 18 Dec 2021 22:23:00 EDT').toISOString()");
106 }
107
108
109
110
111 @Test
112 @Alerts("2021-12-19T04:23:00.000Z")
113 public void ctorDateTimeStringCST() throws Exception {
114 ctorDateTimeString("new Date('Sat, 18 Dec 2021 22:23:00 CST').toISOString()");
115 }
116
117
118
119
120 @Test
121 @Alerts("2021-12-19T03:23:00.000Z")
122 public void ctorDateTimeStringCDT() throws Exception {
123 ctorDateTimeString("new Date('Sat, 18 Dec 2021 22:23:00 CDT').toISOString()");
124 }
125
126
127
128
129 @Test
130 @Alerts("2021-12-19T05:23:00.000Z")
131 public void ctorDateTimeStringMST() throws Exception {
132 ctorDateTimeString("new Date('Sat, 18 Dec 2021 22:23:00 MST').toISOString()");
133 }
134
135
136
137
138 @Test
139 @Alerts("2021-12-19T04:23:00.000Z")
140 public void ctorDateTimeStringMDT() throws Exception {
141 ctorDateTimeString("new Date('Sat, 18 Dec 2021 22:23:00 MDT').toISOString()");
142 }
143
144
145
146
147 @Test
148 @Alerts("2021-12-19T06:23:00.000Z")
149 public void ctorDateTimeStringPST() throws Exception {
150 ctorDateTimeString("new Date('Sat, 18 Dec 2021 22:23:00 PST').toISOString()");
151 }
152
153
154
155
156 @Test
157 @Alerts("2021-12-19T05:23:00.000Z")
158 public void ctorDateTimeStringPDT() throws Exception {
159 ctorDateTimeString("new Date('Sat, 18 Dec 2021 22:23:00 PDT').toISOString()");
160 }
161
162
163
164
165 @Test
166 @Alerts("2021-12-18T18:23:00.000Z")
167 public void ctorDateTimeStringBerlin() throws Exception {
168 ctorDateTimeString("new Date('2021-12-18T17:23:00.000-01:00').toISOString()");
169 }
170
171
172
173
174 @Test
175 @Alerts("2021-12-19T02:23:00.000Z")
176 public void ctorDateTimeStringTokyo() throws Exception {
177 ctorDateTimeString("new Date('2021-12-18T17:23:00.000-09:00').toISOString()");
178 }
179
180
181
182
183 @Test
184 @Alerts("2021-12-19T02:23:00.000Z")
185 public void ctorDateTimeStringJST() throws Exception {
186 ctorDateTimeString("new Date('2021-12-18T17:23:00.000-09:00').toISOString()");
187 }
188
189
190
191
192 @Test
193 @Alerts("2021-12-18T12:23:00.000Z")
194 public void ctorDateTimeStringNewYork() throws Exception {
195 ctorDateTimeString("new Date('2021-12-18T17:23:00.000+05:00').toISOString()");
196 }
197
198 private void ctorDateTimeString(final String js) throws Exception {
199 final String html = DOCTYPE_HTML
200 + "<html><body><script>\n"
201 + LOG_TITLE_FUNCTION
202 + "log(" + js + ");\n"
203 + "</script>\n"
204 + "</body></html>";
205
206 loadPageVerifyTitle2(html);
207 }
208
209
210
211
212 @Test
213 @Alerts("2021-12-18T22:23:00.000Z")
214 @BuggyWebDriver(FF = "2021-12-18T21:23:00.000Z",
215 FF_ESR = "2021-12-18T21:23:00.000Z")
216 public void ctorDateTimeGMT() throws Exception {
217 ctorDateTime("GMT");
218 }
219
220
221
222
223 @Test
224 @Alerts("2021-12-18T22:23:00.000Z")
225 @BuggyWebDriver(FF = "2021-12-18T21:23:00.000Z",
226 FF_ESR = "2021-12-18T21:23:00.000Z")
227 public void ctorDateTimeUTC() throws Exception {
228 ctorDateTime("UTC");
229 }
230
231
232
233
234 @Test
235 @Alerts("2021-12-19T03:23:00.000Z")
236 @BuggyWebDriver(FF = "2021-12-18T21:23:00.000Z",
237 FF_ESR = "2021-12-18T21:23:00.000Z")
238 public void ctorDateTimeEST() throws Exception {
239 ctorDateTime("EST");
240 }
241
242
243
244
245 @Test
246 @Alerts("2021-12-18T21:23:00.000Z")
247 public void ctorDateTimeBerlin() throws Exception {
248 ctorDateTime("Europe/Berlin");
249 }
250
251
252
253
254 @Test
255 @Alerts("2021-12-18T13:23:00.000Z")
256 @BuggyWebDriver(FF = "2021-12-18T21:23:00.000Z",
257 FF_ESR = "2021-12-18T21:23:00.000Z")
258 public void ctorDateTimeTokyo() throws Exception {
259 ctorDateTime("Asia/Tokyo");
260 }
261
262
263
264
265 @Test
266 @Alerts("2021-12-18T13:23:00.000Z")
267 @BuggyWebDriver(FF = "2021-12-18T21:23:00.000Z",
268 FF_ESR = "2021-12-18T21:23:00.000Z")
269 public void ctorDateTimeJST() throws Exception {
270 ctorDateTime("JST");
271 }
272
273
274
275
276 @Test
277 @Alerts("2021-12-19T03:23:00.000Z")
278 @BuggyWebDriver(FF = "2021-12-18T21:23:00.000Z",
279 FF_ESR = "2021-12-18T21:23:00.000Z")
280 public void ctorDateTimeNewYork() throws Exception {
281 ctorDateTime("America/New_York");
282 }
283
284 private void ctorDateTime(final String tz) throws Exception {
285 final String html = DOCTYPE_HTML
286 + "<html><body><script>\n"
287 + LOG_TITLE_FUNCTION
288 + "log(new Date('2021-12-18T22:23').toISOString());\n"
289 + "</script>\n"
290 + "</body></html>";
291
292 shutDownAll();
293 try {
294 final BrowserVersion.BrowserVersionBuilder builder
295 = new BrowserVersion.BrowserVersionBuilder(getBrowserVersion());
296 builder.setSystemTimezone(TimeZone.getTimeZone(tz));
297 setBrowserVersion(builder.build());
298
299 loadPageVerifyTitle2(html);
300 }
301 finally {
302 shutDownAll();
303 }
304 }
305
306
307
308
309 @Test
310 @Alerts("2021-12-18T00:00:00.000Z")
311 public void ctorDateGMT() throws Exception {
312 ctorDate("GMT");
313 }
314
315
316
317
318 @Test
319 @Alerts("2021-12-18T00:00:00.000Z")
320 public void ctorDateUTC() throws Exception {
321 ctorDate("UTC");
322 }
323
324
325
326
327 @Test
328 @Alerts("2021-12-18T00:00:00.000Z")
329 public void ctorDateEST() throws Exception {
330 ctorDate("EST");
331 }
332
333
334
335
336 @Test
337 @Alerts("2021-12-18T00:00:00.000Z")
338 public void ctorDateBerlin() throws Exception {
339 ctorDate("Europe/Berlin");
340 }
341
342
343
344
345 @Test
346 @Alerts("2021-12-18T00:00:00.000Z")
347 public void ctorDateNewYork() throws Exception {
348 ctorDate("America/New_York");
349 }
350
351
352
353
354 @Test
355 @Alerts("2021-12-18T00:00:00.000Z")
356 public void ctorDateTokyo() throws Exception {
357 ctorDate("Asia/Tokyo");
358 }
359
360
361
362
363 @Test
364 @Alerts("2021-12-18T00:00:00.000Z")
365 public void ctorDateJST() throws Exception {
366 ctorDate("JST");
367 }
368
369 private void ctorDate(final String tz) throws Exception {
370 final String html = DOCTYPE_HTML
371 + "<html><body><script>\n"
372 + LOG_TITLE_FUNCTION
373 + "log(new Date('2021-12-18').toISOString());\n"
374 + "</script>\n"
375 + "</body></html>";
376
377 shutDownAll();
378 try {
379 final BrowserVersion.BrowserVersionBuilder builder
380 = new BrowserVersion.BrowserVersionBuilder(getBrowserVersion());
381 builder.setSystemTimezone(TimeZone.getTimeZone(tz));
382 setBrowserVersion(builder.build());
383
384 loadPageVerifyTitle2(html);
385 }
386 finally {
387 shutDownAll();
388 }
389 }
390
391
392
393
394 @Test
395 @Alerts("2000-02-28T23:59:59.000Z")
396 public void ctorInt() throws Exception {
397 final String html = DOCTYPE_HTML
398 + "<html><body><script>\n"
399 + LOG_TITLE_FUNCTION
400 + "log(new Date(951782399000).toISOString());\n"
401 + "</script>\n"
402 + "</body></html>";
403
404 loadPageVerifyTitle2(html);
405 }
406
407
408
409
410 @Test
411 @Alerts("2035-11-30T01:46:40.000Z")
412 public void ctorDouble() throws Exception {
413 final String html = DOCTYPE_HTML
414 + "<html><body><script>\n"
415 + LOG_TITLE_FUNCTION
416 + "log(new Date(208e10).toISOString());\n"
417 + "</script>\n"
418 + "</body></html>";
419
420 loadPageVerifyTitle2(html);
421 }
422
423
424
425
426 @Test
427 @Alerts("12/18/2021, 10:23:00 PM")
428 @HtmlUnitNYI(CHROME = "12/18/21, 10:23 PM",
429 EDGE = "12/18/21, 10:23 PM",
430 FF = "12/18/21, 10:23 PM",
431 FF_ESR = "12/18/21, 10:23 PM")
432 public void toLocaleEnUs() throws Exception {
433 toLocale("new Date('2021-12-18T22:23').toLocaleString('en-US')");
434 }
435
436
437
438
439 @Test
440 @Alerts("12/18/2021")
441 @HtmlUnitNYI(CHROME = "12/18/21",
442 EDGE = "12/18/21",
443 FF = "12/18/21",
444 FF_ESR = "12/18/21")
445 public void toLocaleEnUsDate() throws Exception {
446 toLocale("new Date('2021-12-18T22:23').toLocaleDateString('en-US')");
447 }
448
449
450
451
452 @Test
453 @Alerts("10:23:00 PM")
454 @HtmlUnitNYI(CHROME = "10:23 PM",
455 EDGE = "10:23 PM",
456 FF = "10:23 PM",
457 FF_ESR = "10:23 PM")
458 public void toLocaleEnUsTime() throws Exception {
459 toLocale("new Date('2021-12-18T22:23').toLocaleTimeString('en-US')");
460 }
461
462
463
464
465 @Test
466 @Alerts("18.12.2021, 22:23:00")
467 @HtmlUnitNYI(CHROME = "18.12.21, 22:23",
468 EDGE = "18.12.21, 22:23",
469 FF = "18.12.21, 22:23",
470 FF_ESR = "18.12.21, 22:23")
471 public void toLocaleDeDe() throws Exception {
472 toLocale("new Date('2021-12-18T22:23').toLocaleString('de-DE')");
473 }
474
475
476
477
478 @Test
479 @Alerts("18.12.2021")
480 @HtmlUnitNYI(CHROME = "18.12.21",
481 EDGE = "18.12.21",
482 FF = "18.12.21",
483 FF_ESR = "18.12.21")
484 public void toLocaleDeDeDate() throws Exception {
485 toLocale("new Date('2021-12-18T22:23').toLocaleDateString('de-DE')");
486 }
487
488
489
490
491 @Test
492 @Alerts("22:23:00")
493 @HtmlUnitNYI(CHROME = "22:23",
494 EDGE = "22:23",
495 FF = "22:23",
496 FF_ESR = "22:23")
497 public void toLocaleDeDeTime() throws Exception {
498 toLocale("new Date('2021-12-18T22:23').toLocaleTimeString('de-DE')");
499 }
500
501
502
503
504 @Test
505 @Alerts("2021/12/18 22:23:00")
506 @HtmlUnitNYI(CHROME = "2021/12/18 22:23",
507 EDGE = "2021/12/18 22:23",
508 FF = "2021/12/18 22:23",
509 FF_ESR = "2021/12/18 22:23")
510 public void toLocaleJaJp() throws Exception {
511 toLocale("new Date('2021-12-18T22:23').toLocaleString('ja-JP')");
512 }
513
514
515
516
517 @Test
518 @Alerts("2021/12/18")
519 public void toLocaleJaJpDate() throws Exception {
520 toLocale("new Date('2021-12-18T22:23').toLocaleDateString('ja-JP')");
521 }
522
523
524
525
526 @Test
527 @Alerts("22:23:00")
528 @HtmlUnitNYI(CHROME = "22:23",
529 EDGE = "22:23",
530 FF = "22:23",
531 FF_ESR = "22:23")
532 public void toLocaleJaJpTime() throws Exception {
533 toLocale("new Date('2021-12-18T22:23').toLocaleTimeString('ja-JP')");
534 }
535
536
537
538
539 @Test
540 @Alerts("2021/12/18 22:23:00")
541 @HtmlUnitNYI(CHROME = "2021/12/18 22:23",
542 EDGE = "2021/12/18 22:23",
543 FF = "2021/12/18 22:23",
544 FF_ESR = "2021/12/18 22:23")
545 public void toLocaleArray() throws Exception {
546 toLocale("new Date('2021-12-18T22:23').toLocaleString(['foo', 'ja-JP', 'en-US'])");
547 }
548
549
550
551
552 @Test
553 @Alerts("2021/12/18")
554 public void toLocaleArrayDate() throws Exception {
555 toLocale("new Date('2021-12-18T22:23').toLocaleDateString(['foo', 'ja-JP', 'en-US'])");
556 }
557
558
559
560
561 @Test
562 @Alerts("22:23:00")
563 @HtmlUnitNYI(CHROME = "22:23",
564 EDGE = "22:23",
565 FF = "22:23",
566 FF_ESR = "22:23")
567 public void toLocaleArrayTime() throws Exception {
568 toLocale("new Date('2021-12-18T22:23').toLocaleTimeString(['foo', 'ja-JP', 'en-US'])");
569 }
570
571 private void toLocale(final String js) throws Exception {
572 final String html = DOCTYPE_HTML
573 + "<html><body><script>\n"
574 + LOG_TITLE_FUNCTION
575 + "log(" + js + ");\n"
576 + "</script>\n"
577 + "</body></html>";
578
579 shutDownAll();
580 try {
581 final BrowserVersion.BrowserVersionBuilder builder
582 = new BrowserVersion.BrowserVersionBuilder(getBrowserVersion());
583 builder.setSystemTimezone(TimeZone.getTimeZone("GMT"));
584 setBrowserVersion(builder.build());
585
586 loadPageVerifyTitle2(html);
587 }
588 finally {
589 shutDownAll();
590 }
591 }
592
593
594
595
596 @Test
597 @Alerts("Sat Dec 18 2021")
598 public void toDateStringGMT() throws Exception {
599 toDateString("GMT");
600 }
601
602
603
604
605 @Test
606 @Alerts("Sat Dec 18 2021")
607 public void toDateStringUTC() throws Exception {
608 toDateString("UTC");
609 }
610
611
612
613
614 @Test
615 @Alerts("Sat Dec 18 2021")
616 public void toDateStringEST() throws Exception {
617 toDateString("EST");
618 }
619
620
621
622
623 @Test
624 @Alerts("Sat Dec 18 2021")
625 public void toDateStringBerlin() throws Exception {
626 toDateString("Europe/Berlin");
627 }
628
629
630
631
632 @Test
633 @Alerts("Sat Dec 18 2021")
634 public void toDateStringNewYork() throws Exception {
635 toDateString("America/New_York");
636 }
637
638
639
640
641 @Test
642 @Alerts("Sun Dec 19 2021")
643 @BuggyWebDriver(FF = "Sat Dec 18 2021",
644 FF_ESR = "Sat Dec 18 2021")
645 public void toDateStringTokyo() throws Exception {
646 toDateString("Asia/Tokyo");
647 }
648
649
650
651
652 @Test
653 @Alerts("Sun Dec 19 2021")
654 @BuggyWebDriver(FF = "Sat Dec 18 2021",
655 FF_ESR = "Sat Dec 18 2021")
656 public void toDateStringJST() throws Exception {
657 toDateString("JST");
658 }
659
660 private void toDateString(final String tz) throws Exception {
661 final String html = DOCTYPE_HTML
662 + "<html><body><script>\n"
663 + LOG_TITLE_FUNCTION
664 + "log(new Date('Sat, 18 Dec 2021 22:23:00 UTC').toDateString());\n"
665 + "</script>\n"
666 + "</body></html>";
667
668 shutDownAll();
669 try {
670 final BrowserVersion.BrowserVersionBuilder builder
671 = new BrowserVersion.BrowserVersionBuilder(getBrowserVersion());
672 builder.setSystemTimezone(TimeZone.getTimeZone(tz));
673 setBrowserVersion(builder.build());
674
675 loadPageVerifyTitle2(html);
676 }
677 finally {
678 shutDownAll();
679 }
680 }
681
682
683
684
685 @Test
686 @Alerts("22:23:00 GMT+0000 (Greenwich Mean Time)")
687 @BuggyWebDriver(FF = "23:23:00 GMT+0100 (Central European Standard Time)",
688 FF_ESR = "23:23:00 GMT+0100 (Central European Standard Time)")
689 @HtmlUnitNYI(CHROME = "22:23:00 GMT-0000 (GMT)",
690 EDGE = "22:23:00 GMT-0000 (GMT)",
691 FF = "22:23:00 GMT-0000 (GMT)",
692 FF_ESR = "22:23:00 GMT-0000 (GMT)")
693 public void toTimeStringGMT() throws Exception {
694 toTimeString("GMT");
695 }
696
697
698
699
700 @Test
701 @Alerts("22:23:00 GMT+0000 (Coordinated Universal Time)")
702 @BuggyWebDriver(FF = "23:23:00 GMT+0100 (Central European Standard Time)",
703 FF_ESR = "23:23:00 GMT+0100 (Central European Standard Time)")
704 @HtmlUnitNYI(CHROME = "22:23:00 GMT-0000 (UTC)",
705 EDGE = "22:23:00 GMT-0000 (UTC)",
706 FF = "22:23:00 GMT-0000 (UTC)",
707 FF_ESR = "22:23:00 GMT-0000 (UTC)")
708 public void toTimeStringUTC() throws Exception {
709 toTimeString("UTC");
710 }
711
712
713
714
715 @Test
716 @Alerts("17:23:00 GMT-0500 (Eastern Standard Time)")
717 @BuggyWebDriver(FF = "23:23:00 GMT+0100 (Central European Standard Time)",
718 FF_ESR = "23:23:00 GMT+0100 (Central European Standard Time)")
719 @HtmlUnitNYI(CHROME = "17:23:00 GMT-0500 (-05:00)",
720 EDGE = "17:23:00 GMT-0500 (-05:00)",
721 FF = "17:23:00 GMT-0500 (-05:00)",
722 FF_ESR = "17:23:00 GMT-0500 (-05:00)")
723 public void toTimeStringEST() throws Exception {
724 toTimeString("EST");
725 }
726
727
728
729
730 @Test
731 @Alerts("23:23:00 GMT+0100 (Central European Standard Time)")
732 @HtmlUnitNYI(CHROME = "23:23:00 GMT+0100 (CET)",
733 EDGE = "23:23:00 GMT+0100 (CET)",
734 FF = "23:23:00 GMT+0100 (CET)",
735 FF_ESR = "23:23:00 GMT+0100 (CET)")
736 public void toTimeStringBerlin() throws Exception {
737 toTimeString("Europe/Berlin");
738 }
739
740
741
742
743 @Test
744 @Alerts("17:23:00 GMT-0500 (Eastern Standard Time)")
745 @BuggyWebDriver(FF = "23:23:00 GMT+0100 (Central European Standard Time)",
746 FF_ESR = "23:23:00 GMT+0100 (Central European Standard Time)")
747 @HtmlUnitNYI(CHROME = "17:23:00 GMT-0500 (EST)",
748 EDGE = "17:23:00 GMT-0500 (EST)",
749 FF = "17:23:00 GMT-0500 (EST)",
750 FF_ESR = "17:23:00 GMT-0500 (EST)")
751 public void toTimeStringNewYork() throws Exception {
752 toTimeString("America/New_York");
753 }
754
755
756
757
758 @Test
759 @Alerts("07:23:00 GMT+0900 (Japan Standard Time)")
760 @BuggyWebDriver(FF = "23:23:00 GMT+0100 (Central European Standard Time)",
761 FF_ESR = "23:23:00 GMT+0100 (Central European Standard Time)")
762 @HtmlUnitNYI(CHROME = "07:23:00 GMT+0900 (JST)",
763 EDGE = "07:23:00 GMT+0900 (JST)",
764 FF = "07:23:00 GMT+0900 (JST)",
765 FF_ESR = "07:23:00 GMT+0900 (JST)")
766 public void toTimeStringTokyo() throws Exception {
767 toTimeString("Asia/Tokyo");
768 }
769
770
771
772
773 @Test
774 @Alerts("07:23:00 GMT+0900 (Japan Standard Time)")
775 @BuggyWebDriver(FF = "23:23:00 GMT+0100 (Central European Standard Time)",
776 FF_ESR = "23:23:00 GMT+0100 (Central European Standard Time)")
777 @HtmlUnitNYI(CHROME = "07:23:00 GMT+0900 (JST)",
778 EDGE = "07:23:00 GMT+0900 (JST)",
779 FF = "07:23:00 GMT+0900 (JST)",
780 FF_ESR = "07:23:00 GMT+0900 (JST)")
781 public void toTimeStringJST() throws Exception {
782 toTimeString("JST");
783 }
784
785 private void toTimeString(final String tz) throws Exception {
786 final String html = DOCTYPE_HTML
787 + "<html><body><script>\n"
788 + LOG_TITLE_FUNCTION
789 + "log(new Date('Sat, 18 Dec 2021 22:23:00 UTC').toTimeString());\n"
790 + "</script>\n"
791 + "</body></html>";
792
793 shutDownAll();
794 try {
795 final BrowserVersion.BrowserVersionBuilder builder
796 = new BrowserVersion.BrowserVersionBuilder(getBrowserVersion());
797 builder.setSystemTimezone(TimeZone.getTimeZone(tz));
798 setBrowserVersion(builder.build());
799
800 loadPageVerifyTitle2(html);
801 }
802 finally {
803 shutDownAll();
804 }
805 }
806
807
808
809
810 @Test
811 @Alerts("Sat, 18 Dec 2021 22:23:00 GMT")
812 public void toUTCStringGMT() throws Exception {
813 toUTCString("GMT");
814 }
815
816
817
818
819 @Test
820 @Alerts("Sat, 18 Dec 2021 22:23:00 GMT")
821 public void toUTCStringUTC() throws Exception {
822 toUTCString("UTC");
823 }
824
825
826
827
828 @Test
829 @Alerts("Sat, 18 Dec 2021 22:23:00 GMT")
830 public void toUTCStringEST() throws Exception {
831 toUTCString("EST");
832 }
833
834
835
836
837 @Test
838 @Alerts("Sat, 18 Dec 2021 22:23:00 GMT")
839 public void toUTCStringBerlin() throws Exception {
840 toUTCString("Europe/Berlin");
841 }
842
843
844
845
846 @Test
847 @Alerts("Sat, 18 Dec 2021 22:23:00 GMT")
848 public void toUTCStringNewYork() throws Exception {
849 toUTCString("America/New_York");
850 }
851
852
853
854
855 @Test
856 @Alerts("Sat, 18 Dec 2021 22:23:00 GMT")
857 public void toUTCStringTokyo() throws Exception {
858 toUTCString("Asia/Tokyo");
859 }
860
861
862
863
864 @Test
865 @Alerts("Sat, 18 Dec 2021 22:23:00 GMT")
866 public void toUTCStringJST() throws Exception {
867 toUTCString("JST");
868 }
869
870 private void toUTCString(final String tz) throws Exception {
871 final String html = DOCTYPE_HTML
872 + "<html><body><script>\n"
873 + LOG_TITLE_FUNCTION
874 + "log(new Date('Sat, 18 Dec 2021 22:23:00 UTC').toUTCString());\n"
875 + "</script>\n"
876 + "</body></html>";
877
878 shutDownAll();
879 try {
880 final BrowserVersion.BrowserVersionBuilder builder
881 = new BrowserVersion.BrowserVersionBuilder(getBrowserVersion());
882 builder.setSystemTimezone(TimeZone.getTimeZone(tz));
883 setBrowserVersion(builder.build());
884
885 loadPageVerifyTitle2(html);
886 }
887 finally {
888 shutDownAll();
889 }
890 }
891
892
893
894
895 @Test
896 @Alerts("0")
897 @BuggyWebDriver(FF = "-60",
898 FF_ESR = "-60")
899 public void timezoneOffsetGMT() throws Exception {
900 timezoneOffset("GMT");
901 }
902
903
904
905
906 @Test
907 @Alerts("0")
908 @BuggyWebDriver(FF = "-60",
909 FF_ESR = "-60")
910 public void timezoneOffsetUTC() throws Exception {
911 timezoneOffset("UTC");
912 }
913
914
915
916
917 @Test
918 @Alerts("300")
919 @BuggyWebDriver(FF = "-60",
920 FF_ESR = "-60")
921 public void timezoneOffsetEST() throws Exception {
922 timezoneOffset("EST");
923 }
924
925
926
927
928 @Test
929 @Alerts("-60")
930 public void timezoneOffsetBerlin() throws Exception {
931 timezoneOffset("Europe/Berlin");
932 }
933
934
935
936
937 @Test
938 @Alerts("300")
939 @BuggyWebDriver(FF = "-60",
940 FF_ESR = "-60")
941 public void timezoneOffsetNewYork() throws Exception {
942 timezoneOffset("America/New_York");
943 }
944
945
946
947
948 @Test
949 @Alerts("-540")
950 @BuggyWebDriver(FF = "-60",
951 FF_ESR = "-60")
952 public void timezoneOffsetTokyo() throws Exception {
953 timezoneOffset("Asia/Tokyo");
954 }
955
956
957
958
959 @Test
960 @Alerts("-540")
961 @BuggyWebDriver(FF = "-60",
962 FF_ESR = "-60")
963 public void timezoneOffsetJST() throws Exception {
964 timezoneOffset("JST");
965 }
966
967 private void timezoneOffset(final String tz) throws Exception {
968 final String html = DOCTYPE_HTML
969 + "<html><body><script>\n"
970 + LOG_TITLE_FUNCTION
971 + "log(new Date(0).getTimezoneOffset());\n"
972 + "</script>\n"
973 + "</body></html>";
974
975 shutDownAll();
976 try {
977 final BrowserVersion.BrowserVersionBuilder builder
978 = new BrowserVersion.BrowserVersionBuilder(getBrowserVersion());
979 builder.setSystemTimezone(TimeZone.getTimeZone(tz));
980 setBrowserVersion(builder.build());
981
982 loadPageVerifyTitle2(html);
983 }
984 finally {
985 shutDownAll();
986 }
987 }
988 }