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.htmlunit.junit.annotation.HtmlUnitNYI;
20 import org.junit.jupiter.api.Test;
21
22
23
24
25
26
27 public class CSSTest extends WebDriverTestCase {
28
29
30
31
32 @Test
33 @Alerts({"[object CSS]", "undefined"})
34 public void global() throws Exception {
35 final String html = DOCTYPE_HTML
36 + "<html><body>\n"
37 + "<style>@charset 'UTF-8';</style>\n"
38 + "<script>\n"
39 + LOG_TITLE_FUNCTION
40 + " try {\n"
41 + " log(CSS);"
42 + " log(CSS.prototype);"
43 + " } catch(e) { logEx(e); }\n"
44 + "</script>\n"
45 + "</body></html>";
46
47 loadPageVerifyTitle2(html);
48 }
49
50
51
52
53 @Test
54 @Alerts("TypeError")
55 public void constructor() throws Exception {
56 final String html = DOCTYPE_HTML
57 + "<html><body>\n"
58 + "<style>@charset 'UTF-8';</style>\n"
59 + "<script>\n"
60 + LOG_TITLE_FUNCTION
61 + " try {\n"
62 + " var o = Object.create(CSS.prototype);\n"
63 + " log(o);"
64 + " } catch(e) { logEx(e); }\n"
65 + "</script>\n"
66 + "</body></html>";
67
68 loadPageVerifyTitle2(html);
69 }
70
71
72
73
74 @Test
75 @Alerts({"true", "true", "true"})
76 public void supports() throws Exception {
77 final String html = DOCTYPE_HTML
78 + "<html><body>\n"
79 + "<script>\n"
80 + LOG_TITLE_FUNCTION
81 + " try {\n"
82 + " log(CSS.supports('display', 'flex'));"
83 + " log(CSS.supports('display', 'grid'));"
84 + " log(CSS.supports('color', 'red'));"
85 + " } catch(e) { logEx(e); }\n"
86 + "</script>\n"
87 + "</body></html>";
88
89 loadPageVerifyTitle2(html);
90 }
91
92
93
94
95 @Test
96 @Alerts({"true", "true"})
97 public void supportsCondition() throws Exception {
98 final String html = DOCTYPE_HTML
99 + "<html><body>\n"
100 + "<script>\n"
101 + LOG_TITLE_FUNCTION
102 + " try {\n"
103 + " log(CSS.supports('display: flex'));"
104 + " log(CSS.supports('color: red'));"
105 + " } catch(e) { logEx(e); }\n"
106 + "</script>\n"
107 + "</body></html>";
108
109 loadPageVerifyTitle2(html);
110 }
111
112
113
114
115 @Test
116 @Alerts({"true", "false"})
117 @HtmlUnitNYI(CHROME = {"true", "true"},
118 EDGE = {"true", "true"},
119 FF = {"true", "true"},
120 FF_ESR = {"true", "true"})
121 public void supportsSelector() throws Exception {
122 final String html = DOCTYPE_HTML
123 + "<html><body>\n"
124 + "<script>\n"
125 + LOG_TITLE_FUNCTION
126 + " try {\n"
127 + " log(CSS.supports('selector(div)'));"
128 + " log(CSS.supports('selector(div, span)'));"
129 + " } catch(e) { logEx(e); }\n"
130 + "</script>\n"
131 + "</body></html>";
132
133 loadPageVerifyTitle2(html);
134 }
135 }