|
20 | 20 | import org.htmlunit.junit.annotation.HtmlUnitNYI;
|
21 | 21 | import org.junit.Test;
|
22 | 22 | import org.junit.runner.RunWith;
|
| 23 | +import org.openqa.selenium.By; |
| 24 | +import org.openqa.selenium.WebDriver; |
23 | 25 |
|
24 | 26 | /**
|
25 | 27 | * Unit tests for {@code clientHeight} of an element.
|
@@ -2030,4 +2032,171 @@ public void slot() throws Exception {
|
2030 | 2032 | loadPageVerifyTitle2(test("slot"));
|
2031 | 2033 | }
|
2032 | 2034 |
|
| 2035 | + /** |
| 2036 | + * Tests the relation between {@code fontSize} and {@code clientHeight}. |
| 2037 | + * |
| 2038 | + * @throws Exception if the test fails |
| 2039 | + */ |
| 2040 | + @Test |
| 2041 | + @Alerts(DEFAULT = "10, 11, 16, 18, 21, 27, 37, 55", |
| 2042 | + FF = "11, 12, 16, 18, 21, 28, 38, 56", |
| 2043 | + FF_ESR = "11, 12, 16, 18, 21, 28, 38, 56") |
| 2044 | + @HtmlUnitNYI(CHROME = "11, 11, 15, 18, 21, 28, 37, 55", |
| 2045 | + EDGE = "11, 11, 15, 18, 21, 28, 37, 55", |
| 2046 | + FF = "12, 12, 15, 18, 21, 29, 38, 56", |
| 2047 | + FF_ESR = "12, 12, 15, 18, 21, 29, 38, 56") |
| 2048 | + public void clientHeightSmallLarge() throws Exception { |
| 2049 | + final String html = DOCTYPE_HTML |
| 2050 | + + "<html><head><body>\n" |
| 2051 | + + " <div id='myDiv'>a</div>\n" |
| 2052 | + + " <textarea id='myTextarea' cols='120' rows='20'></textarea>\n" |
| 2053 | + + "<script>\n" |
| 2054 | + + "var e = document.getElementById('myDiv');\n" |
| 2055 | + + "var array = [];\n" |
| 2056 | + |
| 2057 | + + "e.style.fontSize = 'xx-small';\n" |
| 2058 | + + "array.push(e.clientHeight);\n" |
| 2059 | + |
| 2060 | + + "e.style.fontSize = 'x-small';\n" |
| 2061 | + + "array.push(e.clientHeight);\n" |
| 2062 | + |
| 2063 | + + "e.style.fontSize = 'small';\n" |
| 2064 | + + "array.push(e.clientHeight);\n" |
| 2065 | + |
| 2066 | + + "e.style.fontSize = 'medium';\n" |
| 2067 | + + "array.push(e.clientHeight);\n" |
| 2068 | + |
| 2069 | + + "e.style.fontSize = 'large';\n" |
| 2070 | + + "array.push(e.clientHeight);\n" |
| 2071 | + |
| 2072 | + + "e.style.fontSize = 'x-large';\n" |
| 2073 | + + "array.push(e.clientHeight);\n" |
| 2074 | + |
| 2075 | + + "e.style.fontSize = 'xx-large';\n" |
| 2076 | + + "array.push(e.clientHeight);\n" |
| 2077 | + |
| 2078 | + + "e.style.fontSize = 'xxx-large';\n" |
| 2079 | + + "array.push(e.clientHeight);\n" |
| 2080 | + |
| 2081 | + + "document.getElementById('myTextarea').value = array.join(', ');\n" |
| 2082 | + + "</script></body></html>"; |
| 2083 | + |
| 2084 | + final WebDriver driver = loadPage2(html); |
| 2085 | + final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); |
| 2086 | + assertEquals(getExpectedAlerts()[0], actual); |
| 2087 | + } |
| 2088 | + |
| 2089 | + /** |
| 2090 | + * Tests the relation between {@code fontSize} and {@code clientHeight}. |
| 2091 | + * |
| 2092 | + * @throws Exception if the test fails |
| 2093 | + */ |
| 2094 | + @Test |
| 2095 | + @Alerts("16, 22") |
| 2096 | + @HtmlUnitNYI(CHROME = "15, 22", |
| 2097 | + EDGE = "15, 22", |
| 2098 | + FF = "15, 22", |
| 2099 | + FF_ESR = "15, 22") |
| 2100 | + public void clientHeightSmallerLarger() throws Exception { |
| 2101 | + final String html = DOCTYPE_HTML |
| 2102 | + + "<html><head><body>\n" |
| 2103 | + + " <div id='myDiv'>a</div>\n" |
| 2104 | + + " <textarea id='myTextarea' cols='120' rows='20'></textarea>\n" |
| 2105 | + + "<script>\n" |
| 2106 | + + "var e = document.getElementById('myDiv');\n" |
| 2107 | + + "var array = [];\n" |
| 2108 | + |
| 2109 | + + "e.style.fontSize = 'smaller';\n" |
| 2110 | + + "array.push(e.clientHeight);\n" |
| 2111 | + |
| 2112 | + + "e.style.fontSize = 'larger';\n" |
| 2113 | + + "array.push(e.clientHeight);\n" |
| 2114 | + |
| 2115 | + + "document.getElementById('myTextarea').value = array.join(', ');\n" |
| 2116 | + + "</script></body></html>"; |
| 2117 | + |
| 2118 | + final WebDriver driver = loadPage2(html); |
| 2119 | + final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); |
| 2120 | + assertEquals(getExpectedAlerts()[0], actual); |
| 2121 | + } |
| 2122 | + |
| 2123 | + /** |
| 2124 | + * Tests the relation between {@code fontSize} and {@code clientHeight}. |
| 2125 | + * |
| 2126 | + * @throws Exception if the test fails |
| 2127 | + */ |
| 2128 | + @Test |
| 2129 | + @Alerts(DEFAULT = "11, 49, 6", |
| 2130 | + FF = "12, 49, 3", |
| 2131 | + FF_ESR = "12, 49, 3") |
| 2132 | + @HtmlUnitNYI(CHROME = "11, 49, 2", |
| 2133 | + EDGE = "11, 49, 2", |
| 2134 | + FF = "12, 49, 3", |
| 2135 | + FF_ESR = "12, 49, 3") |
| 2136 | + public void clientHeightUnits() throws Exception { |
| 2137 | + final String html = DOCTYPE_HTML |
| 2138 | + + "<html><head><body>\n" |
| 2139 | + + " <div id='myDivPX' style='font-size: 10px;'>a</div>\n" |
| 2140 | + + " <div id='myDivEM' style='font-size: 2.7em;'>a</div>\n" |
| 2141 | + + " <div id='myDivP' style='font-size: 10%;'>a</div>\n" |
| 2142 | + + " <textarea id='myTextarea' cols='120' rows='20'></textarea>\n" |
| 2143 | + + "<script>\n" |
| 2144 | + + "var array = [];\n" |
| 2145 | + |
| 2146 | + + "var e = document.getElementById('myDivPX');\n" |
| 2147 | + + "array.push(e.clientHeight);\n" |
| 2148 | + |
| 2149 | + + "e = document.getElementById('myDivEM');\n" |
| 2150 | + + "array.push(e.clientHeight);\n" |
| 2151 | + |
| 2152 | + + "e = document.getElementById('myDivP');\n" |
| 2153 | + + "array.push(e.clientHeight);\n" |
| 2154 | + |
| 2155 | + + "document.getElementById('myTextarea').value = array.join(', ');\n" |
| 2156 | + + "</script></body></html>"; |
| 2157 | + |
| 2158 | + final WebDriver driver = loadPage2(html); |
| 2159 | + final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); |
| 2160 | + assertEquals(getExpectedAlerts()[0], actual); |
| 2161 | + } |
| 2162 | + |
| 2163 | + /** |
| 2164 | + * Tests the relation between {@code fontSize} and {@code clientHeight}. |
| 2165 | + * |
| 2166 | + * @throws Exception if the test fails |
| 2167 | + */ |
| 2168 | + @Test |
| 2169 | + @Alerts(DEFAULT = "12, 49, 6", |
| 2170 | + FF = "13, 49, 4", |
| 2171 | + FF_ESR = "13, 49, 4") |
| 2172 | + @HtmlUnitNYI(CHROME = "12, 49, 4", |
| 2173 | + EDGE = "12, 49, 4", |
| 2174 | + FF = "13, 49, 5", |
| 2175 | + FF_ESR = "13, 49, 5") |
| 2176 | + public void clientHeightUnitsWidth() throws Exception { |
| 2177 | + final String html = DOCTYPE_HTML |
| 2178 | + + "<html><head><body>\n" |
| 2179 | + + " <div id='myDivPX' style='font-size: 11.4px; width: 40px;'>a</div>\n" |
| 2180 | + + " <div id='myDivEM' style='font-size: 2.7em; width: 40px;'>a</div>\n" |
| 2181 | + + " <div id='myDivP' style='font-size: 17%; width: 40px;'>a</div>\n" |
| 2182 | + + " <textarea id='myTextarea' cols='120' rows='20'></textarea>\n" |
| 2183 | + + "<script>\n" |
| 2184 | + + "var array = [];\n" |
| 2185 | + |
| 2186 | + + "var e = document.getElementById('myDivPX');\n" |
| 2187 | + + "array.push(e.clientHeight);\n" |
| 2188 | + |
| 2189 | + + "e = document.getElementById('myDivEM');\n" |
| 2190 | + + "array.push(e.clientHeight);\n" |
| 2191 | + |
| 2192 | + + "e = document.getElementById('myDivP');\n" |
| 2193 | + + "array.push(e.clientHeight);\n" |
| 2194 | + |
| 2195 | + + "document.getElementById('myTextarea').value = array.join(', ');\n" |
| 2196 | + + "</script></body></html>"; |
| 2197 | + |
| 2198 | + final WebDriver driver = loadPage2(html); |
| 2199 | + final String actual = driver.findElement(By.id("myTextarea")).getDomProperty("value"); |
| 2200 | + assertEquals(getExpectedAlerts()[0], actual); |
| 2201 | + } |
2033 | 2202 | }
|
0 commit comments