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