I am using the HtmlUnit Java library to create a set of regression tests for a web application.
I have an "onload" handler hooked in the body of the application pages to redirect to the timeout page after the session expires. A handler is some kind of JavaScript form:
window.setTimeout( function() { window.location = 'timout.html'; }, 3600000);
I would like to verify that the redirect will eventually start when the time comes, but the closest thing I can find is actually to wait for the entire duration of the time (for example, an hour in the example above), as suggested by the Java sample below:
WebClient webClient = new WebClient(); ... webClient.waitForBackgroundJavaScript( 3600000);
I would like to know if it is possible to fool the script execution mechanism to behave as if a lot of time had passed, without having to wait for minutes or hours of "real time" to run the test suite.
Ideally, you can say that the engine / client / interpreter skipped X milliseconds (to mimic the expectation) or, perhaps, set some kind of “time dilation” factor and poll the page to see how it refreshes.
source share