Bug 1314812 - Remove manual timeout code in favor of letting the test harness do it for us. r=Gijs
MozReview-Commit-ID: 4Nlrw11v4U2
--- a/browser/components/places/tests/browser/head.js
+++ b/browser/components/places/tests/browser/head.js
@@ -154,66 +154,56 @@ function promiseIsURIVisited(aURI) {
deferred.resolve(aIsVisited);
});
return deferred.promise;
}
function promiseBookmarksNotification(notification, conditionFn) {
info(`promiseBookmarksNotification: waiting for ${notification}`);
- return new Promise((resolve, reject) => {
+ return new Promise((resolve) => {
let proxifiedObserver = new Proxy({}, {
get: (target, name) => {
if (name == "QueryInterface")
return XPCOMUtils.generateQI([ Ci.nsINavBookmarkObserver ]);
info(`promiseBookmarksNotification: got ${name} notification`);
if (name == notification)
return (...args) => {
if (conditionFn.apply(this, args)) {
- clearTimeout(timeout);
PlacesUtils.bookmarks.removeObserver(proxifiedObserver, false);
executeSoon(resolve);
} else {
info(`promiseBookmarksNotification: skip cause condition doesn't apply to ${JSON.stringify(args)}`);
}
}
return () => {};
}
});
PlacesUtils.bookmarks.addObserver(proxifiedObserver, false);
- let timeout = setTimeout(() => {
- PlacesUtils.bookmarks.removeObserver(proxifiedObserver, false);
- reject(new Error("Timed out while waiting for bookmarks notification"));
- }, 2000);
});
}
function promiseHistoryNotification(notification, conditionFn) {
info(`Waiting for ${notification}`);
- return new Promise((resolve, reject) => {
+ return new Promise((resolve) => {
let proxifiedObserver = new Proxy({}, {
get: (target, name) => {
if (name == "QueryInterface")
return XPCOMUtils.generateQI([ Ci.nsINavHistoryObserver ]);
if (name == notification)
return (...args) => {
if (conditionFn.apply(this, args)) {
- clearTimeout(timeout);
PlacesUtils.history.removeObserver(proxifiedObserver, false);
executeSoon(resolve);
}
}
return () => {};
}
});
PlacesUtils.history.addObserver(proxifiedObserver, false);
- let timeout = setTimeout(() => {
- PlacesUtils.history.removeObserver(proxifiedObserver, false);
- reject(new Error("Timed out while waiting for history notification"));
- }, 2000);
});
}
/**
* Makes the specified toolbar visible or invisible and returns a Promise object
* that is resolved when the toolbar has completed any animations associated
* with hiding or showing the toolbar.
*