Menu

#1046 Tag balancing differences in HtmlUnit and real browsers

Latest SVN
closed
nobody
NekoHTML (24)
5
2016-04-02
2010-03-11
No

In case of incomplete/unbalanced HTML source code, browsers like Firefox and Chrome might create different DOM trees depending on the document type. For example,

"<p><table></table>"

is balanced to

"<p><table></table></p>"

in Quirks mode and to

"<p></p><table></table>"

in Standard mode. HtmlUnit seems to apply the Quirks balancing strategy in Standard mode as well. This is not a big deal except that XPaths copied from one of these browsers might or might not work in HtmlUnit without modification.

Discussion

  • Joerg Werner

    Joerg Werner - 2010-03-11

    test case

     
  • Joerg Werner

    Joerg Werner - 2011-10-20

    updated test case

     
  • Joerg Werner

    Joerg Werner - 2011-10-20

    There are more examples, especially if the HTML code is not valid (with respect to the specs). For example, the following snippet (btw. generated by a GUI framework):

    <a><table>...</table></a>
    

    was rebalanced to:

    <a></a><table>...</table>
    

    FF leaves this as is. So when clicking somewhere inside the table:

    • the XPath needed is different across browsers (causes problems when Selenium is used with different drivers) and
    • the anchor will not be triggered when using HtmlUnit.

    I extended the test case to cover this issue as well.

     

    Last edit: RBRi 2012-11-03
  • RBRi

    RBRi - 2012-11-03
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1 +1,19 @@
    -In case of incomplete/unbalanced HTML source code, browsers like Firefox and Chrome might create different DOM trees depending on the document type. For example, "<p><table></table>" is balanced to "<p><table></table></p>" in Quirks mode and to "<p></p><table></table>" in Standard mode. HtmlUnit seems to apply the Quirks balancing strategy in Standard mode as well. This is not a big deal except that XPaths copied from one of these browsers might or might not work in HtmlUnit without modification.
    +In case of incomplete/unbalanced HTML source code, browsers like Firefox and Chrome might create different DOM trees depending on the document type. For example,
    +
    +~~~~~~
    +"<p><table></table>"
    +~~~~~~
    +
    +is balanced to
    +
    +~~~~~~
    +"<p><table></table></p>"
    +~~~~~~
    +
    +in Quirks mode and to
    +
    +~~~~~~
    +"<p></p><table></table>"
    +~~~~~~
    +
    +in Standard mode. HtmlUnit seems to apply the Quirks balancing strategy in Standard mode as well. This is not a big deal except that XPaths copied from one of these browsers might or might not work in HtmlUnit without modification.
    
     
  • Mark H. Butler

    Mark H. Butler - 2013-08-23

    I am seeing this bug as well. It may be a duplicate of https://sourceforge.net/p/htmlunit/bugs/1423/

     
  • RBRi

    RBRi - 2015-10-31
    • assigned_to: RBRi --> nobody
     
  • RBRi

    RBRi - 2016-04-02
    • status: open --> closed
     
  • RBRi

    RBRi - 2016-04-02

    Ok, this seems to be fixed at least with our own neko fork.
    Tescase added.

     

Log in to post a comment.