From: SourceForge.net <no...@so...> - 2003-06-28 16:05:45
|
Bugs item #745565, was opened at 2003-05-29 11:29 Message generated for change (Comment added) made by mbowler You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=745565&group_id=47038 Category: None Group: 1.2.1 >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Mike Bresnahan (gudujarlson) Assigned to: Mike Bowler (mbowler) Summary: Parser produces two head elements Initial Comment: The following HTML causes HtmlUnit 1.2.2 to produce 2 <head> elements and a blank page title. Note the meta tag that preceeds the head tag. <html> <meta http-equiv="Pragma" content="no-cache"> <head> <title>Title</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> </body> </html> To reproduce use the following code: import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.UnexpectedPage; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html.HtmlElement; public class Main { public static void main(String args[]) { try { Page page = new WebClient().getPage (new java.net.URL("http://localhost:7001/bug.html")); if( page instanceof UnexpectedPage) { System.err.println (page.getWebResponse().getContentAsString()); throw new Exception("Got an unexpected page"); } HtmlPage htmlPage = (HtmlPage)page; //System.err.println("XXX:" + htmlPage.getTitleText()); //System.err.println (htmlPage.getWebResponse().getContentAsString()); dump( htmlPage, 0); junit.framework.Assert.assertEquals ("Title", htmlPage.getTitleText()); } catch( Throwable exception) { exception.printStackTrace(); } } private static void dump(HtmlElement element, int depth) { for( int i = 0; i < depth; ++i) { System.err.print(" "); } System.err.println(element.getTagName()); java.util.Iterator children = element.getChildElements().iterator(); while(children.hasNext()) { HtmlElement child = (HtmlElement)children.next (); dump( child, depth + 1); } } } Which should produce the following output: html head meta head title meta body junit.framework.ComparisonFailure: expected:<Title> but was:<> at junit.framework.Assert.assertEquals (Assert.java:81) at junit.framework.Assert.assertEquals (Assert.java:87) at Main.main(Unknown Source) ---------------------------------------------------------------------- >Comment By: Mike Bowler (mbowler) Date: 2003-06-28 12:05 Message: Logged In: YES user_id=46756 NekoHTML 0.7.7 has been released which fixes this problem. http://www.apache.org/~andyc/neko/doc/html/index.html ---------------------------------------------------------------------- Comment By: Mike Bowler (mbowler) Date: 2003-05-29 12:56 Message: Logged In: YES user_id=46756 I have forwarded this bug to the maintainer of NekoHTML (I am able to reproduce it using just Neko). I'll leave this bug open until Neko has been updated. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=745565&group_id=47038 |