LOG.debug("Window closed (contains: " + event.getWebWindow().getEnclosedPage().getWebResponse().getRequestUrl()
+ ")");
}
public void webWindowContentChanged(final WebWindowEvent event) {
final WebWindow window = event.getWebWindow();
final WebResponse webResp = event.getNewPage().getWebResponse();
LOG.info("Content of window changed to " + webResp.getRequestUrl() + " (" + webResp.getContentType() + ")");
final boolean takeItAsNew;
if (window instanceof TopLevelWindow && event.getOldPage() == null) {
takeItAsNew = true;
LOG.info("Content loaded in newly opened window, its content will become current response");
} else if (fCurrentResponse.getPage() != null
&& fCurrentResponse.getPage().getEnclosingWindow() == window) {
takeItAsNew = true;
LOG.info("Content of current window changed, it will become current response");
}
// content loaded in an other window as the "current" one
// by js becomes "current" only if new top window is opened
else if (getWebClient().getJavaScriptEngine() == null
|| !getWebClient().getJavaScriptEngine().isScriptRunning()) {
if (window instanceof FrameWindow
&& !HtmlPage.READY_STATE_COMPLETE.equals(
((FrameWindow) window).getEnclosingPage().getDocumentElement().getReadyState())) {
LOG.info("Content of frame window has changed without javascript while enclosing page is loading, "
+ "it will NOT become current response");
LOG.debug("Enclosing page's state: " + ((FrameWindow) window).getEnclosingPage().getDocumentElement().getReadyState());
LOG.debug("Enclosing page's url: " + ((FrameWindow) window).getEnclosingPage().getWebResponse().getRequestUrl());
takeItAsNew = false;
} else {
LOG.info("Content of window changed without javascript, it will become current response");
takeItAsNew = true;
}
} else {
LOG.info("Content of window changed with javascript, it will NOT become current response");
takeItAsNew = false;
}
if (takeItAsNew) {
saveResponseAsCurrent(window.getEnclosedPage());
}
}