Skip to content

Commit

Permalink
debug ph_wait_cond()
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpitt committed Aug 7, 2024
1 parent 5b16069 commit 00738d8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/common/test-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,25 @@ window.ph_wait_cond = function(cond, timeout, error_description) {
let stepTimer = null;
let last_err = null;
const tm = window.setTimeout(() => {
if (stepTimer)
if (stepTimer) {
console.log("XXX ph_wait_cond timer(): clearing stepTimer");
window.clearTimeout(stepTimer);
} else
console.log("XXX ph_wait_cond timer(): stepTimer already not set");
console.log("XXX ph_wait_cond timer(): rejecting");
reject(last_err || new PhWaitCondTimeout(error_description));
}, timeout);
function step() {
try {
if (cond()) {
console.log("XXX ph_wait_cond step(): condition is true, resolving");
window.clearTimeout(tm);
resolve();
return;
}
console.log("XXX ph_wait_cond step(): condition is false, stepping");
} catch (err) {
console.log("XXX ph_wait_cond step(): condition errored", err, "stepping");
last_err = err;
}
stepTimer = window.setTimeout(step, 100);
Expand Down

0 comments on commit 00738d8

Please sign in to comment.