Skip to content

Commit 4cbf012

Browse files
committed
faster tests
1 parent 836c759 commit 4cbf012

File tree

1 file changed

+57
-46
lines changed

1 file changed

+57
-46
lines changed

src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclarationTest.java

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,21 @@ public class CSSStyleDeclarationTest extends WebDriverTestCase {
6262
public void style_OneCssAttribute() throws Exception {
6363
final String html
6464
= "<html><head><script>\n"
65+
+ LOG_TITLE_FUNCTION
6566
+ "function doTest() {\n"
6667
+ " var node = document.getElementById('div1');\n"
6768
+ " var style = node.style;\n"
68-
+ " alert(style.color);\n"
69+
+ " log(style.color);\n"
6970
+ " style.color = 'pink';\n"
70-
+ " alert(style.color);\n"
71-
+ " alert(node.getAttribute('style'));\n"
71+
+ " log(style.color);\n"
72+
+ " log(node.getAttribute('style'));\n"
7273
+ "}\n</script></head>\n"
7374
+ "<body onload='doTest()'><div id='div1' style='color: black'>foo</div></body></html>";
7475

7576
final String style = getExpectedAlerts()[getExpectedAlerts().length - 1];
7677

7778
setExpectedAlerts(Arrays.copyOf(getExpectedAlerts(), getExpectedAlerts().length - 1));
78-
final WebDriver driver = loadPageWithAlerts2(html);
79+
final WebDriver driver = loadPageVerifyTitle2(html);
7980

8081
assertEquals(style, driver.findElement(By.id("div1")).getAttribute("style"));
8182
}
@@ -95,20 +96,21 @@ public void style_OneCssAttribute() throws Exception {
9596
IE = {"black", "pink", "color: pink; background: blue; foo: bar;"})
9697
public void style_MultipleCssAttributes() throws Exception {
9798
final String html
98-
= "<html><head><title>First</title><script>\n"
99+
= "<html><head><script>\n"
100+
+ LOG_TITLE_FUNCTION
99101
+ "function doTest() {\n"
100102
+ " var style = document.getElementById('div1').style;\n"
101-
+ " alert(style.color);\n"
103+
+ " log(style.color);\n"
102104
+ " style.color = 'pink';\n"
103-
+ " alert(style.color);\n"
105+
+ " log(style.color);\n"
104106
+ "}\n</script></head>\n"
105107
+ "<body onload='doTest()'>\n"
106108
+ "<div id='div1' style='color: black;background:blue;foo:bar'>foo</div></body></html>";
107109

108110
final String style = getExpectedAlerts()[getExpectedAlerts().length - 1];
109111

110112
setExpectedAlerts(Arrays.copyOf(getExpectedAlerts(), getExpectedAlerts().length - 1));
111-
final WebDriver driver = loadPageWithAlerts2(html);
113+
final WebDriver driver = loadPageVerifyTitle2(html);
112114

113115
assertEquals(style, driver.findElement(By.id("div1")).getAttribute("style"));
114116
}
@@ -121,19 +123,20 @@ public void style_MultipleCssAttributes() throws Exception {
121123
public void style_OneUndefinedCssAttribute() throws Exception {
122124
final String html
123125
= "<html><head><script>\n"
126+
+ LOG_TITLE_FUNCTION
124127
+ "function doTest() {\n"
125128
+ " var style = document.getElementById('div1').style;\n"
126-
+ " alert(document.getElementById('nonexistingid'));\n"
127-
+ " alert(style.color);\n"
129+
+ " log(document.getElementById('nonexistingid'));\n"
130+
+ " log(style.color);\n"
128131
+ " style.color = 'pink';\n"
129-
+ " alert(style.color);\n"
132+
+ " log(style.color);\n"
130133
+ "}\n</script></head>\n"
131134
+ "<body onload='doTest()'><div id='div1'>foo</div></body></html>";
132135

133136
final String style = getExpectedAlerts()[getExpectedAlerts().length - 1];
134137

135138
setExpectedAlerts(Arrays.copyOf(getExpectedAlerts(), getExpectedAlerts().length - 1));
136-
final WebDriver driver = loadPageWithAlerts2(html);
139+
final WebDriver driver = loadPageVerifyTitle2(html);
137140

138141
assertEquals(style, driver.findElement(By.id("div1")).getAttribute("style"));
139142
}
@@ -606,11 +609,12 @@ public void initUnsupportdProperty() throws Exception {
606609
+ "<div id='my' style='htmlunit: foo'>d</div>\n"
607610

608611
+ "<script>\n"
612+
+ LOG_TITLE_FUNCTION
609613
+ " d = document.getElementById('my');\n"
610-
+ " alert(d.style.htmlunit);\n"
614+
+ " log(d.style.htmlunit);\n"
611615
+ "</script>\n"
612616
+ "</body></html>";
613-
loadPageWithAlerts2(html);
617+
loadPageVerifyTitle2(html);
614618
}
615619

616620
/**
@@ -1592,18 +1596,19 @@ private void setPropertyBackgroundColor(final String params, final String... exp
15921596
"<html><body onload='test()'>\n"
15931597
+ "<a id='a' href='#' style='background-color:green'>go</a>\n"
15941598
+ "<script>\n"
1599+
+ LOG_TITLE_FUNCTION
15951600
+ " function test() {\n"
15961601
+ " var node = document.getElementById('a');\n"
15971602
+ " try {\n"
15981603
+ " node.style.setProperty(" + params + ");\n"
1599-
+ " alert(node.style.backgroundColor + ' ' + node.style.getPropertyPriority('background-color'));\n"
1600-
+ " } catch(e) { alert(e); }\n"
1604+
+ " log(node.style.backgroundColor + ' ' + node.style.getPropertyPriority('background-color'));\n"
1605+
+ " } catch(e) { log(e); }\n"
16011606
+ " }\n"
16021607
+ "</script>\n"
16031608
+ "</body></html>";
16041609

16051610
setExpectedAlerts(expected);
1606-
loadPageWithAlerts2(html);
1611+
loadPageVerifyTitle2(html);
16071612
}
16081613

16091614
/**
@@ -2437,21 +2442,22 @@ public void getPropertyPriority() throws Exception {
24372442
public void caseInsensitive() throws Exception {
24382443
final String html
24392444
= "<html><head><script>\n"
2445+
+ LOG_TITLE_FUNCTION
24402446
+ "function doTest() {\n"
24412447
+ " var node = document.getElementById('div1');\n"
24422448
+ " var style = node.style;\n"
2443-
+ " alert(style.color);\n"
2449+
+ " log(style.color);\n"
24442450
+ " style.color = 'pink';\n"
2445-
+ " alert(style.color);\n"
2446-
+ " alert(node.getAttribute('style'));\n"
2451+
+ " log(style.color);\n"
2452+
+ " log(node.getAttribute('style'));\n"
24472453
+ "}\n"
24482454
+ "</script></head>\n"
24492455
+ "<body onload='doTest()'><div id='div1' style='COLOR: BLACK'>foo</div></body></html>";
24502456

24512457
final String style = getExpectedAlerts()[getExpectedAlerts().length - 1];
24522458

24532459
setExpectedAlerts(Arrays.copyOf(getExpectedAlerts(), getExpectedAlerts().length - 1));
2454-
final WebDriver driver = loadPageWithAlerts2(html);
2460+
final WebDriver driver = loadPageVerifyTitle2(html);
24552461
assertEquals(style, driver.findElement(By.id("div1")).getAttribute("style"));
24562462
}
24572463

@@ -2586,26 +2592,27 @@ public void interceptSetter() throws Exception {
25862592
+ "<body>\n"
25872593
+ "<div id='d'>foo</div>\n"
25882594
+ "<script>\n"
2595+
+ LOG_TITLE_FUNCTION
25892596
+ " try {\n"
25902597
+ " var css = window.CSSStyleDeclaration;\n"
25912598
+ " var oldDisplay = css.prototype.__lookupSetter__('display');\n"
2592-
+ " alert(typeof oldDisplay);\n"
2599+
+ " log(typeof oldDisplay);\n"
25932600

25942601
+ " var newDisplay = function(x){\n"
2595-
+ " alert('before');\n"
2596-
+ " alert(x);\n"
2602+
+ " log('before');\n"
2603+
+ " log(x);\n"
25972604
+ " oldDisplay.call(this, x);\n"
2598-
+ " alert('after');\n"
2605+
+ " log('after');\n"
25992606
+ " };\n"
26002607
+ " css.prototype.__defineSetter__('display', newDisplay);\n"
26012608

26022609
+ " var div = document.getElementById('d');\n"
26032610
+ " div.style.display = 'none';\n"
2604-
+ " alert(div.style.display);\n"
2605-
+ " } catch(e) { alert('exception'); }\n"
2611+
+ " log(div.style.display);\n"
2612+
+ " } catch(e) { log('exception'); }\n"
26062613
+ "</script>\n"
26072614
+ "</body></html>";
2608-
loadPageWithAlerts2(html);
2615+
loadPageVerifyTitle2(html);
26092616
}
26102617

26112618
/**
@@ -2616,28 +2623,29 @@ public void interceptSetter() throws Exception {
26162623
public void setToNull() throws Exception {
26172624
final String html
26182625
= "<html><head><script>\n"
2626+
+ LOG_TITLE_FUNCTION
26192627
+ "function test() {\n"
26202628
+ " var div1 = document.getElementById('div1');\n"
2621-
+ " alert(div1.style.border);\n"
2629+
+ " log(div1.style.border);\n"
26222630
+ " try {\n"
26232631
+ " div1.style.border = null;\n"
26242632
+ " } catch (e) {\n"
2625-
+ " alert('error');\n"
2633+
+ " log('error');\n"
26262634
+ " }\n"
2627-
+ " alert(div1.style.border);\n"
2628-
+ " alert(div1.style.display);\n"
2635+
+ " log(div1.style.border);\n"
2636+
+ " log(div1.style.display);\n"
26292637
+ " try {\n"
26302638
+ " div1.style.display = null;\n"
26312639
+ " } catch (e) {\n"
2632-
+ " alert('error');\n"
2640+
+ " log('error');\n"
26332641
+ " }\n"
2634-
+ " alert(div1.style.display);\n"
2642+
+ " log(div1.style.display);\n"
26352643
+ "}\n"
26362644
+ "</script></head>\n"
26372645
+ "<body onload='test()'>\n"
26382646
+ "<div id='div1'>foo</div></body></html>";
26392647

2640-
loadPageWithAlerts2(html);
2648+
loadPageVerifyTitle2(html);
26412649
}
26422650

26432651
/**
@@ -2701,22 +2709,23 @@ public void boxSizing() throws Exception {
27012709
public void jQueryPixelPosition() throws Exception {
27022710
final String html = "<html><head>\n"
27032711
+ "<script>\n"
2712+
+ LOG_TITLE_FUNCTION
27042713
+ " function test() {\n"
27052714
+ " var div = document.getElementById('test');\n"
27062715
+ " var style = window.getComputedStyle(div, null);\n"
2707-
+ " alert(style.top);\n"
2716+
+ " log(style.top);\n"
27082717

27092718
+ " div = document.createElement('div');\n"
27102719
+ " style = window.getComputedStyle(div, null);\n"
2711-
+ " alert(style.top);\n"
2720+
+ " log(style.top);\n"
27122721
+ " }\n"
27132722
+ "</script>\n"
27142723
+ "</head>\n"
27152724
+ "<body onload='test()'>\n"
27162725
+ " <div id='test'></div>\n"
27172726
+ "</body></html>";
27182727

2719-
loadPageWithAlerts2(html);
2728+
loadPageVerifyTitle2(html);
27202729
}
27212730

27222731
/**
@@ -2862,6 +2871,7 @@ private static boolean isDefaultGetterComputed(final List<String> lines, final P
28622871
public void widows() throws Exception {
28632872
final String html = "<html><head>\n"
28642873
+ "<script>\n"
2874+
+ LOG_TITLE_FUNCTION
28652875
+ " function test() {\n"
28662876
+ " var div = document.getElementById('mydiv');\n"
28672877
+ " debug(div);\n"
@@ -2873,15 +2883,15 @@ public void widows() throws Exception {
28732883
+ " debug(div);\n"
28742884
+ " }\n"
28752885
+ " function debug(div) {\n"
2876-
+ " alert(div.style.widows);\n"
2877-
+ " alert(window.getComputedStyle(div, null).widows);\n"
2886+
+ " log(div.style.widows);\n"
2887+
+ " log(window.getComputedStyle(div, null).widows);\n"
28782888
+ " }\n"
28792889
+ "</script>\n"
28802890
+ "</head>\n"
28812891
+ "<body onload='test()'>\n"
28822892
+ " <div id='mydiv'></div>\n"
28832893
+ "</body></html>";
2884-
loadPageWithAlerts2(html);
2894+
loadPageVerifyTitle2(html);
28852895
}
28862896

28872897
/**
@@ -2965,20 +2975,21 @@ public void position() throws Exception {
29652975
public void setStyle() throws Exception {
29662976
final String html = "<html><head>\n"
29672977
+ "<script>\n"
2978+
+ LOG_TITLE_FUNCTION
29682979
+ " function test() {\n"
29692980
+ " var div = document.getElementById('mydiv');\n"
2970-
+ " alert(div.style);\n"
2981+
+ " log(div.style);\n"
29712982
+ " div.style = 'color: green; font-family: abc';\n"
2972-
+ " alert(div.style);\n"
2973-
+ " alert(div.style.color);\n"
2974-
+ " alert(div.style.fontFamily);\n"
2983+
+ " log(div.style);\n"
2984+
+ " log(div.style.color);\n"
2985+
+ " log(div.style.fontFamily);\n"
29752986
+ " }\n"
29762987
+ "</script>\n"
29772988
+ "</head>\n"
29782989
+ "<body onload='test()'>\n"
29792990
+ " <div id='mydiv'></div>\n"
29802991
+ "</body></html>";
2981-
loadPageWithAlerts2(html);
2992+
loadPageVerifyTitle2(html);
29822993
}
29832994

29842995
/**

0 commit comments

Comments
 (0)