1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.css;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.junit.annotation.Alerts;
19 import org.junit.jupiter.api.Test;
20
21
22
23
24
25
26
27
28 public class CSSFontFaceRuleTest extends WebDriverTestCase {
29
30
31
32
33 @Test
34 @Alerts("TypeError")
35 public void ctor() throws Exception {
36 final String html = DOCTYPE_HTML
37 + "<html><body>\n"
38 + LOG_TEXTAREA
39 + "<script>\n"
40 + LOG_TEXTAREA_FUNCTION
41 + "try {\n"
42 + " var rule = new CSSFontFaceRule();\n"
43 + " log(rule);\n"
44 + "} catch(e) { logEx(e); }\n"
45 + "</script></body></html>";
46
47 loadPageVerifyTextArea2(html);
48 }
49
50
51
52
53 @Test
54 @Alerts({"[object CSSFontFaceRule]", "5",
55 "@font-face { font-family: Delicious; src: url(\"Delicious-Bold.otf\"); }"})
56 public void simple() throws Exception {
57 final String html = DOCTYPE_HTML
58 + "<html><body>\n"
59 + LOG_TEXTAREA
60 + "<style>\n"
61 + " @font-face { font-family: Delicious; src: url('Delicious-Bold.otf'); }\n"
62 + " h3 { font-family: Delicious; }\n"
63 + "</style>\n"
64 + "<script>\n"
65 + LOG_TEXTAREA_FUNCTION
66 + "try {\n"
67 + " var styleSheet = document.styleSheets[0];\n"
68 + " var rule = styleSheet.cssRules[0];\n"
69 + " log(rule);\n"
70 + " log(rule.type);\n"
71 + " log(rule.cssText);\n"
72 + "}\n"
73 + "catch(e) { logEx(e); }\n"
74 + "</script></body></html>";
75
76 loadPageVerifyTextArea2(html);
77 }
78
79
80
81
82 @Test
83 @Alerts("@font-face { font-family: Delicious; src: url(\"//:\"); }")
84 public void urlSlashSlashColon() throws Exception {
85 final String html = DOCTYPE_HTML
86 + "<html><body>\n"
87 + LOG_TEXTAREA
88 + "<style>\n"
89 + " @font-face { font-family: Delicious; src: url(//:); }\n"
90 + " h3 { font-family: Delicious; }\n"
91 + "</style>\n"
92 + "<script>\n"
93 + LOG_TEXTAREA_FUNCTION
94 + "try {\n"
95 + " var styleSheet = document.styleSheets[0];\n"
96 + " var rule = styleSheet.cssRules[0];\n"
97 + " log(rule.cssText);\n"
98 + "}\n"
99 + "catch(e) { logEx(e); }\n"
100 + "</script></body></html>";
101
102 loadPageVerifyTextArea2(html);
103 }
104
105
106
107
108 @Test
109 @Alerts("@font-face { font-family: Delicious; src: url(\"/:\"); }")
110 public void urlSlashColon() throws Exception {
111 final String html = DOCTYPE_HTML
112 + "<html><body>\n"
113 + LOG_TEXTAREA
114 + "<style>\n"
115 + " @font-face { font-family: Delicious; src: url(/:); }\n"
116 + " h3 { font-family: Delicious; }\n"
117 + "</style>\n"
118 + "<script>\n"
119 + LOG_TEXTAREA_FUNCTION
120 + "try {\n"
121 + " var styleSheet = document.styleSheets[0];\n"
122 + " var rule = styleSheet.cssRules[0];\n"
123 + " log(rule.cssText);\n"
124 + "}\n"
125 + "catch(e) { logEx(e); }\n"
126 + "</script></body></html>";
127
128 loadPageVerifyTextArea2(html);
129 }
130
131
132
133
134 @Test
135 @Alerts("@font-face { font-family: Delicious; src: url(\"//\"); }")
136 public void urlSlashSlash() throws Exception {
137 final String html = DOCTYPE_HTML
138 + "<html><body>\n"
139 + LOG_TEXTAREA
140 + "<style>\n"
141 + " @font-face { font-family: Delicious; src: url(//); }\n"
142 + " h3 { font-family: Delicious; }\n"
143 + "</style>\n"
144 + "<script>\n"
145 + LOG_TEXTAREA_FUNCTION
146 + "try {\n"
147 + " var styleSheet = document.styleSheets[0];\n"
148 + " var rule = styleSheet.cssRules[0];\n"
149 + " log(rule.cssText);\n"
150 + "}\n"
151 + "catch(e) { logEx(e); }\n"
152 + "</script></body></html>";
153
154 loadPageVerifyTextArea2(html);
155 }
156 }