Description:
Ignore CSS errors and warnings while running htmlUnit tests. This stops
console
spew when running HtmlUnit tests in Eclipse. Any CSS fatal errors will
still be
reported.
Filed HtmlUnit bug at
https://sourceforge.net/tracker/?func=detail&aid=3090806&group_id=47038&atid=448266
Patch by: amitmanjhi
Review by: rjrjr,jlabanca
Please review this at http://gwt-code-reviews.appspot.com/1032801/show
Affected files:
M user/src/com/google/gwt/junit/RunStyleHtmlUnit.java
Index: user/src/com/google/gwt/junit/RunStyleHtmlUnit.java
===================================================================
--- user/src/com/google/gwt/junit/RunStyleHtmlUnit.java (revision 9116)
+++ user/src/com/google/gwt/junit/RunStyleHtmlUnit.java (working copy)
@@ -32,6 +32,9 @@
import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject;
+import org.w3c.css.sac.CSSParseException;
+import org.w3c.css.sac.ErrorHandler;
+
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
@@ -91,6 +94,25 @@
public void run() {
WebClient webClient = new WebClient(browser);
webClient.setAlertHandler(this);
+ // Adding a handler that ignores errors to work-around
+ //
https://sourceforge.net/tracker/?func=detail&aid=3090806&group_id=47038&atid=448266
+ webClient.setCssErrorHandler(new ErrorHandler() {
+
+ public void error(CSSParseException exception) {
+ // ignore
+ }
+
+ public void fatalError(CSSParseException exception) {
+ treeLogger.log(TreeLogger.WARN,
+ "CSS fatal error: " + exception.getURI() + " ["
+ + exception.getLineNumber() + ":"
+ + exception.getColumnNumber() + "] " +
exception.getMessage());
+ }
+
+ public void warning(CSSParseException exception) {
+ // ignore
+ }
+ });
webClient.setIncorrectnessListener(this);
webClient.setThrowExceptionOnFailingStatusCode(false);
webClient.setThrowExceptionOnScriptError(true);