mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00: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. --HG-- extra : commitid : 2LspTl2ii6l extra : rebase_source : 165a9a304634ba399df16d7bd0f74e2f001dad15
This commit is contained in:
parent
f69e8cc585
commit
a9f6da4039
@ -165,17 +165,21 @@ function promisePanelShown(win) {
|
||||
}
|
||||
|
||||
function promisePanelElementEvent(win, aPanel, aEvent) {
|
||||
let deferred = Promise.defer();
|
||||
let timeoutId = win.setTimeout(() => {
|
||||
deferred.reject("Event did not happen within 5 seconds.");
|
||||
}, 5000);
|
||||
aPanel.addEventListener(aEvent, function onPanelEvent(e) {
|
||||
aPanel.removeEventListener(aEvent, onPanelEvent);
|
||||
win.clearTimeout(timeoutId);
|
||||
// Wait one tick to let UITour.jsm process the event as well.
|
||||
executeSoon(deferred.resolve);
|
||||
return new Promise((resolve, reject) => {
|
||||
let timeoutId = win.setTimeout(() => {
|
||||
aPanel.removeEventListener(aEvent, onPanelEvent);
|
||||
reject("Event did not happen within 5 seconds.");
|
||||
}, 5000);
|
||||
|
||||
function onPanelEvent(e) {
|
||||
aPanel.removeEventListener(aEvent, onPanelEvent);
|
||||
win.clearTimeout(timeoutId);
|
||||
// Wait one tick to let UITour.jsm process the event as well.
|
||||
executeSoon(resolve);
|
||||
}
|
||||
|
||||
aPanel.addEventListener(aEvent, onPanelEvent);
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function promisePanelElementShown(win, aPanel) {
|
||||
|
Loading…
Reference in New Issue
Block a user