1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.css;
16
17 import java.util.ArrayList;
18 import java.util.Collection;
19 import java.util.List;
20
21 import org.htmlunit.BrowserVersion;
22 import org.htmlunit.WebDriverTestCase;
23 import org.htmlunit.css.StyleAttributes.Definition;
24 import org.junit.jupiter.params.ParameterizedTest;
25 import org.junit.jupiter.params.provider.Arguments;
26 import org.junit.jupiter.params.provider.MethodSource;
27
28
29
30
31
32
33
34 public class StyleAttributesIterableTest extends WebDriverTestCase {
35
36 private static int ServerRestartCount_ = 0;
37
38
39
40
41
42
43 public static Collection<Arguments> data() throws Exception {
44 final List<Arguments> list = new ArrayList<>();
45 for (final Definition definition : StyleAttributes.Definition.values()) {
46 list.add(Arguments.of(definition));
47 }
48 return list;
49 }
50
51
52
53
54 @Override
55 protected String[] getExpectedAlerts() {
56 if (definition_ == null) {
57 return super.getExpectedAlerts();
58 }
59 final BrowserVersion browserVersion = getBrowserVersion();
60 return new String[] {Boolean.toString(definition_.isAvailable(browserVersion, true))};
61 }
62
63
64
65
66 private Definition definition_;
67
68
69
70
71
72
73 @ParameterizedTest
74 @MethodSource("data")
75 public void test(final Definition definition) throws Exception {
76 definition_ = definition;
77 test(definition_.getPropertyName());
78 }
79
80 private void test(final String propertyName) throws Exception {
81 ServerRestartCount_++;
82 if (ServerRestartCount_ == 200) {
83 stopWebServers();
84 ServerRestartCount_ = 0;
85 }
86
87 final String html = DOCTYPE_HTML
88 + "<html><head><script>\n"
89 + LOG_TITLE_FUNCTION
90 + " function test() {\n"
91 + " var e = document.getElementById('myDiv');\n"
92 + " for (var i in e.style) {\n"
93 + " if (i == '" + propertyName + "') {\n"
94 + " log('true');\n"
95 + " return;\n"
96 + " }\n"
97 + " }\n"
98 + " log('false');\n"
99 + " }\n"
100 + "</script></head>\n"
101 + "<body onload='test()'>\n"
102 + " <div id='myDiv'></div>\n"
103 + "</body></html>";
104
105 loadPageVerifyTitle2(html);
106 }
107 }