Skip to content

Commit e718fa5

Browse files
committed
more detailed tests
1 parent affc1ae commit e718fa5

13 files changed

+3593
-42
lines changed

src/test/java/org/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
*/
1515
package 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-
2017
import java.io.InputStream;
2118
import java.net.URL;
2219
import java.util.Collections;
@@ -27,7 +24,6 @@
2724
import org.htmlunit.junit.BrowserRunner;
2825
import org.htmlunit.junit.annotation.Alerts;
2926
import org.htmlunit.junit.annotation.HtmlUnitNYI;
30-
import org.htmlunit.junit.annotation.NotYetImplemented;
3127
import org.junit.Test;
3228
import org.junit.runner.RunWith;
3329
import 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"

src/test/resources/org/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.properties.Chrome.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ gridTemplate=:none
219219
gridTemplateAreas=:none
220220
gridTemplateColumns=:none
221221
gridTemplateRows=:none
222-
height=:skipped
222+
height=:49px
223223
hyphenateCharacter=:auto
224224
hyphenateLimitChars=:auto
225225
hyphens=:manual
@@ -633,7 +633,7 @@ webkitWritingMode=:horizontal-tb
633633
whiteSpace=:normal
634634
whiteSpaceCollapse=:collapse
635635
widows=:2
636-
width=:skipped
636+
width=:1256px
637637
willChange=:auto
638638
wordBreak=:normal
639639
wordSpacing=:0px

src/test/resources/org/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.properties.Edge.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ gridTemplate=:none
219219
gridTemplateAreas=:none
220220
gridTemplateColumns=:none
221221
gridTemplateRows=:none
222-
height=:skipped
222+
height=:49px
223223
hyphenateCharacter=:auto
224224
hyphenateLimitChars=:auto
225225
hyphens=:manual
@@ -633,7 +633,7 @@ webkitWritingMode=:horizontal-tb
633633
whiteSpace=:normal
634634
whiteSpaceCollapse=:collapse
635635
widows=:2
636-
width=:skipped
636+
width=:1256px
637637
willChange=:auto
638638
wordBreak=:normal
639639
wordSpacing=:0px

src/test/resources/org/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.properties.FF-ESR.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ gridTemplate=:none
608608
gridTemplateAreas=:none
609609
gridTemplateColumns=:none
610610
gridTemplateRows=:none
611-
height=:skipped
611+
height=:49px
612612
hyphenate-character=:auto
613613
hyphenateCharacter=:auto
614614
hyphens=:manual
@@ -1083,7 +1083,7 @@ white-space-collapse=:collapse
10831083
white-space=:normal
10841084
whiteSpace=:normal
10851085
whiteSpaceCollapse=:collapse
1086-
width=:skipped
1086+
width=:1256px
10871087
will-change=:auto
10881088
willChange=:auto
10891089
word-break=:normal

src/test/resources/org/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.properties.FF.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ gridTemplate=:none
614614
gridTemplateAreas=:none
615615
gridTemplateColumns=:none
616616
gridTemplateRows=:none
617-
height=:skipped
617+
height=:49px
618618
hyphenate-character=:auto
619619
hyphenateCharacter=:auto
620620
hyphens=:manual
@@ -1092,7 +1092,7 @@ white-space-collapse=:collapse
10921092
white-space=:normal
10931093
whiteSpace=:normal
10941094
whiteSpaceCollapse=:collapse
1095-
width=:skipped
1095+
width=:1256px
10961096
will-change=:auto
10971097
willChange=:auto
10981098
word-break=:normal

0 commit comments

Comments
 (0)