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 @RunWith(BrowserRunner.class)
28 public class HTMLDataElementTest extends WebDriverTestCase {
29
30
31
32
33 @Test
34 @Alerts("[object HTMLDataElement]")
35 public void tag() throws Exception {
36 final String html = DOCTYPE_HTML
37 + "<html><body>\n"
38 + " <data id='it' value='1234'>onetwothreefour</data>\n"
39 + "<script>\n"
40 + LOG_TITLE_FUNCTION
41 + " log(document.getElementById('it'));\n"
42 + "</script></body></html>";
43
44 loadPageVerifyTitle2(html);
45 }
46
47
48
49
50 @Test
51 @Alerts({"1234", "#12o", "", "#12o"})
52 public void value() throws Exception {
53 final String html = DOCTYPE_HTML
54 + "<html><body>\n"
55 + " <data id='d1' value='1234'>onetwothreefour</data>\n"
56 + " <data id='d2' >onetwothreefour</data>\n"
57 + "<script>\n"
58 + LOG_TITLE_FUNCTION
59 + " var dat = document.getElementById('d1');\n"
60 + " log(dat.value);\n"
61 + " dat.value = '#12o';\n"
62 + " log(dat.value);\n"
63
64 + " dat = document.getElementById('d2');\n"
65 + " log(dat.value);\n"
66 + " dat.value = '#12o';\n"
67 + " log(dat.value);\n"
68 + "</script></body></html>";
69 loadPageVerifyTitle2(html);
70 }
71 }