зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1049545
- use a mutation observer instead of a timeout to wait for the notification, r=mak
--HG-- extra : rebase_source : cdab7bb1fb64d167750de48ed5be92cbd0f1cd1c
This commit is contained in:
Родитель
af92c2dec1
Коммит
d9eef29f70
|
@ -3,16 +3,30 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
let notificationObserver;
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref("browser.fixup.domainwhitelist.localhost");
|
||||
if (notificationObserver) {
|
||||
notificationObserver.disconnect();
|
||||
}
|
||||
});
|
||||
|
||||
function promiseNotificationForTab(value, expected, tab=gBrowser.selectedTab) {
|
||||
let deferred = Promise.defer();
|
||||
let notificationBox = gBrowser.getNotificationBox(tab.linkedBrowser);
|
||||
if (expected) {
|
||||
waitForCondition(() => notificationBox.getNotificationWithValue(value) !== null,
|
||||
deferred.resolve, "Were expecting to get a notification");
|
||||
let checkForNotification = function() {
|
||||
if (notificationBox.getNotificationWithValue(value)) {
|
||||
notificationObserver.disconnect();
|
||||
notificationObserver = null;
|
||||
deferred.resolve();
|
||||
}
|
||||
}
|
||||
if (notificationObserver) {
|
||||
notificationObserver.disconnect();
|
||||
}
|
||||
notificationObserver = new MutationObserver(checkForNotification);
|
||||
notificationObserver.observe(notificationBox, {childList: true});
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
is(notificationBox.getNotificationWithValue(value), null, "We are expecting to not get a notification");
|
||||
|
|
Загрузка…
Ссылка в новой задаче