Looking to test pages with numerous setTimeout functions, I'm searching for a way to expedite the code execution upon page load rather than waiting for it to run on its own.
One idea is to inject custom JavaScript like this into the page before evaluating it:
var originalSetTimeout = window.setTimeout;
window.setTimeout = function(a, t) {
originalSetTimeout(a, 0);
}
However, I need guidance on how to go about implementing this approach or if there are better alternatives available that I might be unaware of.
It's important to note that removing the existing setTimeout code from the pages under testing is not an option in this scenario.