gecko-dev/toolkit/content/tests/browser/head.js
Dave Townsend 6e44ebad84 Bug 1257246: Update toolkit for eslint 2. r=Gijs
Most of this is fixing functions that in some cases return a value but then
can also run to completion without returning anything. ESLint 2 catches this
where previous versions didn't. Unless there was an obvious other choice I just
made these functions return undefined at the end which is effectively what
already happens.

MozReview-Commit-ID: KHYdAkRvhVr

--HG--
extra : rebase_source : 720cc9d864175248508146a7f4704b4bf3f02439
extra : histedit_source : 6cc0ecbf21a571e1a41d517b67512a3452fac19a
2016-04-05 11:33:48 -07:00

33 lines
834 B
JavaScript

"use strict";
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
/**
* A wrapper for the findbar's method "close", which is not synchronous
* because of animation.
*/
function closeFindbarAndWait(findbar) {
return new Promise((resolve) => {
if (findbar.hidden) {
resolve();
return;
}
findbar.addEventListener("transitionend", function cont(aEvent) {
if (aEvent.propertyName != "visibility") {
return;
}
findbar.removeEventListener("transitionend", cont);
resolve();
});
findbar.close();
});
}
function pushPrefs(...aPrefs) {
let deferred = Promise.defer();
SpecialPowers.pushPrefEnv({"set": aPrefs}, deferred.resolve);
return deferred.promise;
}