Hi
What I am experiencing is that the response (html) to an XHR POST is returned to the javascript, but not updated into the DOM after doing the following:
document.open();
document.write(xhr.responseText);
document.close();
What I see in my test HtmlPage response is the "old" page content. The test is executed as follows:
HtmlPage newPage = input.click();
webClient.waitForBackgroundJavaScript(50000);
logger.info("New Page: " + newPage.getEnclosingWindow().getEnclosedPage().getWebResponse().getContentAsString());
I've been trying to analyse/solve this problem for weeks now with no luck. I have pulled the latest source (2.44.0) from github and inserted debug logging at various points. Within the WebClient class, at the end of the "loadWebResponseFromWebConnection" function, I log the expected html page that the server returns. Also, in the XMLHttpRequest class at the end of the "send" function I see the expected content. When I check the content of the "newPage" above in the test result, the old page content is present.
Somewhere along the line the document/HtmlPage isn't updated with the incoming html. I could spend another day or so trying to isolate the issue (and it could be my code too, I haven't ruled that out), but if someone who knows the HtmlUnit code can point me in the right direction of where to look in the code or can see if they can find something that fits the scenario above in the code, I would be very grateful. The code is quite extensive and it's not easy to work backwards from the XMLHttpRequest class to find what calls what (maybe it's just me :) ).
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too