1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.css;
16
17 import java.net.URL;
18
19 import org.htmlunit.WebDriverTestCase;
20 import org.htmlunit.cssparser.dom.CSSCharsetRuleImpl;
21 import org.htmlunit.junit.annotation.Alerts;
22 import org.htmlunit.util.MimeType;
23 import org.junit.jupiter.api.Test;
24
25
26
27
28
29
30
31
32 public class CSSCharsetRuleTest extends WebDriverTestCase {
33
34
35
36
37 @Test
38 @Alerts("0")
39 public void inStyle() throws Exception {
40 final String html = DOCTYPE_HTML
41 + "<html><body>\n"
42
43 + "<style>@charset \"UTF-8\";</style>\n"
44
45 + "<script>\n"
46 + LOG_TITLE_FUNCTION
47 + " var rules = document.styleSheets[0].cssRules;\n"
48 + " log(rules.length);\n"
49 + "</script>\n"
50
51 + "</body></html>";
52
53 loadPageVerifyTitle2(html);
54 }
55
56
57
58
59 @Test
60 @Alerts("0")
61 public void inLink() throws Exception {
62 final String html = DOCTYPE_HTML
63 + "<html><body>\n"
64
65 + "<link rel='stylesheet' href='imp.css'>\n"
66
67 + "<script>\n"
68 + LOG_TITLE_FUNCTION
69 + " var rules = document.styleSheets[0].cssRules;\n"
70 + " log(rules.length);\n"
71 + "</script>\n"
72
73 + "</body></html>";
74
75 final String css = "@charset \"UTF-8\";";
76 getMockWebConnection().setResponse(new URL(URL_FIRST, "imp.css"), css, MimeType.TEXT_CSS);
77
78 loadPageVerifyTitle2(html);
79 }
80 }