From: SourceForge.net <no...@so...> - 2010-08-31 08:35:46
|
Bugs item #3056617, was opened at 2010-08-31 01:35 Message generated for change (Tracker Item Submitted) made by pinkston3 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=3056617&group_id=47038 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Donnie Pinkston (pinkston3) Assigned to: Nobody/Anonymous (nobody) Summary: Setting location.href to exact same URL causes page reload Initial Comment: I ran into a website that caused a very interesting issue in HtmlUnit. Loading the page in HtmlUnit would cause an infinite recursion, and eventually the code would crash with a stack-overflow. The page included some Javascript that would resize images within the page, and then the script had a line like this: if (location.hash) { location.href = location.hash; } In this case, the "new ref" is *identical to* the "old ref" - this script is simply ensuring that after image-resizing, the specific anchor still shows in the browser window. However, this line was causing HtmlUnit to reload the page again -- which would run the "resize images" script again, which would set location.href again, which would reload the page again, etc., etc. The stack finally goes boom. I tracked down the issue to the com.gargoylesoftware.htmlunit.javascript.host.Location class, line 199 (in the 2.8 snapshot, not sure what it is on head). The specific test is this: if (url.sameFile(oldUrl) && !StringUtils.equals(url.getRef(), oldUrl.getRef())) { I found that commenting out the second condition causes this infinite loop to go away. I believe the second condition may be too strict a constraint, since scripts can certainly set location.href to the same URL that is already being shown (and the ref could also be the same). I don't think HtmlUnit should completely reload the web page in that situation. Sorry that I don't have a repro-case - I found this bug late at night and I'm too tired to create one at the moment, especially since I think the fix is straightforward, although it would be nice to have as a unit-test... Thanks! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=3056617&group_id=47038 |