Skip to content

Commit 4af2128

Browse files
committed
some more not/has/is/where fixes
1 parent e1db5c1 commit 4af2128

File tree

1 file changed

+147
-1
lines changed

1 file changed

+147
-1
lines changed

src/test/java/org/htmlunit/javascript/host/css/CSSSelector3Test.java

Lines changed: 147 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,81 @@
1919
import org.junit.jupiter.api.Test;
2020

2121
/**
22-
* Tests for css pseudo selectors :is(), :where() and :has().
22+
* Tests for css pseudo selectors :not(), :is(), :where() and :has().
2323
*
2424
* @author Ronald Brill
2525
*
2626
*/
2727
public class CSSSelector3Test extends WebDriverTestCase {
2828

29+
/**
30+
* @throws Exception if the test fails
31+
*/
32+
@Test
33+
@Alerts({"6", "[object HTMLBodyElement]", "[object HTMLLIElement]", "[object HTMLScriptElement]",
34+
"5", "[object HTMLBodyElement]", "[object HTMLScriptElement]",
35+
"5", "[object HTMLBodyElement]", "[object HTMLScriptElement]"})
36+
public void notElement() throws Exception {
37+
final String html = DOCTYPE_HTML
38+
+ "<html>\n"
39+
+ "<head><title></title></head>\n"
40+
+ "<body>\n"
41+
+ "<ul>\n"
42+
+ " <li>ul - item 0</li>\n"
43+
+ "</ul>\n"
44+
45+
+ "<script>\n"
46+
+ LOG_TITLE_FUNCTION
47+
+ " try {\n"
48+
+ " let items = document.querySelectorAll(':not(ul)');"
49+
+ " log(items.length);\n"
50+
+ " log(items[3]);\n"
51+
+ " log(items[4]);\n"
52+
+ " log(items[5]);\n"
53+
54+
+ " items = document.querySelectorAll(':not(ul, li)');"
55+
+ " log(items.length);\n"
56+
+ " log(items[3]);\n"
57+
+ " log(items[4]);\n"
58+
59+
+ " items = document.querySelectorAll(':not(ul):not(li)');"
60+
+ " log(items.length);\n"
61+
+ " log(items[3]);\n"
62+
+ " log(items[4]);\n"
63+
+ " } catch (e) { logEx(e); }\n"
64+
+ "</script>\n"
65+
66+
+ "</body></html>";
67+
68+
loadPageVerifyTitle2(html);
69+
}
70+
71+
/**
72+
* @throws Exception if the test fails
73+
*/
74+
@Test
75+
@Alerts("SyntaxError/DOMException")
76+
public void notDoubleColon() throws Exception {
77+
final String html = DOCTYPE_HTML
78+
+ "<html>\n"
79+
+ "<head><title></title></head>\n"
80+
+ "<body>\n"
81+
+ "<ul>\n"
82+
+ " <li>ul - item 0</li>\n"
83+
+ "</ul>\n"
84+
85+
+ "<script>\n"
86+
+ LOG_TITLE_FUNCTION
87+
+ " try {\n"
88+
+ " let items = document.querySelectorAll('::not(ul)');"
89+
+ " } catch (e) { logEx(e); }\n"
90+
+ "</script>\n"
91+
92+
+ "</body></html>";
93+
94+
loadPageVerifyTitle2(html);
95+
}
96+
2997
/**
3098
* @throws Exception if the test fails
3199
*/
@@ -136,6 +204,32 @@ public void isDuplicates() throws Exception {
136204
loadPageVerifyTitle2(html);
137205
}
138206

207+
/**
208+
* @throws Exception if the test fails
209+
*/
210+
@Test
211+
@Alerts("SyntaxError/DOMException")
212+
public void isDoubleColon() throws Exception {
213+
final String html = DOCTYPE_HTML
214+
+ "<html>\n"
215+
+ "<head><title></title></head>\n"
216+
+ "<body>\n"
217+
+ "<ul>\n"
218+
+ " <li>ul - item 0</li>\n"
219+
+ "</ul>\n"
220+
221+
+ "<script>\n"
222+
+ LOG_TITLE_FUNCTION
223+
+ " try {\n"
224+
+ " let items = document.querySelectorAll('::is(ul)');"
225+
+ " } catch (e) { logEx(e); }\n"
226+
+ "</script>\n"
227+
228+
+ "</body></html>";
229+
230+
loadPageVerifyTitle2(html);
231+
}
232+
139233
/**
140234
* @throws Exception if the test fails
141235
*/
@@ -246,6 +340,32 @@ public void whereDuplicates() throws Exception {
246340
loadPageVerifyTitle2(html);
247341
}
248342

343+
/**
344+
* @throws Exception if the test fails
345+
*/
346+
@Test
347+
@Alerts("SyntaxError/DOMException")
348+
public void whereDoubleColon() throws Exception {
349+
final String html = DOCTYPE_HTML
350+
+ "<html>\n"
351+
+ "<head><title></title></head>\n"
352+
+ "<body>\n"
353+
+ "<ul>\n"
354+
+ " <li>ul - item 0</li>\n"
355+
+ "</ul>\n"
356+
357+
+ "<script>\n"
358+
+ LOG_TITLE_FUNCTION
359+
+ " try {\n"
360+
+ " let items = document.querySelectorAll('::where(ul)');"
361+
+ " } catch (e) { logEx(e); }\n"
362+
+ "</script>\n"
363+
364+
+ "</body></html>";
365+
366+
loadPageVerifyTitle2(html);
367+
}
368+
249369
/**
250370
* @throws Exception if the test fails
251371
*/
@@ -583,4 +703,30 @@ public void hasAnd() throws Exception {
583703

584704
loadPageVerifyTitle2(html);
585705
}
706+
707+
/**
708+
* @throws Exception if the test fails
709+
*/
710+
@Test
711+
@Alerts("SyntaxError/DOMException")
712+
public void hasDoubleColon() throws Exception {
713+
final String html = DOCTYPE_HTML
714+
+ "<html>\n"
715+
+ "<head><title></title></head>\n"
716+
+ "<body>\n"
717+
+ "<ul>\n"
718+
+ " <li>ul - item 0</li>\n"
719+
+ "</ul>\n"
720+
721+
+ "<script>\n"
722+
+ LOG_TITLE_FUNCTION
723+
+ " try {\n"
724+
+ " let items = document.querySelectorAll('::has(ul)');"
725+
+ " } catch (e) { logEx(e); }\n"
726+
+ "</script>\n"
727+
728+
+ "</body></html>";
729+
730+
loadPageVerifyTitle2(html);
731+
}
586732
}

0 commit comments

Comments
 (0)