Skip to content

Commit

Permalink
WebWindow handling is hard
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Oct 20, 2023
1 parent 7b1bc33 commit b8ffdd5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/htmlunit/WebClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public WebClient(final BrowserVersion browserVersion, final boolean javaScriptEn

// The window must be constructed AFTER the script engine.
currentWindowTracker_ = new CurrentWindowTracker(this, true);
currentWindow_ = new TopLevelWindow("", this);
new TopLevelWindow("", this);

initMSXMLActiveX();
}
Expand Down Expand Up @@ -2233,8 +2233,7 @@ public void afterWebWindowClosedListenersProcessed(final WebWindowEvent event) {

if (webClient_.topLevelWindows_.isEmpty()) {
// Must always have at least window, and there are no top-level windows left; must create one.
final TopLevelWindow newWindow = new TopLevelWindow("", webClient_);
webClient_.setCurrentWindow(newWindow);
new TopLevelWindow("", webClient_);
}
}

Expand Down Expand Up @@ -2286,6 +2285,7 @@ public void webWindowOpened(final WebWindowEvent event) {
if (window instanceof TopLevelWindow) {
final TopLevelWindow tlw = (TopLevelWindow) window;
webClient_.topLevelWindows_.add(tlw);
webClient_.setCurrentWindow(tlw);
}
// Page is not loaded yet, don't set it now as current window.
}
Expand Down Expand Up @@ -2436,7 +2436,7 @@ public void reset() {

// The window must be constructed AFTER the script engine.
currentWindowTracker_ = new CurrentWindowTracker(this, true);
currentWindow_ = new TopLevelWindow("", this);
new TopLevelWindow("", this);
}

/**
Expand Down

0 comments on commit b8ffdd5

Please sign in to comment.