Menu

#1233 ComputedCSSStyleDeclaration.getTop prone to StackOverflow?

2.8
closed
None
5
2015-09-23
2011-01-12
No

Hi guys,

Thanks again for all your hard work on HtmlUnit!

When using HtmlUnit against my production system I am encountering StackOverflowError (trace below). Looking at the code, it would appear that ComputedCSSStyleDeclaration.getTop is quite prone to this. For every sibling (not parent), it recursively calls .getTop. So in my case, where I have a couple of SELECT boxes with 2,000 OPTIONs in them (silly I know) this requires over 4,000 stack calls.

Could perhaps this code be rewritten as a loop? Or at least taught to ignore those elements (such as OPTION) that have no vertical displacement (it already tries this for elements that are absolutely positioned)?

Regards,

Richard.

Please also see http://old.nabble.com/ComputedCSSStyleDeclaration.getTop-prone-to-StackOverflowError--td30593445.html

Discussion

  • Kennard Consulting

    Stack trace showing StackOverflow

     
  • Adam Afeltowicz

    Adam Afeltowicz - 2015-09-22

    Hi,

    I have also encountered such issue.

    In attachment you will find patch for ComputedCSSStyleDeclaration and testcase based on HTMLElement2Test.offsetTopWithPreviousSiblings.

     
  • Ahmed Ashour

    Ahmed Ashour - 2015-09-23
    • status: open --> closed
    • assigned_to: Ahmed Ashour
     
  • Ahmed Ashour

    Ahmed Ashour - 2015-09-23

    Thanks a lot for the patch, slightly modified and committed.

    Next time, please run 'mvn checkstyle:checkstyle' as hinted in http://htmlunit.sourceforge.net/submittingPatches.html

     

Log in to post a comment.