Allow to parametrize waitFor interval & maxTries helper in a given test
Categories
(DevTools :: Console, task, P3)
Tracking
(firefox90 fixed)
| Tracking | Status | |
|---|---|---|
| firefox90 | --- | fixed |
People
(Reporter: jdescottes, Assigned: jdescottes)
References
Details
Attachments
(1 file)
In Bug 1689101, we had intermittent failures because the waitFor helper was too quick to fail. The test was browser_webconsole_network_messages_expand_before_updates.js
There were a lot of waitFor calls in the file (searchfox), so to fix it we created a small wrapper:
async function waitForLonger(predicate) {
const message = "";
// Default interval is 10ms. The test often times out on waitFor statements
// use a 50ms interval instead.
const interval = 50;
const maxTries = 500;
return waitFor(predicate, message, interval, maxTries);
}
But this is not a great solution, and doesn't easily scale for other tests.
It would be great to either:
- have a shared
waitForLongerhelper - have an easy way to parametrize
waitForin each test
I am leaning towards the second option. I think we could for instance drive the interval and maxTries parameters with a preference? Or a global variable? Or properties attached to the waitFor method?
Preferences could rely on the pushPref helper in order to be automatically cleanedUp on test teardown.
waitFor is currently in shared-head.js: https://searchfox.org/mozilla-central/rev/9f76a47f4aa935b49754c5608a1c8e72ee358c46/devtools/client/shared/test/shared-head.js#690-709
async function waitFor(condition, message = "", interval = 10, maxTries = 500) {
try {
const value = await BrowserTestUtils.waitForCondition(
condition,
message,
interval,
maxTries
);
return value;
} catch (e) {
const errorMessage =
"Failed waitFor(): " +
message +
"\n" +
"Failed condition: " +
condition +
"\n";
throw new Error(errorMessage);
}
}
| Assignee | ||
Comment 1•5 years ago
|
||
Depends on D113156
Comment 3•5 years ago
|
||
| bugherder | ||
Description
•