1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.html;
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 public class HtmlTemplateTest extends WebDriverTestCase {
27
28
29
30
31 @Test
32 @Alerts({"2", "null", "null"})
33 public void noChilds() throws Exception {
34 final String html = DOCTYPE_HTML
35 + "<html><head>\n"
36 + "<script>\n"
37 + LOG_TITLE_FUNCTION
38 + " function test() {\n"
39 + " log(document.querySelectorAll('form input[type=radio][name=\"rad\"]').length);\n"
40 + " log(document.querySelector('form input[type=radio][name=\"rad\"][value=\"3\"]'));\n"
41 + " log(document.querySelector('form input[type=radio][name=\"rad\"][value=\"4\"]'));\n"
42 + " }\n"
43 + "</script>\n"
44 + "</head>\n"
45 + "<body onload='test()'>\n"
46 + "<form>\n"
47 + " <input type='radio' id='radio1' name='rad' value='1' checked/>\n"
48 + " <input type='radio' name='rad' value='2'/>\n"
49 + " <template>\n"
50 + " <input type='radio' name='rad' value='3' checked/>\n"
51 + " <input type='radio' name='rad' value='4'/>\n"
52 + " </template>\n"
53 + "</body></html>";
54
55 loadPageVerifyTitle2(html);
56 }
57
58
59
60
61 @Test
62 @Alerts("true")
63 public void ignoreContent() throws Exception {
64 final String html = DOCTYPE_HTML
65 + "<html><head>\n"
66 + "<script>\n"
67 + LOG_TITLE_FUNCTION
68 + " function test() {\n"
69 + " log(document.getElementById('radio1').checked);\n"
70 + " }\n"
71 + "</script>\n"
72 + "</head>\n"
73 + "<body onload='test()'>\n"
74 + "<form>\n"
75 + " <input type='radio' id='radio1' name='rad' value='1' checked/>\n"
76 + " <input type='radio' name='rad' value='2'/>\n"
77 + " <template>\n"
78 + " <input type='radio' name='rad' value='3' checked/>\n"
79 + " <input type='radio' name='rad' value='4'/>\n"
80 + " </template>\n"
81 + "</body></html>";
82
83 loadPageVerifyTitle2(html);
84 }
85 }