Ignore CSS errors and warnings while running htmlUnit tests. This stops console (issue1032801)

905 views
Skip to first unread message

amitm...@google.com

unread,
Oct 19, 2010, 5:20:40 PM10/19/10
to rj...@google.com, jlab...@google.com, google-web-tool...@googlegroups.com, re...@gwt-code-reviews.appspotmail.com
Reviewers: rjrjr, jlabanca,

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);


jlab...@google.com

unread,
Oct 19, 2010, 5:22:47 PM10/19/10
to amitm...@google.com, rj...@google.com, google-web-tool...@googlegroups.com, re...@gwt-code-reviews.appspotmail.com
Reply all
Reply to author
Forward
0 new messages