1414 */
1515package org .htmlunit .javascript .host .css ;
1616
17- import static org .htmlunit .junit .annotation .TestedBrowser .FF ;
18- import static org .htmlunit .junit .annotation .TestedBrowser .FF_ESR ;
19-
2017import java .io .InputStream ;
2118import java .net .URL ;
2219import java .util .Collections ;
2724import org .htmlunit .junit .BrowserRunner ;
2825import org .htmlunit .junit .annotation .Alerts ;
2926import org .htmlunit .junit .annotation .HtmlUnitNYI ;
30- import org .htmlunit .junit .annotation .NotYetImplemented ;
3127import org .junit .Test ;
3228import org .junit .runner .RunWith ;
3329import org .openqa .selenium .By ;
@@ -119,7 +115,7 @@ public void stringProperties() throws Exception {
119115 + " for (var i in e.style) {\n "
120116 + " var s1 = e.style[i];\n "
121117 + " var s2 = window.getComputedStyle(e, null)[i];\n "
122- + " if ('height' == i || 'width' == i || ' cssText' == i) {\n "
118+ + " if ('cssText' == i) {\n "
123119 + " s2 = 'skipped';\n "
124120 + " }\n "
125121 + " if(typeof s1 == 'string')\n "
@@ -136,13 +132,48 @@ public void stringProperties() throws Exception {
136132 assertEquals (expected , actual );
137133 }
138134
135+ /**
136+ * Compares all {@code style} and {@code getComputedStyle}.
137+ *
138+ * @throws Exception if the test fails
139+ */
140+ @ Test
141+ public void stringPropertiesDisplayNone () throws Exception {
142+ final String html
143+ = "<html><head><body>\n "
144+ + " <div id='myDiv' style='display: none'><br>\n "
145+ + " <textarea id='myTextarea' cols='120' rows='20'></textarea>\n "
146+ + " </div>\n "
147+ + "<script>\n "
148+ + "var e = document.getElementById('myDiv');\n "
149+ + "var array = [];\n "
150+ + "try {\n "
151+ + " for (var i in e.style) {\n "
152+ + " var s1 = e.style[i];\n "
153+ + " var s2 = window.getComputedStyle(e, null)[i];\n "
154+ + " if ('cssText' == i) {\n "
155+ + " s2 = 'skipped';\n "
156+ + " }\n "
157+ + " if(typeof s1 == 'string')\n "
158+ + " array.push(i + '=' + s1 + ':' + s2);\n "
159+ + " }\n "
160+ + "} catch(e) { array[array.length] = e.name; }\n "
161+ + "array.sort();\n "
162+ + "document.getElementById('myTextarea').value = array.join('\\ n');\n "
163+ + "</script></body></html>" ;
164+
165+ final WebDriver driver = loadPage2 (html );
166+ final String expected = loadExpectation ("ComputedCSSStyleDeclarationTest.properties.displayNone" , ".txt" );
167+ final String actual = driver .findElement (By .id ("myTextarea" )).getDomProperty ("value" );
168+ assertEquals (expected , actual );
169+ }
170+
139171 /**
140172 * Compares all {@code style} and {@code getComputedStyle}, for not-attached elements.
141173 *
142174 * @throws Exception if the test fails
143175 */
144176 @ Test
145- @ NotYetImplemented
146177 public void stringPropertiesNotAttached () throws Exception {
147178 // to fix Chrome, look into ComputedCSSStyleDeclaration.defaultIfEmpty first condition
148179 final String html
@@ -156,7 +187,7 @@ public void stringPropertiesNotAttached() throws Exception {
156187 + " for (var i in e.style) {\n "
157188 + " var s1 = e.style[i];\n "
158189 + " var s2 = window.getComputedStyle(e, null)[i];\n "
159- + " if ('height' == i || 'width' == i || ' cssText' == i) {\n "
190+ + " if ('cssText' == i) {\n "
160191 + " s2 = 'skipped';\n "
161192 + " }\n "
162193 + " if(typeof s1 == 'string')\n "
@@ -1194,7 +1225,10 @@ public void fontSizeVW() throws Exception {
11941225 */
11951226 @ Test
11961227 @ Alerts ({"111px" , "auto" })
1197- @ NotYetImplemented
1228+ @ HtmlUnitNYI (CHROME = {"1256px" , "auto" },
1229+ EDGE = {"1256px" , "auto" },
1230+ FF = {"1256px" , "auto" },
1231+ FF_ESR = {"1256px" , "auto" })
11981232 public void computedWidthOfHiddenElements () throws Exception {
11991233 final String content = "<html><head><script>\n "
12001234 + LOG_TITLE_FUNCTION
@@ -1251,7 +1285,10 @@ public void inheritedImplicitly() throws Exception {
12511285 EDGE = { "underline solid rgb(0, 0, 0)" , "none solid rgb(0, 0, 0)" , "underline solid rgb(0, 0, 0)" },
12521286 FF = {"underline rgb(0, 0, 0)" , "rgb(0, 0, 0)" , "underline rgb(0, 0, 0)" },
12531287 FF_ESR = {"underline rgb(0, 0, 0)" , "rgb(0, 0, 0)" , "underline rgb(0, 0, 0)" })
1254- @ NotYetImplemented
1288+ @ HtmlUnitNYI (CHROME = { "underline" , "none solid rgb(0, 0, 0)" , "underline" },
1289+ EDGE = { "underline" , "none solid rgb(0, 0, 0)" , "underline" },
1290+ FF = { "underline" , "rgb(0, 0, 0)" , "underline" },
1291+ FF_ESR = { "underline" , "rgb(0, 0, 0)" , "underline" })
12551292 public void changeInParentClassNodeReferencedByRule () throws Exception {
12561293 final String html = "<html><head>\n "
12571294 + "<script>\n "
@@ -1614,7 +1651,10 @@ public void widthAuto() throws Exception {
16141651 */
16151652 @ Test
16161653 @ Alerts ({"" , "rgb(0, 0, 255)" })
1617- @ NotYetImplemented
1654+ @ HtmlUnitNYI (CHROME = {"red" , "rgb(0, 0, 255)" },
1655+ EDGE = {"red" , "rgb(0, 0, 255)" },
1656+ FF = {"red" , "rgb(0, 0, 255)" },
1657+ FF_ESR = {"red" , "rgb(0, 0, 255)" })
16181658 public void getPropertyValue () throws Exception {
16191659 final String html = "<html><head><script>\n "
16201660 + LOG_TITLE_FUNCTION
@@ -1764,7 +1804,10 @@ public void offsetHeight_with_child() throws Exception {
17641804 */
17651805 @ Test
17661806 @ Alerts ("81" )
1767- @ NotYetImplemented
1807+ @ HtmlUnitNYI (CHROME = "18" ,
1808+ EDGE = "18" ,
1809+ FF = "18" ,
1810+ FF_ESR = "18" )
17681811 public void offsetHeight_with_childHeight () throws Exception {
17691812 final String html = "<html><head><script>\n "
17701813 + LOG_TITLE_FUNCTION
@@ -2145,7 +2188,8 @@ public void selector() throws Exception {
21452188 @ Alerts (DEFAULT = {"" , "0px" , "20%" , "80px" , "25%" , "100px" },
21462189 FF = {"" , "0px" , "20%" , "360px" , "25%" , "100px" },
21472190 FF_ESR = {"" , "0px" , "20%" , "360px" , "25%" , "100px" })
2148- @ NotYetImplemented ({FF , FF_ESR })
2191+ @ HtmlUnitNYI (FF = {"" , "0px" , "20%" , "80px" , "25%" , "100px" },
2192+ FF_ESR = {"" , "0px" , "20%" , "80px" , "25%" , "100px" })
21492193 public void marginLeftRight () throws Exception {
21502194 final String html = "<html><head><script>\n "
21512195 + LOG_TITLE_FUNCTION
@@ -2184,7 +2228,10 @@ public void marginLeftRight() throws Exception {
21842228 */
21852229 @ Test
21862230 @ Alerts ({"" , "0px" , "" , "0px" , "50%" , "100px" , "50%" , "100px" })
2187- @ NotYetImplemented
2231+ @ HtmlUnitNYI (CHROME = {"" , "auto" , "" , "auto" , "50%" , "100px" , "50%" , "100px" },
2232+ EDGE = {"" , "auto" , "" , "auto" , "50%" , "100px" , "50%" , "100px" },
2233+ FF = {"" , "auto" , "" , "auto" , "50%" , "100px" , "50%" , "100px" },
2234+ FF_ESR = {"" , "auto" , "" , "auto" , "50%" , "100px" , "50%" , "100px" })
21882235 public void topLeft () throws Exception {
21892236 final String html = "<html><head><script>\n "
21902237 + LOG_TITLE_FUNCTION
@@ -2397,7 +2444,10 @@ public void bodyOffsetWidth() throws Exception {
23972444 */
23982445 @ Test
23992446 @ Alerts ({"0" , "24" })
2400- @ NotYetImplemented
2447+ @ HtmlUnitNYI (CHROME = {"0" , "18" },
2448+ EDGE = {"0" , "18" },
2449+ FF = {"0" , "18" },
2450+ FF_ESR = {"0" , "18" })
24012451 public void offsetHeightTable () throws Exception {
24022452 final String html = "<html><head>\n "
24032453 + "<script>\n "
0 commit comments