-
-
Notifications
You must be signed in to change notification settings - Fork 184
Description
We hit this problem in something like 1 in 200 test runs. HtmlUnit is capable of successfully executing our pages, but then if the machine is busy, or we're just plain unlucky, it doesn't work.
I think it's a race condition.
We have pages where:
<head>
<script src="/js/jquery-3.6.0.min.js" language="javascript"></script>
<script src="/js/form-common.js" language="javascript"></script>
</head>and in form-common.js:
$(document).ready(function () {
var errorElements = $('.error');
if( errorElements && errorElements.length ) {
errorElements[0].scrollIntoView({behavior: "smooth", block: "center", inline: "nearest"})
}
});Though in fairness, similar code in the body of the main page can cause the error
So, what I think is happening is that the <script> tags in the <head> are being loaded and parsed asynchronously with the rest of the page's scripts. Or possibly they're all being put into an execution queue, but the execution queue is not in strict order. This may be related to the setTimeout issue raised in #369 - comment #369 (comment)
Any thoughts on where to start in solving this. I'm prepared to have a go at raising a PR if someone can give me a starting point?