Bug 1824919 - Try to fix intermittent comm/mail/base/test/browser/browser_treeView.js | 'select' event didn't fire before the delay. r=freaktechnik

We can't guarantee the check will take place in the 240-250 time frame. If it gets checked after 250 it may be too late to get the right result.

Differential Revision: https://phabricator.services.mozilla.com/D191085

--HG--
extra : amend_source : 40b07a7d8ebacc806c0ed62350756be01df0405d
This commit is contained in:
Magnus Melin 2023-10-16 19:25:56 +01:00
Родитель 0335a2f1dc
Коммит 2ea7b80cf4
1 изменённых файлов: 8 добавлений и 9 удалений

Просмотреть файл

@ -151,16 +151,20 @@ async function subtestKeyboardAndMouse(variant) {
seenEvent: null,
currentAtEvent: null,
selectedAtEvent: null,
t0: Date.now(),
time: 0,
reset() {
this.seenEvent = null;
this.currentAtEvent = null;
this.selectedAtEvent = null;
this.t0 = Date.now();
},
handleEvent(event) {
this.seenEvent = event;
this.currentAtEvent = list.currentIndex;
this.selectedAtEvent = list.selectedIndices;
this.time = Date.now() - this.t0;
},
};
@ -331,19 +335,14 @@ async function subtestKeyboardAndMouse(variant) {
selectHandler.reset();
list.addEventListener("select", selectHandler, { once: true });
EventUtils.synthesizeKey(key, modifiers, content);
// We don't enforce any delay on multiselection.
if (!modifiers.shiftKey && !modifiers.accelKey) {
content.setTimeout(() => {
Assert.ok(
!selectHandler.seenEvent,
"'select' event didn't fire before the delay"
);
}, 240);
}
await TestUtils.waitForCondition(
() => !!selectHandler.seenEvent == expectEvent,
`'select' event should ${expectEvent ? "" : "not "}get fired`
);
// We don't enforce any delay on multiselection.
if (expectEvent && !modifiers.shiftKey && !modifiers.accelKey) {
Assert.greater(selectHandler.time, 240, "should select only after delay");
}
}
await pressKey("VK_UP");