1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.encoding;
16
17 import static java.nio.charset.StandardCharsets.ISO_8859_1;
18 import static java.nio.charset.StandardCharsets.UTF_8;
19
20 import java.io.ByteArrayOutputStream;
21 import java.net.URL;
22 import java.nio.charset.Charset;
23 import java.nio.charset.StandardCharsets;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.List;
27 import java.util.zip.GZIPOutputStream;
28
29 import org.apache.commons.io.ByteOrderMark;
30 import org.apache.commons.lang3.ArrayUtils;
31 import org.htmlunit.MiniServer;
32 import org.htmlunit.WebDriverTestCase;
33 import org.htmlunit.junit.BrowserParameterizedRunner;
34 import org.htmlunit.junit.BrowserParameterizedRunner.Default;
35 import org.htmlunit.junit.annotation.Alerts;
36 import org.htmlunit.junit.annotation.HtmlUnitNYI;
37 import org.htmlunit.util.MimeType;
38 import org.htmlunit.util.NameValuePair;
39 import org.junit.Test;
40 import org.junit.runner.RunWith;
41 import org.junit.runners.Parameterized.Parameter;
42 import org.junit.runners.Parameterized.Parameters;
43 import org.openqa.selenium.WebDriver;
44 import org.openqa.selenium.WebDriverException;
45
46
47
48
49
50
51 @RunWith(BrowserParameterizedRunner.class)
52 public class HtmlPageEncodingTest extends WebDriverTestCase {
53
54 private static final String BOM_UTF_16LE = "BOMUTF16LE";
55 private static final String BOM_UTF_16BE = "BOMUTF16BE";
56 private static final String BOM_UTF_8 = "BOMUTF8";
57
58 private enum TestCharset {
59 UTF8("UTF8", UTF_8),
60 ISO88591("ISO88591", ISO_8859_1),
61 GB2312("GB2312", Charset.forName("GB2312"));
62
63 private final String label_;
64 private final Charset charset_;
65
66 TestCharset(final String label, final Charset charset) {
67 label_ = label;
68 charset_ = charset;
69 }
70
71 @Override
72 public String toString() {
73 return label_;
74 }
75
76 public Charset getCharset() {
77 return charset_;
78 }
79 }
80
81
82
83
84
85
86 @Parameters
87 public static Collection<Object[]> data() throws Exception {
88 final List<Object[]> list = new ArrayList<>();
89
90 final TestCharset[] charsetResponseHeader = new TestCharset[]
91 {null, TestCharset.UTF8, TestCharset.ISO88591, TestCharset.GB2312};
92 final TestCharset[] charsetResponseEncoding = new TestCharset[]
93 {null, TestCharset.UTF8, TestCharset.ISO88591, TestCharset.GB2312};
94 final TestCharset[] charsetMeta = new TestCharset[]
95 {null, TestCharset.UTF8, TestCharset.ISO88591, TestCharset.GB2312};
96 final String[] bom = {null, BOM_UTF_8, BOM_UTF_16LE, BOM_UTF_16BE};
97
98 for (final Object responseHeader : charsetResponseHeader) {
99 for (final Object responseEncoding : charsetResponseEncoding) {
100 for (final Object meta : charsetMeta) {
101 for (final Object b : bom) {
102 list.add(new Object[] {responseHeader, responseEncoding, meta, b, false});
103 list.add(new Object[] {responseHeader, responseEncoding, meta, b, true});
104 }
105 }
106 }
107 }
108 return list;
109 }
110
111
112
113
114 @Parameter(0)
115 public TestCharset charsetResponseHeader_;
116
117
118
119
120 @Parameter(1)
121 public TestCharset charsetResponseEncoding_;
122
123
124
125
126 @Parameter(2)
127 public TestCharset charsetMeta_;
128
129
130
131
132 @Parameter(3)
133 public String bom_;
134
135
136
137
138 @Parameter(4)
139 public boolean gzip_;
140
141
142
143
144
145 @Test
146 @Alerts("a \u00E4 \u0623\u0647\u0644\u0627\u064B \u043C\u0438\u0440 \u623F\u95F4")
147 @Default
148 public void charset() throws Exception {
149 charset(charsetResponseHeader_, charsetResponseEncoding_, charsetMeta_, bom_, gzip_);
150 }
151
152 private void charset(
153 final TestCharset charsetResponseHeader,
154 final TestCharset charsetResponseEncoding,
155 final TestCharset charsetMeta,
156 final String bom,
157 final boolean gzip) throws Exception {
158
159
160 final URL htmlUrl = new URL(URL_FIRST, "" + System.currentTimeMillis() + ".html");
161
162
163 String meta = "";
164 if (charsetMeta != null) {
165 meta = "<meta charset='" + charsetMeta.getCharset().name().toLowerCase() + "' />\n";
166 }
167
168 final String html = DOCTYPE_HTML
169 + "<html><head>\n"
170 + meta
171 + " <title>a ä أهلاً мир 房间</title>\n"
172 + "</head>\n"
173 + "<body>\n"
174 + "</body>\n"
175 + "</html>";
176
177 String contentType = MimeType.TEXT_HTML;
178 if (charsetResponseHeader != null) {
179 contentType = contentType + "; charset=" + charsetResponseHeader.getCharset().name().toLowerCase();
180 }
181
182 byte[] htmlBytes = null;
183 if (charsetResponseEncoding == null) {
184 htmlBytes = html.getBytes(UTF_8);
185 }
186 else {
187 htmlBytes = html.getBytes(charsetResponseEncoding.getCharset());
188 }
189
190 if (BOM_UTF_8.equals(bom)) {
191 htmlBytes = ArrayUtils.addAll(ByteOrderMark.UTF_8.getBytes(), html.getBytes(StandardCharsets.UTF_8));
192 }
193 else if (BOM_UTF_16BE.equals(bom)) {
194 htmlBytes = ArrayUtils.addAll(ByteOrderMark.UTF_16BE.getBytes(), html.getBytes(StandardCharsets.UTF_16BE));
195 }
196 else if (BOM_UTF_16LE.equals(bom)) {
197 htmlBytes = ArrayUtils.addAll(ByteOrderMark.UTF_16LE.getBytes(), html.getBytes(StandardCharsets.UTF_16LE));
198 }
199
200 if (gzip) {
201 final ByteArrayOutputStream bos = new ByteArrayOutputStream();
202 final GZIPOutputStream gout = new GZIPOutputStream(bos);
203 gout.write(htmlBytes);
204 gout.finish();
205
206 final List<NameValuePair> headers = new ArrayList<>();
207 headers.add(new NameValuePair("Content-Encoding", "gzip"));
208 getMockWebConnection().setResponse(htmlUrl, bos.toByteArray(), 200, "OK", contentType, headers);
209 }
210 else {
211 getMockWebConnection().setResponse(htmlUrl, htmlBytes, 200, "OK", contentType, null);
212 }
213
214 try (MiniServer miniServer1 = new MiniServer(PORT, getMockWebConnection())) {
215 miniServer1.start();
216
217 try {
218 final WebDriver driver = getWebDriver();
219 driver.get(htmlUrl.toExternalForm());
220
221 assertEquals(getExpectedAlerts()[0], driver.getTitle());
222 }
223 catch (final WebDriverException e) {
224 if (!e.getCause().getMessage().contains("illegal character")
225 && !e.getCause().getMessage().contains("is not defined.")) {
226 throw e;
227 }
228
229 final String msg = e.getCause().getMessage();
230 assertTrue(msg, msg.contains(getExpectedAlerts()[0]));
231 }
232 }
233 }
234
235
236
237
238 @Test
239 @Alerts("a ? ????? \u043C\u0438\u0440 \u623F\u95F4")
240 public void _GB2312_GB2312_GB2312__false() throws Exception {
241 charset(TestCharset.GB2312, TestCharset.GB2312, TestCharset.GB2312, null, false);
242 }
243
244
245
246
247 @Test
248 @Alerts("a ? ????? \u043C\u0438\u0440 \u623F\u95F4")
249 public void _GB2312_GB2312_GB2312__true() throws Exception {
250 charset(TestCharset.GB2312, TestCharset.GB2312, TestCharset.GB2312, null, true);
251 }
252
253
254
255
256 @Test
257 @Alerts("a ? ????? \u043C\u0438\u0440 \u623F\u95F4")
258 public void _GB2312_GB2312_ISO88591__false() throws Exception {
259 charset(TestCharset.GB2312, TestCharset.GB2312, TestCharset.ISO88591, null, false);
260 }
261
262
263
264
265 @Test
266 @Alerts("a ? ????? \u043C\u0438\u0440 \u623F\u95F4")
267 public void _GB2312_GB2312_ISO88591__true() throws Exception {
268 charset(TestCharset.GB2312, TestCharset.GB2312, TestCharset.ISO88591, null, true);
269 }
270
271
272
273
274 @Test
275 @Alerts("a ? ????? \u043C\u0438\u0440 \u623F\u95F4")
276 public void _GB2312_GB2312_UTF8__false() throws Exception {
277 charset(TestCharset.GB2312, TestCharset.GB2312, TestCharset.UTF8, null, false);
278 }
279
280
281
282
283 @Test
284 @Alerts("a ? ????? \u043C\u0438\u0440 \u623F\u95F4")
285 public void _GB2312_GB2312_UTF8__true() throws Exception {
286 charset(TestCharset.GB2312, TestCharset.GB2312, TestCharset.UTF8, null, true);
287 }
288
289
290
291
292 @Test
293 @Alerts("a ? ????? \u043C\u0438\u0440 \u623F\u95F4")
294 public void _GB2312_GB2312___false() throws Exception {
295 charset(TestCharset.GB2312, TestCharset.GB2312, null, null, false);
296 }
297
298
299
300
301 @Test
302 @Alerts("a ? ????? \u043C\u0438\u0440 \u623F\u95F4")
303 public void _GB2312_GB2312___true() throws Exception {
304 charset(TestCharset.GB2312, TestCharset.GB2312, null, null, true);
305 }
306
307
308
309
310 @Test
311 @Alerts("a � ????? ??? ??")
312 public void _GB2312_ISO88591_GB2312__false() throws Exception {
313 charset(TestCharset.GB2312, TestCharset.ISO88591, TestCharset.GB2312, null, false);
314 }
315
316
317
318
319 @Test
320 @Alerts("a � ????? ??? ??")
321 public void _GB2312_ISO88591_GB2312__true() throws Exception {
322 charset(TestCharset.GB2312, TestCharset.ISO88591, TestCharset.GB2312, null, true);
323 }
324
325
326
327
328 @Test
329 @Alerts("a � ????? ??? ??")
330 public void _GB2312_ISO88591_ISO88591__false() throws Exception {
331 charset(TestCharset.GB2312, TestCharset.ISO88591, TestCharset.ISO88591, null, false);
332 }
333
334
335
336
337 @Test
338 @Alerts("a � ????? ??? ??")
339 public void _GB2312_ISO88591_ISO88591__true() throws Exception {
340 charset(TestCharset.GB2312, TestCharset.ISO88591, TestCharset.ISO88591, null, true);
341 }
342
343
344
345
346 @Test
347 @Alerts("a � ????? ??? ??")
348 public void _GB2312_ISO88591_UTF8__false() throws Exception {
349 charset(TestCharset.GB2312, TestCharset.ISO88591, TestCharset.UTF8, null, false);
350 }
351
352
353
354
355 @Test
356 @Alerts("a � ????? ??? ??")
357 public void _GB2312_ISO88591_UTF8__true() throws Exception {
358 charset(TestCharset.GB2312, TestCharset.ISO88591, TestCharset.UTF8, null, true);
359 }
360
361
362
363
364 @Test
365 @Alerts("a � ????? ??? ??")
366 public void _GB2312_ISO88591___false() throws Exception {
367 charset(TestCharset.GB2312, TestCharset.ISO88591, null, null, false);
368 }
369
370
371
372
373 @Test
374 @Alerts("a � ????? ??? ??")
375 public void _GB2312_ISO88591___true() throws Exception {
376 charset(TestCharset.GB2312, TestCharset.ISO88591, null, null, true);
377 }
378
379
380
381
382 @Test
383 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
384 public void _GB2312_UTF8_GB2312__false() throws Exception {
385 charset(TestCharset.GB2312, TestCharset.UTF8, TestCharset.GB2312, null, false);
386 }
387
388
389
390
391 @Test
392 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
393 public void _GB2312_UTF8_GB2312__true() throws Exception {
394 charset(TestCharset.GB2312, TestCharset.UTF8, TestCharset.GB2312, null, true);
395 }
396
397
398
399
400 @Test
401 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
402 public void _GB2312_UTF8_ISO88591__false() throws Exception {
403 charset(TestCharset.GB2312, TestCharset.UTF8, TestCharset.ISO88591, null, false);
404 }
405
406
407
408
409 @Test
410 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
411 public void _GB2312_UTF8_ISO88591__true() throws Exception {
412 charset(TestCharset.GB2312, TestCharset.UTF8, TestCharset.ISO88591, null, true);
413 }
414
415
416
417
418 @Test
419 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
420 public void _GB2312_UTF8_UTF8__false() throws Exception {
421 charset(TestCharset.GB2312, TestCharset.UTF8, TestCharset.UTF8, null, false);
422 }
423
424
425
426
427 @Test
428 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
429 public void _GB2312_UTF8_UTF8__true() throws Exception {
430 charset(TestCharset.GB2312, TestCharset.UTF8, TestCharset.UTF8, null, true);
431 }
432
433
434
435
436 @Test
437 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
438 public void _GB2312_UTF8___false() throws Exception {
439 charset(TestCharset.GB2312, TestCharset.UTF8, null, null, false);
440 }
441
442
443
444
445 @Test
446 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
447 public void _GB2312_UTF8___true() throws Exception {
448 charset(TestCharset.GB2312, TestCharset.UTF8, null, null, true);
449 }
450
451
452
453
454 @Test
455 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
456 public void _GB2312__GB2312__false() throws Exception {
457 charset(TestCharset.GB2312, null, TestCharset.GB2312, null, false);
458 }
459
460
461
462
463 @Test
464 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
465 public void _GB2312__GB2312__true() throws Exception {
466 charset(TestCharset.GB2312, null, TestCharset.GB2312, null, true);
467 }
468
469
470
471
472 @Test
473 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
474 public void _GB2312__ISO88591__false() throws Exception {
475 charset(TestCharset.GB2312, null, TestCharset.ISO88591, null, false);
476 }
477
478
479
480
481 @Test
482 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
483 public void _GB2312__ISO88591__true() throws Exception {
484 charset(TestCharset.GB2312, null, TestCharset.ISO88591, null, true);
485 }
486
487
488
489
490 @Test
491 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
492 public void _GB2312__UTF8__false() throws Exception {
493 charset(TestCharset.GB2312, null, TestCharset.UTF8, null, false);
494 }
495
496
497
498
499 @Test
500 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
501 public void _GB2312__UTF8__true() throws Exception {
502 charset(TestCharset.GB2312, null, TestCharset.UTF8, null, true);
503 }
504
505
506
507
508 @Test
509 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
510 public void _GB2312____false() throws Exception {
511 charset(TestCharset.GB2312, null, null, null, false);
512 }
513
514
515
516
517 @Test
518 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
519 public void _GB2312____true() throws Exception {
520 charset(TestCharset.GB2312, null, null, null, true);
521 }
522
523
524
525
526 @Test
527 @Alerts("a ? ????? §Þ§Ú§â ·¿¼ä")
528 public void _ISO88591_GB2312_GB2312__false() throws Exception {
529 charset(TestCharset.ISO88591, TestCharset.GB2312, TestCharset.GB2312, null, false);
530 }
531
532
533
534
535 @Test
536 @Alerts("a ? ????? §Þ§Ú§â ·¿¼ä")
537 public void _ISO88591_GB2312_GB2312__true() throws Exception {
538 charset(TestCharset.ISO88591, TestCharset.GB2312, TestCharset.GB2312, null, true);
539 }
540
541
542
543
544 @Test
545 @Alerts("a ? ????? §Þ§Ú§â ·¿¼ä")
546 public void _ISO88591_GB2312_ISO88591__false() throws Exception {
547 charset(TestCharset.ISO88591, TestCharset.GB2312, TestCharset.ISO88591, null, false);
548 }
549
550
551
552
553 @Test
554 @Alerts("a ? ????? §Þ§Ú§â ·¿¼ä")
555 public void _ISO88591_GB2312_ISO88591__true() throws Exception {
556 charset(TestCharset.ISO88591, TestCharset.GB2312, TestCharset.ISO88591, null, true);
557 }
558
559
560
561
562 @Test
563 @Alerts("a ? ????? §Þ§Ú§â ·¿¼ä")
564 public void _ISO88591_GB2312_UTF8__false() throws Exception {
565 charset(TestCharset.ISO88591, TestCharset.GB2312, TestCharset.UTF8, null, false);
566 }
567
568
569
570
571 @Test
572 @Alerts("a ? ????? §Þ§Ú§â ·¿¼ä")
573 public void _ISO88591_GB2312_UTF8__true() throws Exception {
574 charset(TestCharset.ISO88591, TestCharset.GB2312, TestCharset.UTF8, null, true);
575 }
576
577
578
579
580 @Test
581 @Alerts("a ? ????? §Þ§Ú§â ·¿¼ä")
582 public void _ISO88591_GB2312___false() throws Exception {
583 charset(TestCharset.ISO88591, TestCharset.GB2312, null, null, false);
584 }
585
586
587
588
589 @Test
590 @Alerts("a ? ????? §Þ§Ú§â ·¿¼ä")
591 public void _ISO88591_GB2312___true() throws Exception {
592 charset(TestCharset.ISO88591, TestCharset.GB2312, null, null, true);
593 }
594
595
596
597
598 @Test
599 @Alerts("a ä ????? ??? ??")
600 public void _ISO88591_ISO88591_GB2312__false() throws Exception {
601 charset(TestCharset.ISO88591, TestCharset.ISO88591, TestCharset.GB2312, null, false);
602 }
603
604
605
606
607 @Test
608 @Alerts("a ä ????? ??? ??")
609 public void _ISO88591_ISO88591_GB2312__true() throws Exception {
610 charset(TestCharset.ISO88591, TestCharset.ISO88591, TestCharset.GB2312, null, true);
611 }
612
613
614
615
616 @Test
617 @Alerts("a ä ????? ??? ??")
618 public void _ISO88591_ISO88591_ISO88591__false() throws Exception {
619 charset(TestCharset.ISO88591, TestCharset.ISO88591, TestCharset.ISO88591, null, false);
620 }
621
622
623
624
625 @Test
626 @Alerts("a ä ????? ??? ??")
627 public void _ISO88591_ISO88591_ISO88591__true() throws Exception {
628 charset(TestCharset.ISO88591, TestCharset.ISO88591, TestCharset.ISO88591, null, true);
629 }
630
631
632
633
634 @Test
635 @Alerts("a ä ????? ??? ??")
636 public void _ISO88591_ISO88591_UTF8__false() throws Exception {
637 charset(TestCharset.ISO88591, TestCharset.ISO88591, TestCharset.UTF8, null, false);
638 }
639
640
641
642
643 @Test
644 @Alerts("a ä ????? ??? ??")
645 public void _ISO88591_ISO88591_UTF8__true() throws Exception {
646 charset(TestCharset.ISO88591, TestCharset.ISO88591, TestCharset.UTF8, null, true);
647 }
648
649
650
651
652 @Test
653 @Alerts("a ä ????? ??? ??")
654 public void _ISO88591_ISO88591___false() throws Exception {
655 charset(TestCharset.ISO88591, TestCharset.ISO88591, null, null, false);
656 }
657
658
659
660
661 @Test
662 @Alerts("a ä ????? ??? ??")
663 public void _ISO88591_ISO88591___true() throws Exception {
664 charset(TestCharset.ISO88591, TestCharset.ISO88591, null, null, true);
665 }
666
667
668
669
670 @Test
671 @Alerts("a ä أهلاً мир 房间")
672 public void _ISO88591_UTF8_GB2312__false() throws Exception {
673 charset(TestCharset.ISO88591, TestCharset.UTF8, TestCharset.GB2312, null, false);
674 }
675
676
677
678
679 @Test
680 @Alerts("a ä أهلاً мир 房间")
681 public void _ISO88591_UTF8_GB2312__true() throws Exception {
682 charset(TestCharset.ISO88591, TestCharset.UTF8, TestCharset.GB2312, null, true);
683 }
684
685
686
687
688 @Test
689 @Alerts("a ä أهلاً мир 房间")
690 public void _ISO88591_UTF8_ISO88591__false() throws Exception {
691 charset(TestCharset.ISO88591, TestCharset.UTF8, TestCharset.ISO88591, null, false);
692 }
693
694
695
696
697 @Test
698 @Alerts("a ä أهلاً мир 房间")
699 public void _ISO88591_UTF8_ISO88591__true() throws Exception {
700 charset(TestCharset.ISO88591, TestCharset.UTF8, TestCharset.ISO88591, null, true);
701 }
702
703
704
705
706 @Test
707 @Alerts("a ä أهلاً мир 房间")
708 public void _ISO88591_UTF8_UTF8__false() throws Exception {
709 charset(TestCharset.ISO88591, TestCharset.UTF8, TestCharset.UTF8, null, false);
710 }
711
712
713
714
715 @Test
716 @Alerts("a ä أهلاً мир 房间")
717 public void _ISO88591_UTF8_UTF8__true() throws Exception {
718 charset(TestCharset.ISO88591, TestCharset.UTF8, TestCharset.UTF8, null, true);
719 }
720
721
722
723
724 @Test
725 @Alerts("a ä أهلاً мир 房间")
726 public void _ISO88591_UTF8___false() throws Exception {
727 charset(TestCharset.ISO88591, TestCharset.UTF8, null, null, false);
728 }
729
730
731
732
733 @Test
734 @Alerts("a ä أهلاً мир 房间")
735 public void _ISO88591_UTF8___true() throws Exception {
736 charset(TestCharset.ISO88591, TestCharset.UTF8, null, null, true);
737 }
738
739
740
741
742 @Test
743 @Alerts("a ä أهلاً мир 房间")
744 public void _ISO88591__GB2312__false() throws Exception {
745 charset(TestCharset.ISO88591, null, TestCharset.GB2312, null, false);
746 }
747
748
749
750
751 @Test
752 @Alerts("a ä أهلاً мир 房间")
753 public void _ISO88591__GB2312__true() throws Exception {
754 charset(TestCharset.ISO88591, null, TestCharset.GB2312, null, true);
755 }
756
757
758
759
760 @Test
761 @Alerts("a ä أهلاً мир 房间")
762 public void _ISO88591__ISO88591__false() throws Exception {
763 charset(TestCharset.ISO88591, null, TestCharset.ISO88591, null, false);
764 }
765
766
767
768
769 @Test
770 @Alerts("a ä أهلاً мир 房间")
771 public void _ISO88591__ISO88591__true() throws Exception {
772 charset(TestCharset.ISO88591, null, TestCharset.ISO88591, null, true);
773 }
774
775
776
777
778 @Test
779 @Alerts("a ä أهلاً мир 房间")
780 public void _ISO88591__UTF8__false() throws Exception {
781 charset(TestCharset.ISO88591, null, TestCharset.UTF8, null, false);
782 }
783
784
785
786
787 @Test
788 @Alerts("a ä أهلاً мир 房间")
789 public void _ISO88591__UTF8__true() throws Exception {
790 charset(TestCharset.ISO88591, null, TestCharset.UTF8, null, true);
791 }
792
793
794
795
796 @Test
797 @Alerts("a ä أهلاً мир 房间")
798 public void _ISO88591____false() throws Exception {
799 charset(TestCharset.ISO88591, null, null, null, false);
800 }
801
802
803
804
805 @Test
806 @Alerts("a ä أهلاً мир 房间")
807 public void _ISO88591____true() throws Exception {
808 charset(TestCharset.ISO88591, null, null, null, true);
809 }
810
811
812
813
814 @Test
815 @Alerts("a ? ????? �ާڧ� ����")
816 public void _UTF8_GB2312_GB2312__false() throws Exception {
817 charset(TestCharset.UTF8, TestCharset.GB2312, TestCharset.GB2312, null, false);
818 }
819
820
821
822
823 @Test
824 @Alerts("a ? ????? �ާڧ� ����")
825 public void _UTF8_GB2312_GB2312__true() throws Exception {
826 charset(TestCharset.UTF8, TestCharset.GB2312, TestCharset.GB2312, null, true);
827 }
828
829
830
831
832 @Test
833 @Alerts("a ? ????? �ާڧ� ����")
834 public void _UTF8_GB2312_ISO88591__false() throws Exception {
835 charset(TestCharset.UTF8, TestCharset.GB2312, TestCharset.ISO88591, null, false);
836 }
837
838
839
840
841 @Test
842 @Alerts("a ? ????? �ާڧ� ����")
843 public void _UTF8_GB2312_ISO88591__true() throws Exception {
844 charset(TestCharset.UTF8, TestCharset.GB2312, TestCharset.ISO88591, null, true);
845 }
846
847
848
849
850 @Test
851 @Alerts("a ? ????? �ާڧ� ����")
852 public void _UTF8_GB2312_UTF8__false() throws Exception {
853 charset(TestCharset.UTF8, TestCharset.GB2312, TestCharset.UTF8, null, false);
854 }
855
856
857
858
859 @Test
860 @Alerts("a ? ????? �ާڧ� ����")
861 public void _UTF8_GB2312_UTF8__true() throws Exception {
862 charset(TestCharset.UTF8, TestCharset.GB2312, TestCharset.UTF8, null, true);
863 }
864
865
866
867
868 @Test
869 @Alerts("a ? ????? �ާڧ� ����")
870 public void _UTF8_GB2312___false() throws Exception {
871 charset(TestCharset.UTF8, TestCharset.GB2312, null, null, false);
872 }
873
874
875
876
877 @Test
878 @Alerts("a ? ????? �ާڧ� ����")
879 public void _UTF8_GB2312___true() throws Exception {
880 charset(TestCharset.UTF8, TestCharset.GB2312, null, null, true);
881 }
882
883
884
885
886 @Test
887 @Alerts("a � ????? ??? ??")
888 public void _UTF8_ISO88591_GB2312__false() throws Exception {
889 charset(TestCharset.UTF8, TestCharset.ISO88591, TestCharset.GB2312, null, false);
890 }
891
892
893
894
895 @Test
896 @Alerts("a � ????? ??? ??")
897 public void _UTF8_ISO88591_GB2312__true() throws Exception {
898 charset(TestCharset.UTF8, TestCharset.ISO88591, TestCharset.GB2312, null, true);
899 }
900
901
902
903
904 @Test
905 @Alerts("a � ????? ??? ??")
906 public void _UTF8_ISO88591_ISO88591__false() throws Exception {
907 charset(TestCharset.UTF8, TestCharset.ISO88591, TestCharset.ISO88591, null, false);
908 }
909
910
911
912
913 @Test
914 @Alerts("a � ????? ??? ??")
915 public void _UTF8_ISO88591_ISO88591__true() throws Exception {
916 charset(TestCharset.UTF8, TestCharset.ISO88591, TestCharset.ISO88591, null, true);
917 }
918
919
920
921
922 @Test
923 @Alerts("a � ????? ??? ??")
924 public void _UTF8_ISO88591_UTF8__false() throws Exception {
925 charset(TestCharset.UTF8, TestCharset.ISO88591, TestCharset.UTF8, null, false);
926 }
927
928
929
930
931 @Test
932 @Alerts("a � ????? ??? ??")
933 public void _UTF8_ISO88591_UTF8__true() throws Exception {
934 charset(TestCharset.UTF8, TestCharset.ISO88591, TestCharset.UTF8, null, true);
935 }
936
937
938
939
940 @Test
941 @Alerts("a � ????? ??? ??")
942 public void _UTF8_ISO88591___false() throws Exception {
943 charset(TestCharset.UTF8, TestCharset.ISO88591, null, null, false);
944 }
945
946
947
948
949 @Test
950 @Alerts("a � ????? ??? ??")
951 public void _UTF8_ISO88591___true() throws Exception {
952 charset(TestCharset.UTF8, TestCharset.ISO88591, null, null, true);
953 }
954
955
956
957
958 @Test
959 @Alerts("a ? ????? мир 房间")
960 public void __GB2312_GB2312__false() throws Exception {
961 charset(null, TestCharset.GB2312, TestCharset.GB2312, null, false);
962 }
963
964
965
966
967 @Test
968 @Alerts("a ? ????? мир 房间")
969 public void __GB2312_GB2312__true() throws Exception {
970 charset(null, TestCharset.GB2312, TestCharset.GB2312, null, true);
971 }
972
973
974
975
976 @Test
977 @Alerts("a ? ????? §Þ§Ú§â ·¿¼ä")
978 public void __GB2312_ISO88591__false() throws Exception {
979 charset(null, TestCharset.GB2312, TestCharset.ISO88591, null, false);
980 }
981
982
983
984
985 @Test
986 @Alerts("a ? ????? §Þ§Ú§â ·¿¼ä")
987 public void __GB2312_ISO88591__true() throws Exception {
988 charset(null, TestCharset.GB2312, TestCharset.ISO88591, null, true);
989 }
990
991
992
993
994 @Test
995 @Alerts("a ? ????? �ާڧ� ����")
996 public void __GB2312_UTF8__false() throws Exception {
997 charset(null, TestCharset.GB2312, TestCharset.UTF8, null, false);
998 }
999
1000
1001
1002
1003 @Test
1004 @Alerts("a ? ????? �ާڧ� ����")
1005 public void __GB2312_UTF8__true() throws Exception {
1006 charset(null, TestCharset.GB2312, TestCharset.UTF8, null, true);
1007 }
1008
1009
1010
1011
1012 @Test
1013 @Alerts(DEFAULT = "a ? ????? §Þ§Ú§â ·¿¼ä",
1014 FF = "a ? ????? 技我把 滇潔",
1015 FF_ESR = "a ? ????? 技我把 滇潔")
1016 @HtmlUnitNYI(FF = "a ? ????? §Þ§Ú§â ·¿¼ä",
1017 FF_ESR = "a ? ????? §Þ§Ú§â ·¿¼ä")
1018 public void __GB2312___false() throws Exception {
1019 charset(null, TestCharset.GB2312, null, null, false);
1020 }
1021
1022
1023
1024
1025 @Test
1026 @Alerts(DEFAULT = "a ? ????? §Þ§Ú§â ·¿¼ä",
1027 FF = "a ? ????? 技我把 滇潔",
1028 FF_ESR = "a ? ????? 技我把 滇潔")
1029 @HtmlUnitNYI(FF = "a ? ????? §Þ§Ú§â ·¿¼ä",
1030 FF_ESR = "a ? ????? §Þ§Ú§â ·¿¼ä")
1031 public void __GB2312___true() throws Exception {
1032 charset(null, TestCharset.GB2312, null, null, true);
1033 }
1034
1035
1036
1037
1038 @Test
1039 @Alerts("a � ????? ??? ??")
1040 public void __ISO88591_GB2312__false() throws Exception {
1041 charset(null, TestCharset.ISO88591, TestCharset.GB2312, null, false);
1042 }
1043
1044
1045
1046
1047 @Test
1048 @Alerts("a � ????? ??? ??")
1049 public void __ISO88591_GB2312__true() throws Exception {
1050 charset(null, TestCharset.ISO88591, TestCharset.GB2312, null, true);
1051 }
1052
1053
1054
1055
1056 @Test
1057 @Alerts("a ä ????? ??? ??")
1058 public void __ISO88591_ISO88591__false() throws Exception {
1059 charset(null, TestCharset.ISO88591, TestCharset.ISO88591, null, false);
1060 }
1061
1062
1063
1064
1065 @Test
1066 @Alerts("a ä ????? ??? ??")
1067 public void __ISO88591_ISO88591__true() throws Exception {
1068 charset(null, TestCharset.ISO88591, TestCharset.ISO88591, null, true);
1069 }
1070
1071
1072
1073
1074 @Test
1075 @Alerts("a � ????? ??? ??")
1076 public void __ISO88591_UTF8__false() throws Exception {
1077 charset(null, TestCharset.ISO88591, TestCharset.UTF8, null, false);
1078 }
1079
1080
1081
1082
1083 @Test
1084 @Alerts("a � ????? ??? ??")
1085 public void __ISO88591_UTF8__true() throws Exception {
1086 charset(null, TestCharset.ISO88591, TestCharset.UTF8, null, true);
1087 }
1088
1089
1090
1091
1092 @Test
1093 @Alerts("a ä ????? ??? ??")
1094 public void __ISO88591___false() throws Exception {
1095 charset(null, TestCharset.ISO88591, null, null, false);
1096 }
1097
1098
1099
1100
1101 @Test
1102 @Alerts("a ä ????? ??? ??")
1103 public void __ISO88591___true() throws Exception {
1104 charset(null, TestCharset.ISO88591, null, null, true);
1105 }
1106
1107
1108
1109
1110 @Test
1111 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
1112 public void __UTF8_GB2312__true() throws Exception {
1113 charset(null, TestCharset.UTF8, TestCharset.GB2312, null, true);
1114 }
1115
1116
1117
1118
1119 @Test
1120 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
1121 public void __UTF8_GB2312__false() throws Exception {
1122 charset(null, TestCharset.UTF8, TestCharset.GB2312, null, false);
1123 }
1124
1125
1126
1127
1128 @Test
1129 @Alerts("a ä أهلاً мир 房间")
1130 public void __UTF8_ISO88591__true() throws Exception {
1131 charset(null, TestCharset.UTF8, TestCharset.ISO88591, null, true);
1132 }
1133
1134
1135
1136
1137 @Test
1138 @Alerts("a ä أهلاً мир 房间")
1139 public void __UTF8_ISO88591__false() throws Exception {
1140 charset(null, TestCharset.UTF8, TestCharset.ISO88591, null, false);
1141 }
1142
1143
1144
1145
1146 @Test
1147 @Alerts("a ä أهلاً мир 房间")
1148 public void __UTF8___true() throws Exception {
1149 charset(null, TestCharset.UTF8, null, null, true);
1150 }
1151
1152
1153
1154
1155 @Test
1156 @Alerts("a ä أهلاً мир 房间")
1157 public void __UTF8___false() throws Exception {
1158 charset(null, TestCharset.UTF8, null, null, false);
1159 }
1160
1161
1162
1163
1164 @Test
1165 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
1166 public void ___GB2312__false() throws Exception {
1167 charset(null, null, TestCharset.GB2312, null, false);
1168 }
1169
1170
1171
1172
1173 @Test
1174 @Alerts("a 盲 兀賴賱丕賸 屑懈褉 鎴块棿")
1175 public void ___GB2312__true() throws Exception {
1176 charset(null, null, TestCharset.GB2312, null, true);
1177 }
1178
1179
1180
1181
1182 @Test
1183 @Alerts("a ä أهلاً мир 房间")
1184 public void ___ISO88591__false() throws Exception {
1185 charset(null, null, TestCharset.ISO88591, null, false);
1186 }
1187
1188
1189
1190
1191 @Test
1192 @Alerts("a ä أهلاً мир 房间")
1193 public void ___ISO88591__true() throws Exception {
1194 charset(null, null, TestCharset.ISO88591, null, true);
1195 }
1196
1197
1198
1199
1200 @Test
1201 @Alerts("a ä أهلاً мир 房间")
1202 public void _____false() throws Exception {
1203 charset(null, null, null, null, false);
1204 }
1205
1206
1207
1208
1209 @Test
1210 @Alerts("a ä أهلاً мир 房间")
1211 public void _____true() throws Exception {
1212 charset(null, null, null, null, true);
1213 }
1214 }