From: RBRi <rb...@us...> - 2023-02-02 06:17:55
|
Fixed in 2.71.0 --- ** [bugs:#1630] form_owner incorrect when <form> are malformed** **Status:** open **Group:** Latest SVN **Created:** Mon Aug 04, 2014 09:16 AM UTC by Atsushi Nakagawa **Last Updated:** Sat Sep 06, 2014 06:50 PM UTC **Owner:** nobody **Attachments:** - [consumed1-div.html](https://sourceforge.net/p/htmlunit/bugs/1630/attachment/consumed1-div.html) (308 Bytes; text/html) - [consumed1.html](https://sourceforge.net/p/htmlunit/bugs/1630/attachment/consumed1.html) (312 Bytes; text/html) - [consumed2.html](https://sourceforge.net/p/htmlunit/bugs/1630/attachment/consumed2.html) (398 Bytes; text/html) - [doc-order1-div.html](https://sourceforge.net/p/htmlunit/bugs/1630/attachment/doc-order1-div.html) (308 Bytes; text/html) - [doc-order1.html](https://sourceforge.net/p/htmlunit/bugs/1630/attachment/doc-order1.html) (312 Bytes; text/html) - [dom-tree1.html](https://sourceforge.net/p/htmlunit/bugs/1630/attachment/dom-tree1.html) (619 Bytes; text/html) - [dom-tree2.html](https://sourceforge.net/p/htmlunit/bugs/1630/attachment/dom-tree2.html) (700 Bytes; text/html) - [f1.html](https://sourceforge.net/p/htmlunit/bugs/1630/attachment/f1.html) (40 Bytes; text/html) - [f2.html](https://sourceforge.net/p/htmlunit/bugs/1630/attachment/f2.html) (40 Bytes; text/html) Unlike the recently closed [#1621], this problem isn't a regression and has existed at least as far back as 2.12. **Summary:** Owner forms returned by HtmlUnit do not match conventional browsers in certain cases when `<form></form>`s aren't aligned with the DOM tree. For example, the following incorrectly returns `"f1"` when `HtmlElement.getEnclosingForm()` is called on the `f2_submit` element. Chrome/IE11/Firefox returns `"f2"`: ~~~~~~ <html> <body> <div> <form name="f1" action="f1.html" method="GET"> <table> <input type="submit" name="f1_submit" value="expect f1"/> </form> <form name="f2" action="f2.html" method="GET"> </table> </div> <input type="submit" name="f2_submit" value="expect f2"/> </form> </body> </html> ~~~~~~ --- After some testing in Chrome/IE11/Firefox, owner forms seem to be determined by these three rules: **1. Document order pure and simple. (Completely ignoring the DOM heirachy):** ~~~~~~ <html> ... <form name="f1"> ... everything in between belongs to f1 ... </form> ... <form name="f2"> ... everything here and belongs to f2 ... (missing </form> so until the end of document) ~~~~~~ **2. Anything not encompassed between `<form>...</form>`, in document order, belong to the closest DOM-tree ancestor if any.** ~~~~~~ <html> ... <form name="f1"> ... everything here belongs to f1 ... <div> ... everything here belongs to f1 ... </form> ... things here belong to f1 because DOM-tree is `<form><div></div></form>` ... </div> ... ~~~~~~ **3. `<form>`s within `<form>`s simply cease to exist. (This is also determined by document order pure and simple.)** ~~~~~~ <html> ... <form name="f1"> ... everything in between belongs to f1 ... <form name="f2"> ... everything in between belongs to f1 ... </form><!--This actually closed f1's document-order enclosure--> ... things here belong to no one ... </form> ... things here belong to no one ... ~~~~~~ --- **Conclusion:** 1 and 3 seem to happen with no regards to the DOM tree and it doesn't seem to matter how whacky and nested the surrounding `<element>` and `</element>` placements are. Even though `<form>` nesting is not allowed *in document order*, it can be nested in the resulting DOM tree. --- Sent from sourceforge.net because htm...@li... is subscribed to https://sourceforge.net/p/htmlunit/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |