1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.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
27 public class HTMLProgressElementTest extends WebDriverTestCase {
28
29
30
31
32 @Test
33 @Alerts({"0", "2", "1", "2", "1", "1"})
34 public void labels() throws Exception {
35 final String html = DOCTYPE_HTML
36 + "<html><head>\n"
37 + " <script>\n"
38 + LOG_TITLE_FUNCTION
39 + " function test() {\n"
40 + " debug(document.getElementById('e1'));\n"
41 + " debug(document.getElementById('e2'));\n"
42 + " debug(document.getElementById('e3'));\n"
43 + " debug(document.getElementById('e4'));\n"
44 + " var labels = document.getElementById('e4').labels;\n"
45 + " document.body.removeChild(document.getElementById('l4'));\n"
46 + " debug(document.getElementById('e4'));\n"
47 + " log(labels ? labels.length : labels);\n"
48 + " }\n"
49 + " function debug(e) {\n"
50 + " log(e.labels ? e.labels.length : e.labels);\n"
51 + " }\n"
52 + " </script>\n"
53 + "</head>\n"
54 + "<body onload='test()'>\n"
55 + " <progress id='e1'>e 1</progress><br>\n"
56 + " <label>something <label> click here <progress id='e2'>e 2</progress></label></label><br>\n"
57 + " <label for='e3'> and here</label>\n"
58 + " <progress id='e3'>e 3</progress><br>\n"
59 + " <label id='l4' for='e4'> what about</label>\n"
60 + " <label> this<progress id='e4'>e 4</progress></label><br>\n"
61 + "</body></html>";
62
63 loadPageVerifyTitle2(html);
64 }
65
66
67
68
69 @Test
70 @Alerts({"0", "number"})
71 public void value() throws Exception {
72 final String html = DOCTYPE_HTML
73 + "<html><head>\n"
74 + " <script>\n"
75 + LOG_TITLE_FUNCTION
76 + " function test() {\n"
77 + " var e1 = document.getElementById('e1');\n"
78 + " log(e1.value);\n"
79 + " log(typeof e1.value);\n"
80 + " }\n"
81 + " </script>\n"
82 + "</head>\n"
83 + "<body onload='test()'>\n"
84 + " <progress id='e1'>e 1</progress>\n"
85 + "</body></html>";
86
87 loadPageVerifyTitle2(html);
88 }
89 }