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.BrowserRunner;
22 import org.htmlunit.junit.annotation.Alerts;
23 import org.htmlunit.util.MimeType;
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26
27
28
29
30
31
32
33
34 @RunWith(BrowserRunner.class)
35 public class CSSCharsetRuleTest extends WebDriverTestCase {
36
37
38
39
40 @Test
41 @Alerts("0")
42 public void inStyle() throws Exception {
43 final String html = DOCTYPE_HTML
44 + "<html><body>\n"
45
46 + "<style>@charset \"UTF-8\";</style>\n"
47
48 + "<script>\n"
49 + LOG_TITLE_FUNCTION
50 + " var rules = document.styleSheets[0].cssRules;\n"
51 + " log(rules.length);\n"
52 + "</script>\n"
53
54 + "</body></html>";
55
56 loadPageVerifyTitle2(html);
57 }
58
59
60
61
62 @Test
63 @Alerts("0")
64 public void inLink() throws Exception {
65 final String html = DOCTYPE_HTML
66 + "<html><body>\n"
67
68 + "<link rel='stylesheet' href='imp.css'>\n"
69
70 + "<script>\n"
71 + LOG_TITLE_FUNCTION
72 + " var rules = document.styleSheets[0].cssRules;\n"
73 + " log(rules.length);\n"
74 + "</script>\n"
75
76 + "</body></html>";
77
78 final String css = "@charset \"UTF-8\";";
79 getMockWebConnection().setResponse(new URL(URL_FIRST, "imp.css"), css, MimeType.TEXT_CSS);
80
81 loadPageVerifyTitle2(html);
82 }
83 }