[prev in list] [next in list] [prev in thread] [next in thread] 

List:       htmlunit-develop
Subject:    [HtmlUnit] SF.net SVN: htmlunit:[5026] trunk/htmlunit/src
From:       mguillem () users ! sourceforge ! net
Date:       2009-09-29 19:39:19
Message-ID: E1MsiXf-0006Aq-PL () 3kljzd1 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Revision: 5026
          http://htmlunit.svn.sourceforge.net/htmlunit/?rev=5026&view=rev
Author:   mguillem
Date:     2009-09-29 19:39:19 +0000 (Tue, 29 Sep 2009)

Log Message:
-----------
DomNode.asText() considers UL content that is not within a LI too.
Issue 2868052

Modified Paths:
--------------
    trunk/htmlunit/src/changes/changes.xml
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSerializer.java
  trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlUnorderedListTest.java
  trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUListElementTest.java


Modified: trunk/htmlunit/src/changes/changes.xml
===================================================================
--- trunk/htmlunit/src/changes/changes.xml	2009-09-29 12:58:55 UTC (rev 5025)
+++ trunk/htmlunit/src/changes/changes.xml	2009-09-29 19:39:19 UTC (rev 5026)
@@ -6,6 +6,9 @@
 
     <body>
         <release version="2.7" date="?" description="Bugfixes, (initial)??? IE8 \
support"> +            <action type="fix" dev="mguillem" issue="2868052">
+                DomNode.asText() considers UL content that is not within a LI too.
+            </action>
             <action type="fix" dev="asashour">
                 JavaScript: fix attribute.value property.
             </action>

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSerializer.java
 ===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSerializer.java	2009-09-29 \
                12:58:55 UTC (rev 5025)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSerializer.java	2009-09-29 \
19:39:19 UTC (rev 5026) @@ -198,14 +198,11 @@
         doAppendBlockSeparator();
         boolean first = true;
         for (final DomNode item : htmlUnorderedList.getChildren()) {
-            if (!(item instanceof HtmlListItem)) {
-                continue;
-            }
             if (!first) {
                 doAppendBlockSeparator();
             }
             first = false;
-            appendChildren(item);
+            appendNode(item);
         }
         doAppendBlockSeparator();
     }

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlUnorderedListTest.java
 ===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlUnorderedListTest.java	2009-09-29 \
                12:58:55 UTC (rev 5025)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlUnorderedListTest.java	2009-09-29 \
19:39:19 UTC (rev 5026) @@ -14,12 +14,8 @@
  */
 package com.gargoylesoftware.htmlunit.html;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.junit.Test;
 
-import com.gargoylesoftware.htmlunit.BrowserVersion;
 import com.gargoylesoftware.htmlunit.WebTestCase;
 
 /**
@@ -35,40 +31,23 @@
      * @throws Exception if the test fails
      */
     @Test
-    public void testSimpleScriptable() throws Exception {
-        final String html = "<html><head>\n"
-            + "<script>\n"
-            + "  function test() {\n"
-            + "    alert(document.getElementById('myId'));\n"
-            + "  }\n"
-            + "</script>\n"
-            + "</head><body onload='test()'>\n"
-            + "  <ul id='myId'/>\n"
-            + "</body></html>";
-
-        final String[] expectedAlerts = {"[object HTMLUListElement]"};
-        final List<String> collectedAlerts = new ArrayList<String>();
-        final HtmlPage page = loadPage(BrowserVersion.FIREFOX_2, html, \
                collectedAlerts);
-        assertTrue(HtmlUnorderedList.class.isInstance(page.getHtmlElementById("myId")));
                
-        assertEquals(expectedAlerts, collectedAlerts);
-    }
-
-    /**
-     * @throws Exception if the test fails
-     */
-    @Test
     public void asText() throws Exception {
         final String html = "<html><head>\n"
             + "</head><body>\n"
             + "  <ul id='foo'>"
             + "  <li>first item</li>\n"
             + "  <li>second item</li>\n"
+            + "something without li node\n"
+            + "  <li>third item</li>\n"
             + "  </ul>\n"
             + "</body></html>";
 
         final HtmlPage page = loadPage(html);
         final HtmlElement node = page.getHtmlElementById("foo");
-        final String expectedText = "first item" + LINE_SEPARATOR + "second item";
+        final String expectedText = "first item" + LINE_SEPARATOR
+            + "second item" + LINE_SEPARATOR
+            + "something without li node" + LINE_SEPARATOR
+            + "third item";
 
         assertEquals(expectedText, node.asText());
         assertEquals(expectedText, page.asText());

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUListElementTest.java
 ===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUListElementTest.java	2009-09-29 \
                12:58:55 UTC (rev 5025)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUListElementTest.java	2009-09-29 \
19:39:19 UTC (rev 5026) @@ -16,21 +16,50 @@
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.htmlunit.HtmlUnitDriver;
 
 import com.gargoylesoftware.htmlunit.BrowserRunner;
-import com.gargoylesoftware.htmlunit.WebTestCase;
+import com.gargoylesoftware.htmlunit.WebDriverTestCase;
 import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts;
+import com.gargoylesoftware.htmlunit.html.HtmlUnorderedList;
 
 /**
  * Unit tests for {@link HTMLUListElement}.
  *
  * @version $Revision$
  * @author Daniel Gredler
+ * @author Marc Guillemot
  */
 @RunWith(BrowserRunner.class)
-public class HTMLUListElementTest extends WebTestCase {
+public class HTMLUListElementTest extends WebDriverTestCase {
 
     /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    @Alerts(FF = "[object HTMLUListElement]", IE = "[object]")
+    public void testSimpleScriptable() throws Exception {
+        final String html = "<html><head>\n"
+            + "<script>\n"
+            + "  function test() {\n"
+            + "    alert(document.getElementById('myId'));\n"
+            + "  }\n"
+            + "</script>\n"
+            + "</head><body onload='test()'>\n"
+            + "  <ul id='myId'/>\n"
+            + "</body></html>";
+
+        final WebDriver driver = loadPageWithAlerts2(html);
+        if (driver instanceof HtmlUnitDriver) {
+            final WebElement element = driver.findElement(By.id("myId"));
+            assertTrue(toHtmlElement(element) instanceof HtmlUnorderedList);
+        }
+    }
+
+    /**
      * @throws Exception if an error occurs
      */
     @Test
@@ -67,7 +96,7 @@
             + "alert(document.getElementById('u4').getAttribute('compact'));\n"
             + "</script>\n"
             + "</body></html>";
-        loadPageWithAlerts(html);
+        loadPageWithAlerts2(html);
     }
 
 }


This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
HtmlUnit-develop mailing list
HtmlUnit-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic