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 Review at http://gwt-code-reviews.appspot.com/1032801 git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@9119 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java b/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java index 22c1354..ad072b1 100644 --- a/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java +++ b/user/src/com/google/gwt/junit/RunStyleHtmlUnit.java
@@ -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);