When an asynchronous XMLHttpRequest is made, a new thread is kicked off to do the work. However, at least one thread local variable (JavaScriptEngine.KEY_STARTING_SCOPE) is missing when this new thread is created. I can see the problem when I try to set window.location.href value. A NullPointerException is thrown when the Window.jsxSet_location method is called because it attempts to retrieve the starting scope as a thread local and cannot.
Attaching a test case and a potential fix as a patch file. The fix may not be broad enough (not sure how many thread locals need to be applied). Perhaps consider using an InheritableThreadLocal instead.
Test case and one way to potentially fix.
Logged In: YES
user_id=402164
Originator: NO
Patch applied (after simplification and cleanup to conform to htmlunit coding guidelines). Thanks.