1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.css;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.javascript.host.css.CSSStyleDeclaration;
19 import org.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration;
20 import org.htmlunit.junit.annotation.Alerts;
21 import org.junit.jupiter.api.Test;
22
23
24
25
26
27
28
29 public class StyleAttributesIterable2Test extends WebDriverTestCase {
30
31
32
33
34
35
36
37 @Test
38 @Alerts("done")
39 public void notInComputed() throws Exception {
40 styleVsComputed("pixelBottom");
41 }
42
43
44
45
46 @Test
47 @Alerts({"in style", "in computed style", "done"})
48 public void inComputed() throws Exception {
49 styleVsComputed("wordBreak");
50 }
51
52 private void styleVsComputed(final String property) throws Exception {
53 final String html = DOCTYPE_HTML
54 + "<html><head>\n"
55 + "<script>\n"
56 + LOG_TITLE_FUNCTION
57 + " function test() {\n"
58 + " var e = document.getElementById('myDiv');\n"
59 + " for (var i in e.style) {\n"
60 + " if (i == '" + property + "') {\n"
61 + " log('in style');\n"
62 + " }\n"
63 + " }\n"
64 + " for (var i in window.getComputedStyle(e, null)) {\n"
65 + " if (i == '" + property + "') {\n"
66 + " log('in computed style');\n"
67 + " }\n"
68 + " }\n"
69 + " log('done');\n"
70 + " }\n"
71 + "</script></head><body onload='test()'>\n"
72 + " <div id='myDiv'></div>\n"
73 + "</body></html>";
74
75 loadPageVerifyTitle2(html);
76 }
77 }