From: <no...@us...> - 2003-09-10 14:21:47
|
Log Message: ----------- Fixed bug where HtmlPage.asText() would blow up if form tags were found between tr and td tags. Clearly this is illegal html but the browsers support it so HtmlUnit needs to as well. Modified Files: -------------- /cvsroot/htmlunit/htmlunit/src/xdocs: changes.xml /cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html: TableElementCreatorTest.java /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html: HtmlTableRow.java Revision Data ------------- Index: changes.xml =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/xdocs/changes.xml,v retrieving revision 1.127 retrieving revision 1.128 diff -u -d -r1.127 -r1.128 --- changes.xml 10 Sep 2003 12:19:50 -0000 1.127 +++ changes.xml 10 Sep 2003 14:21:43 -0000 1.128 @@ -6,7 +6,7 @@ </properties> <body> - <release version="1.3" date="not released yet"> + <release version="Next" date="not released yet"> <action type="update" dev="mbowler" id="713646"> Patch for bug in onload handler submitted by Andreas Hangler </action> @@ -26,6 +26,11 @@ </action> <action type="update" dev="mbowler" id="803237" due-to="Brad Clarke"> Upgraded junit.jar to 3.8.1 + </action> + <action type="update" dev="mbowler" id="802285"> + Fixed bug where HtmlPage.asText() would blow up if form tags were + found between tr and td tags. Clearly this is illegal html but + the browsers support it so HtmlUnit needs to as well. </action> </release> Index: TableElementCreatorTest.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/TableElementCreatorTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- TableElementCreatorTest.java 9 Sep 2003 20:16:13 -0000 1.1 +++ TableElementCreatorTest.java 10 Sep 2003 14:21:44 -0000 1.2 @@ -67,10 +67,6 @@ * @exception Exception If the test fails */ public void testGetTableCell() throws Exception { - if(true) { - notImplemented(); - return; - } final String htmlContent = "<html><head><title>test</title></head>" + "<body><table>" @@ -87,6 +83,6 @@ SubmitMethod.POST, Collections.EMPTY_LIST ); // Calling asText() will invoke the element creator which in turn will blow up - System.out.println(page.asXml()); + page.asText(); } } Index: HtmlTableRow.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlTableRow.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- HtmlTableRow.java 10 Jun 2003 11:56:58 -0000 1.5 +++ HtmlTableRow.java 10 Sep 2003 14:21:44 -0000 1.6 @@ -88,10 +88,23 @@ if( tableCells_ != null ) { return tableCells_; } - + + tableCells_ = Collections.unmodifiableList(getCells( getElement() )); + return tableCells_; + } + /** + * Return a List containing all the HtmlTableCell objects in this row + * @param parent The parent element + * @return See above + */ + private List getCells( final Element parent ) { + if( tableCells_ != null ) { + return tableCells_; + } + final List list = new ArrayList(); - final NodeList nodeList = getElement().getChildNodes(); + final NodeList nodeList = parent.getChildNodes(); final int nodeCount = nodeList.getLength(); final HtmlPage page = getPage(); @@ -110,11 +123,17 @@ else if( tagName.equals( "th" ) ) { list.add( new HtmlTableHeaderCell( page, element, rowIndex, columnIndex++ ) ); } + else if( tagName.equals( "form" ) ) { + // Completely illegal html but some of the big sites (ie amazon) do this + list.addAll( getCells(element) ); + } + else { + getLog().debug("Illegal html: found <"+tagName+"> under a <tr> tag"); + } } } - tableCells_ = Collections.unmodifiableList( list ); - return tableCells_; + return list; } |