-
-
Notifications
You must be signed in to change notification settings - Fork 184
Description
I mean this 2 methods:
public int waitForBackgroundJavaScript(final long timeoutMillis)
public int waitForBackgroundJavaScriptStartingBefore(final long delayMillis)
We usually do this when opening a page:
Page p=webClient.getPage(...);
webClient.waitForBackgroundJavaScriptStartingBefore(5000);
I noticed in some cases background jobs are not executed. For example with this kind of onload function:
function my_onload() {
do_some_time_consuming_work(); //this costs like 2000ms
setTimeout(time_func, 0);
}
In the case above, I noticed the 'time_func' sometimes executed but sometimes did not.
With waitForBackgroundJavaScriptStartingBefore(5000) I expect that all jobs run normally and those jobs started before 5000 will complete. But the fact is not that case. I checked the source and found that the waitForBackgroundJavaScriptStartingBefore locks the job manager while adding job requires that lock. So there will be no jobs added to the job queue after the waitForBackgroundJavaScriptxxx() method starts. That's not what I expected.
Is that a problem or I miss understood?