Bug 1355473 - convert uses of 'defer' to 'new Promise' in client/responsivedesign; r=tromey

MozReview-Commit-ID: L9tNE28knjF

--HG--
extra : rebase_source : ef6c02f39b5446df2120b3f0936958d30ee4ef6f
This commit is contained in:
Matt R 2017-05-21 12:54:48 +01:00
Родитель cd5f595a60
Коммит 35ad0c68cf
2 изменённых файлов: 25 добавлений и 25 удалений

Просмотреть файл

@ -142,7 +142,7 @@ function synthesizeClick(element) {
} }
function pushPrefs(...aPrefs) { function pushPrefs(...aPrefs) {
let deferred = promise.defer(); return new Promise(resolve => {
SpecialPowers.pushPrefEnv({"set": aPrefs}, deferred.resolve); SpecialPowers.pushPrefEnv({"set": aPrefs}, resolve);
return deferred.promise; });
} }

Просмотреть файл

@ -130,9 +130,9 @@ var closeToolbox = Task.async(function* () {
*/ */
function waitForToolboxFrameFocus(toolbox) { function waitForToolboxFrameFocus(toolbox) {
info("Making sure that the toolbox's frame is focused"); info("Making sure that the toolbox's frame is focused");
let def = promise.defer(); return new Promise(resolve => {
waitForFocus(def.resolve, toolbox.win); waitForFocus(resolve, toolbox.win);
return def.promise; });
} }
/** /**
@ -210,27 +210,27 @@ var addTab = Task.async(function* (url) {
* @return promise * @return promise
*/ */
function waitForDocLoadComplete(aBrowser = gBrowser) { function waitForDocLoadComplete(aBrowser = gBrowser) {
let deferred = promise.defer(); return new Promise(resolve => {
let progressListener = { let progressListener = {
onStateChange: function (webProgress, req, flags, status) { onStateChange: function (webProgress, req, flags, status) {
let docStop = Ci.nsIWebProgressListener.STATE_IS_NETWORK | let docStop = Ci.nsIWebProgressListener.STATE_IS_NETWORK |
Ci.nsIWebProgressListener.STATE_STOP; Ci.nsIWebProgressListener.STATE_STOP;
info(`Saw state ${flags.toString(16)} and status ${status.toString(16)}`); info(`Saw state ${flags.toString(16)} and status ${status.toString(16)}`);
// When a load needs to be retargetted to a new process it is cancelled // When a load needs to be retargetted to a new process it is cancelled
// with NS_BINDING_ABORTED so ignore that case // with NS_BINDING_ABORTED so ignore that case
if ((flags & docStop) == docStop && status != Cr.NS_BINDING_ABORTED) { if ((flags & docStop) == docStop && status != Cr.NS_BINDING_ABORTED) {
aBrowser.removeProgressListener(progressListener); aBrowser.removeProgressListener(progressListener);
info("Browser loaded"); info("Browser loaded");
deferred.resolve(); resolve();
} }
}, },
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference]) Ci.nsISupportsWeakReference])
}; };
aBrowser.addProgressListener(progressListener); aBrowser.addProgressListener(progressListener);
info("Waiting for browser load"); info("Waiting for browser load");
return deferred.promise; });
} }
/** /**