mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1206943 - UITour: Remove the event listener in promisePanelElementEvent upon timeout. r=bgrins
The event listener wasn't getting removed in the reject case.
This commit is contained in:
parent
79c77dfad2
commit
9f9d0b30ec
@ -165,17 +165,21 @@ function promisePanelShown(win) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function promisePanelElementEvent(win, aPanel, aEvent) {
|
function promisePanelElementEvent(win, aPanel, aEvent) {
|
||||||
let deferred = Promise.defer();
|
return new Promise((resolve, reject) => {
|
||||||
let timeoutId = win.setTimeout(() => {
|
let timeoutId = win.setTimeout(() => {
|
||||||
deferred.reject("Event did not happen within 5 seconds.");
|
aPanel.removeEventListener(aEvent, onPanelEvent);
|
||||||
|
reject("Event did not happen within 5 seconds.");
|
||||||
}, 5000);
|
}, 5000);
|
||||||
aPanel.addEventListener(aEvent, function onPanelEvent(e) {
|
|
||||||
|
function onPanelEvent(e) {
|
||||||
aPanel.removeEventListener(aEvent, onPanelEvent);
|
aPanel.removeEventListener(aEvent, onPanelEvent);
|
||||||
win.clearTimeout(timeoutId);
|
win.clearTimeout(timeoutId);
|
||||||
// Wait one tick to let UITour.jsm process the event as well.
|
// Wait one tick to let UITour.jsm process the event as well.
|
||||||
executeSoon(deferred.resolve);
|
executeSoon(resolve);
|
||||||
|
}
|
||||||
|
|
||||||
|
aPanel.addEventListener(aEvent, onPanelEvent);
|
||||||
});
|
});
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function promisePanelElementShown(win, aPanel) {
|
function promisePanelElementShown(win, aPanel) {
|
||||||
|
Loading…
Reference in New Issue
Block a user