Skip to content

Commit e7052c5

Browse files
committed
suppress some warnings and remove more alerts
1 parent 0623cdd commit e7052c5

File tree

4 files changed

+46
-20
lines changed

4 files changed

+46
-20
lines changed

src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/MutationRecord.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor;
2525
import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter;
2626

27+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2728
import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;
2829

2930
/**
@@ -131,6 +132,7 @@ void setAddedNodes(final NodeList addedNodes) {
131132
* @return the {@code addedNodes} property
132133
*/
133134
@JsxGetter
135+
@SuppressFBWarnings("EI_EXPOSE_REP")
134136
public NodeList getAddedNodes() {
135137
return addedNodes_;
136138
}
@@ -147,6 +149,7 @@ void setRemovedNodes(final NodeList removedNodes) {
147149
* @return the {@code removedNodes} property
148150
*/
149151
@JsxGetter
152+
@SuppressFBWarnings("EI_EXPOSE_REP")
150153
public NodeList getRemovedNodes() {
151154
return removedNodes_;
152155
}
@@ -163,6 +166,7 @@ void setPreviousSibling(final Node previousSibling) {
163166
* @return the {@code previousSibling} property
164167
*/
165168
@JsxGetter
169+
@SuppressFBWarnings("EI_EXPOSE_REP")
166170
public Node getPreviousSibling() {
167171
return previousSibling_;
168172
}
@@ -179,6 +183,7 @@ void setNextSibling(final Node nextSibling) {
179183
* @return the {@code nextSibling} property
180184
*/
181185
@JsxGetter
186+
@SuppressFBWarnings("EI_EXPOSE_REP")
182187
public Node getNextSibling() {
183188
return nextSibling_;
184189
}

src/main/java/com/gargoylesoftware/htmlunit/platform/util/XmlUtilsSunXercesHelper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl;
2929
import com.sun.org.apache.xerces.internal.dom.DeferredNode;
3030

31+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
32+
3133
/**
3234
* <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br>
3335
*
@@ -39,6 +41,10 @@ public final class XmlUtilsSunXercesHelper implements XmlUtilsHelperAPI {
3941

4042
// private static final Log LOG = LogFactory.getLog(XmlUtilsXerces.class);
4143

44+
/**
45+
* Ctor.
46+
*/
47+
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT")
4248
public XmlUtilsSunXercesHelper() {
4349
// Force eager loading of classes in order to flush out any linkage errors early
4450
Objects.hash(DeferredDocumentImpl.class, DeferredNode.class);

src/main/java/com/gargoylesoftware/htmlunit/platform/util/XmlUtilsXercesHelper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
import com.gargoylesoftware.htmlunit.platform.XmlUtilsHelperAPI;
3030

31+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
32+
3133
/**
3234
* <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br>
3335
*
@@ -39,6 +41,10 @@ public final class XmlUtilsXercesHelper implements XmlUtilsHelperAPI {
3941

4042
// private static final Log LOG = LogFactory.getLog(XmlUtilsXerces.class);
4143

44+
/**
45+
* Ctor.
46+
*/
47+
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT")
4248
public XmlUtilsXercesHelper() {
4349
// Force eager loading of classes in order to flush out any linkage errors early
4450
Objects.hash(DeferredDocumentImpl.class, DeferredNode.class);

src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInputTest.java

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ public void typeWhileDisabled() throws Exception {
112112
@Alerts({"null", "null"})
113113
public void typeDoesNotChangeValueAttribute() throws Exception {
114114
final String html = "<html>\n"
115-
+ "<head></head>\n"
115+
+ "<head>\n"
116+
+ "<script>" + LOG_TITLE_FUNCTION + "</script>\n"
117+
+ "</head>\n"
116118
+ "<body>\n"
117119
+ " <input type='password' id='p'/>\n"
118-
+ " <button id='check' onclick='alert(document.getElementById(\"p\").getAttribute(\"value\"));'>"
120+
+ " <button id='check' onclick='log(document.getElementById(\"p\").getAttribute(\"value\"));'>"
119121
+ "DoIt</button>\n"
120122
+ "</body></html>";
121123

@@ -124,11 +126,11 @@ public void typeDoesNotChangeValueAttribute() throws Exception {
124126

125127
final WebElement check = driver.findElement(By.id("check"));
126128
check.click();
127-
verifyAlerts(driver, getExpectedAlerts()[0]);
129+
verifyTitle2(driver, getExpectedAlerts()[0]);
128130

129131
p.sendKeys("abc");
130132
check.click();
131-
verifyAlerts(driver, getExpectedAlerts()[1]);
133+
verifyTitle2(driver, getExpectedAlerts());
132134
}
133135

134136
/**
@@ -138,10 +140,12 @@ public void typeDoesNotChangeValueAttribute() throws Exception {
138140
@Alerts({"HtmlUnit", "HtmlUnit"})
139141
public void typeDoesNotChangeValueAttributeWithInitialValue() throws Exception {
140142
final String html = "<html>\n"
141-
+ "<head></head>\n"
143+
+ "<head>\n"
144+
+ "<script>" + LOG_TITLE_FUNCTION + "</script>\n"
145+
+ "</head>\n"
142146
+ "<body>\n"
143147
+ " <input type='password' id='p' value='HtmlUnit'/>\n"
144-
+ " <button id='check' onclick='alert(document.getElementById(\"p\").getAttribute(\"value\"));'>"
148+
+ " <button id='check' onclick='log(document.getElementById(\"p\").getAttribute(\"value\"));'>"
145149
+ "DoIt</button>\n"
146150
+ "</body></html>";
147151

@@ -150,11 +154,11 @@ public void typeDoesNotChangeValueAttributeWithInitialValue() throws Exception {
150154

151155
final WebElement check = driver.findElement(By.id("check"));
152156
check.click();
153-
verifyAlerts(driver, getExpectedAlerts()[0]);
157+
verifyTitle2(driver, getExpectedAlerts()[0]);
154158

155159
p.sendKeys("abc");
156160
check.click();
157-
verifyAlerts(driver, getExpectedAlerts()[1]);
161+
verifyTitle2(driver, getExpectedAlerts());
158162
}
159163

160164
/**
@@ -215,12 +219,16 @@ public void preventDefault_OnKeyPress() throws Exception {
215219
* @throws Exception if an error occurs
216220
*/
217221
@Test
222+
@Alerts({"foo", "change", "boo", "blur", "boo", "blur"})
218223
public void typeOnChange() throws Exception {
219224
final String html =
220-
"<html><head></head><body>\n"
225+
"<html><head>\n"
226+
+ "<script>" + LOG_TITLE_FUNCTION + "</script>\n"
227+
+ "</head>\n"
228+
+ "<body>\n"
221229
+ "<input type='password' id='p' value='Hello world'"
222-
+ " onChange='alert(\"foo\");alert(event.type);'"
223-
+ " onBlur='alert(\"boo\");alert(event.type);'>\n"
230+
+ " onChange='log(\"foo\");log(event.type);'"
231+
+ " onBlur='log(\"boo\");log(event.type);'>\n"
224232
+ "<button id='b'>some button</button>\n"
225233
+ "</body></html>";
226234

@@ -232,17 +240,16 @@ public void typeOnChange() throws Exception {
232240

233241
// trigger lost focus
234242
driver.findElement(By.id("b")).click();
235-
final String[] expectedAlerts1 = {"foo", "change", "boo", "blur"};
236-
assertEquals(expectedAlerts1, getCollectedAlerts(driver, 4));
243+
verifyTitle2(driver, getExpectedAlerts()[0], getExpectedAlerts()[1],
244+
getExpectedAlerts()[2], getExpectedAlerts()[3]);
237245

238246
// set only the focus but change nothing
239247
p.click();
240248
assertTrue(getCollectedAlerts(driver, 1).isEmpty());
241249

242250
// trigger lost focus
243251
driver.findElement(By.id("b")).click();
244-
final String[] expectedAlerts2 = {"boo", "blur"};
245-
assertEquals(expectedAlerts2, getCollectedAlerts(driver, 2));
252+
verifyTitle2(driver, getExpectedAlerts());
246253
}
247254

248255
/**
@@ -252,10 +259,12 @@ public void typeOnChange() throws Exception {
252259
public void setValueOnChange() throws Exception {
253260
final String html =
254261
"<html>\n"
255-
+ "<head></head>\n"
262+
+ "<head>\n"
263+
+ "<script>" + LOG_TITLE_FUNCTION + "</script>\n"
264+
+ "</head>\n"
256265
+ "<body>\n"
257266
+ " <input type='password' id='p' value='Hello world'"
258-
+ " onChange='alert(\"foo\");alert(event.type);'>\n"
267+
+ " onChange='log(\"foo\");log(event.type);'>\n"
259268
+ " <button id='b'>some button</button>\n"
260269
+ " <button id='set' onclick='document.getElementById(\"p\").value=\"HtmlUnit\"'>setValue</button>\n"
261270
+ "</body></html>";
@@ -280,7 +289,7 @@ public void setDefaultValueOnChange() throws Exception {
280289
+ "<head></head>\n"
281290
+ "<body>\n"
282291
+ " <input type='password' id='p' value='Hello world'"
283-
+ " onChange='alert(\"foo\");alert(event.type);'>\n"
292+
+ " onChange='log(\"foo\");log(event.type);'>\n"
284293
+ " <button id='b'>some button</button>\n"
285294
+ " <button id='set' onclick='document.getElementById(\"p\").defaultValue=\"HtmlUnit\"'>"
286295
+ "setValue</button>\n"
@@ -289,11 +298,11 @@ public void setDefaultValueOnChange() throws Exception {
289298
final WebDriver driver = loadPage2(html);
290299
driver.findElement(By.id("set")).click();
291300

292-
assertEquals(Collections.emptyList(), getCollectedAlerts(driver));
301+
verifyTitle2(driver);
293302

294303
// trigger lost focus
295304
driver.findElement(By.id("b")).click();
296-
assertEquals(Collections.emptyList(), getCollectedAlerts(driver));
305+
verifyTitle2(driver);
297306
}
298307

299308
/**

0 commit comments

Comments
 (0)