[HtmlUnit] [htmlunit:bugs] #1979 WebClient.getTopLevelWindows() wrongly ordered, probably
RBRi via HtmlUnit-develop <[email protected]> Fri, 10 Aug 2018 18:15:42 -0000
| Newsgroups | gmane.comp.java.htmlunit.devel |
|---|---|
| Message-ID | </p/htmlunit/bugs/1979/001ac752393d2d8402e6d7b7406d2c0ceab0f20a.bugs@htmlunit.p.sourceforge.net> |
- **status**: accepted --> closed
---
** [bugs:#1979] WebClient.getTopLevelWindows() wrongly ordered, probably**
**Status:** closed
**Group:** Latest SVN
**Created:** Thu Aug 02, 2018 07:17 AM UTC by Atsushi Nakagawa
**Last Updated:** Fri Aug 10, 2018 06:14 PM 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 [email protected] 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.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop