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.BrowserRunner;
21 import org.htmlunit.junit.annotation.Alerts;
22 import org.junit.Test;
23 import org.junit.runner.RunWith;
24
25
26
27
28
29
30
31 @RunWith(BrowserRunner.class)
32 public class StyleAttributesIterable2Test extends WebDriverTestCase {
33
34
35
36
37
38
39
40 @Test
41 @Alerts("done")
42 public void notInComputed() throws Exception {
43 styleVsComputed("pixelBottom");
44 }
45
46
47
48
49 @Test
50 @Alerts({"in style", "in computed style", "done"})
51 public void inComputed() throws Exception {
52 styleVsComputed("wordBreak");
53 }
54
55 private void styleVsComputed(final String property) throws Exception {
56 final String html = DOCTYPE_HTML
57 + "<html><head>\n"
58 + "<script>\n"
59 + LOG_TITLE_FUNCTION
60 + " function test() {\n"
61 + " var e = document.getElementById('myDiv');\n"
62 + " for (var i in e.style) {\n"
63 + " if (i == '" + property + "') {\n"
64 + " log('in style');\n"
65 + " }\n"
66 + " }\n"
67 + " for (var i in window.getComputedStyle(e, null)) {\n"
68 + " if (i == '" + property + "') {\n"
69 + " log('in computed style');\n"
70 + " }\n"
71 + " }\n"
72 + " log('done');\n"
73 + " }\n"
74 + "</script></head><body onload='test()'>\n"
75 + " <div id='myDiv'></div>\n"
76 + "</body></html>";
77
78 loadPageVerifyTitle2(html);
79 }
80 }