From: RBRi <rb...@us...> - 2018-08-10 06:17:09
|
Strange, not sure why this API returns a list (internally we use Sets - means there is no order at all). Will have a look, maybe we will stay with lists for this and preserve the order internally (and document it :-) --- ** [bugs:#1979] WebClient.getTopLevelWindows() wrongly ordered, probably** **Status:** accepted **Group:** Latest SVN **Created:** Thu Aug 02, 2018 07:17 AM UTC by Atsushi Nakagawa **Last Updated:** Thu Aug 02, 2018 10:18 AM UTC **Owner:** RBRi ### Problem in brief Prior to around 2.30, `WebClient.getTopLevelWindows()` was FIFO (i.e. oldest window first), and was in line with `WebClient.getWebWindows()` which is also FIFO. Now, `WebClient.getTopLevelWindows()` is reversed and is the opposite of `WebClient.getWebWindows()`. This change is probably an inadvertent resulting from [r15202](https://sourceforge.net/p/htmlunit/code/15202/#diff-2). ### Possible fix Below is the code we're using locally since changing the spec will break code compatibility. N.B.: r15202 [also changed the order of window close in `WebClient.close()`](https://sourceforge.net/p/htmlunit/code/15202/tree/trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java#l1880) but I think that might've been for the better so I've left that one as is. ```diff --- a/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java +++ b/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java @@ -1535,7 +1535,9 @@ public boolean containsWebWindow(final WebWindow webWindow) { * @see #getWebWindows() */ public List<TopLevelWindow> getTopLevelWindows() { - return Collections.unmodifiableList(new ArrayList<>(topLevelWindows_)); + List<TopLevelWindow> l = new ArrayList<>(topLevelWindows_.size()); + topLevelWindows_.descendingIterator().forEachRemaining(l::add); + return Collections.unmodifiableList(l); } /** ``` --- 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. |