Bug 1873189 - Port bug 1845586 - Replace PromiseUtils.defer with Promise.withResolvers. r=aleca
Differential Revision: https://phabricator.services.mozilla.com/D197777 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f7576e31f4
Коммит
87b2fa80d3
|
@ -1027,7 +1027,7 @@ let CalendarFilteredViewMixin = Base =>
|
||||||
*
|
*
|
||||||
* @type {object}
|
* @type {object}
|
||||||
*/
|
*/
|
||||||
#deferred = PromiseUtils.defer();
|
#deferred = Promise.withResolvers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Any async iterator currently reading from a calendar.
|
* Any async iterator currently reading from a calendar.
|
||||||
|
@ -1232,7 +1232,7 @@ let CalendarFilteredViewMixin = Base =>
|
||||||
// If a previous refresh completed, start a new Promise that resolves when the next refresh
|
// If a previous refresh completed, start a new Promise that resolves when the next refresh
|
||||||
// completes. Otherwise, continue with the current Promise.
|
// completes. Otherwise, continue with the current Promise.
|
||||||
// If #currentRefresh is completed, #deferred is already resolved, so we can safely discard it.
|
// If #currentRefresh is completed, #deferred is already resolved, so we can safely discard it.
|
||||||
this.#deferred = PromiseUtils.defer();
|
this.#deferred = Promise.withResolvers();
|
||||||
}
|
}
|
||||||
this.#currentRefresh = null;
|
this.#currentRefresh = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ add_setup(async function () {
|
||||||
loginInfo.init(CalDAVServer.origin, null, "test", "bob", "bob", "", "");
|
loginInfo.init(CalDAVServer.origin, null, "test", "bob", "bob", "", "");
|
||||||
await Services.logins.addLoginAsync(loginInfo);
|
await Services.logins.addLoginAsync(loginInfo);
|
||||||
}
|
}
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
calendar = createCalendar("caldav", CalDAVServer.url, true);
|
calendar = createCalendar("caldav", CalDAVServer.url, true);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
info("calendar set-up complete");
|
info("calendar set-up complete");
|
||||||
|
|
|
@ -14,7 +14,7 @@ add_setup(async function () {
|
||||||
loginInfo.init(CalDAVServer.origin, null, "test", "bob", "bob", "", "");
|
loginInfo.init(CalDAVServer.origin, null, "test", "bob", "bob", "", "");
|
||||||
await Services.logins.addLoginAsync(loginInfo);
|
await Services.logins.addLoginAsync(loginInfo);
|
||||||
}
|
}
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
calendar = createCalendar("caldav", CalDAVServer.url, false);
|
calendar = createCalendar("caldav", CalDAVServer.url, false);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
info("calendar set-up complete");
|
info("calendar set-up complete");
|
||||||
|
|
|
@ -21,7 +21,7 @@ add_setup(async function () {
|
||||||
// Remove the next line when this is fixed.
|
// Remove the next line when this is fixed.
|
||||||
calendarObserver._batchRequired = false;
|
calendarObserver._batchRequired = false;
|
||||||
|
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
calendar = createCalendar("ics", ICSServer.url, true);
|
calendar = createCalendar("ics", ICSServer.url, true);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
info("calendar set-up complete");
|
info("calendar set-up complete");
|
||||||
|
|
|
@ -14,7 +14,7 @@ add_setup(async function () {
|
||||||
loginInfo.init(ICSServer.origin, null, "test", "bob", "bob", "", "");
|
loginInfo.init(ICSServer.origin, null, "test", "bob", "bob", "", "");
|
||||||
await Services.logins.addLoginAsync(loginInfo);
|
await Services.logins.addLoginAsync(loginInfo);
|
||||||
}
|
}
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
calendar = createCalendar("ics", ICSServer.url, false);
|
calendar = createCalendar("ics", ICSServer.url, false);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
info("calendar set-up complete");
|
info("calendar set-up complete");
|
||||||
|
|
|
@ -111,8 +111,8 @@ async function runAddItem(calendar) {
|
||||||
event.startDate = cal.createDateTime("20200303T205500Z");
|
event.startDate = cal.createDateTime("20200303T205500Z");
|
||||||
event.endDate = cal.createDateTime("20200303T210200Z");
|
event.endDate = cal.createDateTime("20200303T210200Z");
|
||||||
|
|
||||||
calendarObserver._onAddItemPromise = PromiseUtils.defer();
|
calendarObserver._onAddItemPromise = Promise.withResolvers();
|
||||||
calendarObserver._onModifyItemPromise = PromiseUtils.defer();
|
calendarObserver._onModifyItemPromise = Promise.withResolvers();
|
||||||
await calendar.addItem(event);
|
await calendar.addItem(event);
|
||||||
await Promise.any([
|
await Promise.any([
|
||||||
calendarObserver._onAddItemPromise.promise,
|
calendarObserver._onAddItemPromise.promise,
|
||||||
|
@ -133,7 +133,7 @@ async function runModifyItem(calendar) {
|
||||||
const clone = event.clone();
|
const clone = event.clone();
|
||||||
clone.title = "Modified event";
|
clone.title = "Modified event";
|
||||||
|
|
||||||
calendarObserver._onModifyItemPromise = PromiseUtils.defer();
|
calendarObserver._onModifyItemPromise = Promise.withResolvers();
|
||||||
await calendar.modifyItem(clone, event);
|
await calendar.modifyItem(clone, event);
|
||||||
await calendarObserver._onModifyItemPromise.promise;
|
await calendarObserver._onModifyItemPromise.promise;
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ async function runModifyItem(calendar) {
|
||||||
async function runDeleteItem(calendar) {
|
async function runDeleteItem(calendar) {
|
||||||
const event = await calendar.getItem("6b7dd6f6-d6f0-4e93-a953-bb5473c4c47a");
|
const event = await calendar.getItem("6b7dd6f6-d6f0-4e93-a953-bb5473c4c47a");
|
||||||
|
|
||||||
calendarObserver._onDeleteItemPromise = PromiseUtils.defer();
|
calendarObserver._onDeleteItemPromise = Promise.withResolvers();
|
||||||
await calendar.deleteItem(event);
|
await calendar.deleteItem(event);
|
||||||
await calendarObserver._onDeleteItemPromise.promise;
|
await calendarObserver._onDeleteItemPromise.promise;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ add_setup(async function () {
|
||||||
registerCleanupFunction(() => CalDAVServer.close());
|
registerCleanupFunction(() => CalDAVServer.close());
|
||||||
|
|
||||||
add_task(async function () {
|
add_task(async function () {
|
||||||
calendarObserver._onAddItemPromise = PromiseUtils.defer();
|
calendarObserver._onAddItemPromise = Promise.withResolvers();
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
const calendar = createCalendar("caldav", CalDAVServer.url, true);
|
const calendar = createCalendar("caldav", CalDAVServer.url, true);
|
||||||
await calendarObserver._onAddItemPromise.promise;
|
await calendarObserver._onAddItemPromise.promise;
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
@ -34,12 +34,12 @@ add_task(async function () {
|
||||||
|
|
||||||
info("creating the item");
|
info("creating the item");
|
||||||
calendarObserver._batchRequired = true;
|
calendarObserver._batchRequired = true;
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
await runAddItem(calendar);
|
await runAddItem(calendar);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
|
||||||
info("modifying the item");
|
info("modifying the item");
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
await runModifyItem(calendar);
|
await runModifyItem(calendar);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ add_task(async function () {
|
||||||
*/
|
*/
|
||||||
add_task(async function testCalendarWithNoPrivSupport() {
|
add_task(async function testCalendarWithNoPrivSupport() {
|
||||||
CalDAVServer.privileges = null;
|
CalDAVServer.privileges = null;
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
|
|
||||||
const calendar = createCalendar("caldav", CalDAVServer.url, true);
|
const calendar = createCalendar("caldav", CalDAVServer.url, true);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
@ -100,8 +100,8 @@ add_task(async function testModifyItemWithNoChanges() {
|
||||||
* items from the local calendar.
|
* items from the local calendar.
|
||||||
*/
|
*/
|
||||||
add_task(async function testSyncError1() {
|
add_task(async function testSyncError1() {
|
||||||
calendarObserver._onAddItemPromise = PromiseUtils.defer();
|
calendarObserver._onAddItemPromise = Promise.withResolvers();
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
const calendar = createCalendar("caldav", CalDAVServer.url, true);
|
const calendar = createCalendar("caldav", CalDAVServer.url, true);
|
||||||
await calendarObserver._onAddItemPromise.promise;
|
await calendarObserver._onAddItemPromise.promise;
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
@ -114,7 +114,7 @@ add_task(async function testSyncError1() {
|
||||||
|
|
||||||
info("syncing with rate limit error");
|
info("syncing with rate limit error");
|
||||||
CalDAVServer.throwRateLimitErrors = true;
|
CalDAVServer.throwRateLimitErrors = true;
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
calendar.refresh();
|
calendar.refresh();
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
CalDAVServer.throwRateLimitErrors = false;
|
CalDAVServer.throwRateLimitErrors = false;
|
||||||
|
@ -132,7 +132,7 @@ add_task(async function testSyncError1() {
|
||||||
);
|
);
|
||||||
|
|
||||||
info("syncing without rate limit error");
|
info("syncing without rate limit error");
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
calendar.refresh();
|
calendar.refresh();
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
info("sync without rate limit error complete");
|
info("sync without rate limit error complete");
|
||||||
|
@ -171,8 +171,8 @@ add_task(async function testSyncError2() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
calendarObserver._onAddItemPromise = PromiseUtils.defer();
|
calendarObserver._onAddItemPromise = Promise.withResolvers();
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
const calendar = createCalendar("caldav", CalDAVServer.url, true);
|
const calendar = createCalendar("caldav", CalDAVServer.url, true);
|
||||||
await calendarObserver._onAddItemPromise.promise;
|
await calendarObserver._onAddItemPromise.promise;
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
@ -184,7 +184,7 @@ add_task(async function testSyncError2() {
|
||||||
info("forced syncing with multiple pages");
|
info("forced syncing with multiple pages");
|
||||||
calendar.wrappedJSObject.mUncachedCalendar.wrappedJSObject.mWebdavSyncToken = null;
|
calendar.wrappedJSObject.mUncachedCalendar.wrappedJSObject.mWebdavSyncToken = null;
|
||||||
calendar.wrappedJSObject.mUncachedCalendar.wrappedJSObject.saveCalendarProperties();
|
calendar.wrappedJSObject.mUncachedCalendar.wrappedJSObject.saveCalendarProperties();
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
calendar.refresh();
|
calendar.refresh();
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
info("forced sync with multiple pages complete");
|
info("forced sync with multiple pages complete");
|
||||||
|
|
|
@ -23,8 +23,8 @@ add_setup(async function () {
|
||||||
registerCleanupFunction(() => CalDAVServer.close());
|
registerCleanupFunction(() => CalDAVServer.close());
|
||||||
|
|
||||||
add_task(async function () {
|
add_task(async function () {
|
||||||
calendarObserver._onAddItemPromise = PromiseUtils.defer();
|
calendarObserver._onAddItemPromise = Promise.withResolvers();
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
const calendar = createCalendar("caldav", CalDAVServer.url, false);
|
const calendar = createCalendar("caldav", CalDAVServer.url, false);
|
||||||
await calendarObserver._onAddItemPromise.promise;
|
await calendarObserver._onAddItemPromise.promise;
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
@ -34,12 +34,12 @@ add_task(async function () {
|
||||||
|
|
||||||
info("creating the item");
|
info("creating the item");
|
||||||
calendarObserver._batchRequired = true;
|
calendarObserver._batchRequired = true;
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
await runAddItem(calendar);
|
await runAddItem(calendar);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
|
||||||
info("modifying the item");
|
info("modifying the item");
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
await runModifyItem(calendar);
|
await runModifyItem(calendar);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ add_task(async function () {
|
||||||
*/
|
*/
|
||||||
add_task(async function testCalendarWithNoPrivSupport() {
|
add_task(async function testCalendarWithNoPrivSupport() {
|
||||||
CalDAVServer.privileges = null;
|
CalDAVServer.privileges = null;
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
|
|
||||||
const calendar = createCalendar("caldav", CalDAVServer.url, false);
|
const calendar = createCalendar("caldav", CalDAVServer.url, false);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
|
|
@ -27,8 +27,8 @@ add_task(async function () {
|
||||||
// Remove the next line when this is fixed.
|
// Remove the next line when this is fixed.
|
||||||
calendarObserver._batchRequired = false;
|
calendarObserver._batchRequired = false;
|
||||||
|
|
||||||
calendarObserver._onAddItemPromise = PromiseUtils.defer();
|
calendarObserver._onAddItemPromise = Promise.withResolvers();
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
const calendar = createCalendar("ics", ICSServer.url, true);
|
const calendar = createCalendar("ics", ICSServer.url, true);
|
||||||
await calendarObserver._onAddItemPromise.promise;
|
await calendarObserver._onAddItemPromise.promise;
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
@ -37,17 +37,17 @@ add_task(async function () {
|
||||||
Assert.ok(await calendar.getItem("5a9fa76c-93f3-4ad8-9f00-9e52aedd2821"));
|
Assert.ok(await calendar.getItem("5a9fa76c-93f3-4ad8-9f00-9e52aedd2821"));
|
||||||
|
|
||||||
info("creating the item");
|
info("creating the item");
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
await runAddItem(calendar);
|
await runAddItem(calendar);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
|
||||||
info("modifying the item");
|
info("modifying the item");
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
await runModifyItem(calendar);
|
await runModifyItem(calendar);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
|
||||||
info("deleting the item");
|
info("deleting the item");
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
await runDeleteItem(calendar);
|
await runDeleteItem(calendar);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,8 +20,8 @@ ICSServer.putICSInternal(
|
||||||
registerCleanupFunction(() => ICSServer.close());
|
registerCleanupFunction(() => ICSServer.close());
|
||||||
|
|
||||||
add_task(async function () {
|
add_task(async function () {
|
||||||
calendarObserver._onAddItemPromise = PromiseUtils.defer();
|
calendarObserver._onAddItemPromise = Promise.withResolvers();
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
const calendar = createCalendar("ics", ICSServer.url, false);
|
const calendar = createCalendar("ics", ICSServer.url, false);
|
||||||
await calendarObserver._onAddItemPromise.promise;
|
await calendarObserver._onAddItemPromise.promise;
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
@ -30,17 +30,17 @@ add_task(async function () {
|
||||||
Assert.ok(await calendar.getItem("5a9fa76c-93f3-4ad8-9f00-9e52aedd2821"));
|
Assert.ok(await calendar.getItem("5a9fa76c-93f3-4ad8-9f00-9e52aedd2821"));
|
||||||
|
|
||||||
info("creating the item");
|
info("creating the item");
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
await runAddItem(calendar);
|
await runAddItem(calendar);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
|
||||||
info("modifying the item");
|
info("modifying the item");
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
await runModifyItem(calendar);
|
await runModifyItem(calendar);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
|
|
||||||
info("deleting the item");
|
info("deleting the item");
|
||||||
calendarObserver._onLoadPromise = PromiseUtils.defer();
|
calendarObserver._onLoadPromise = Promise.withResolvers();
|
||||||
await runDeleteItem(calendar);
|
await runDeleteItem(calendar);
|
||||||
await calendarObserver._onLoadPromise.promise;
|
await calendarObserver._onLoadPromise.promise;
|
||||||
});
|
});
|
||||||
|
|
|
@ -84,7 +84,7 @@ const webProgressListener = {
|
||||||
Ci.nsIWebProgress.NOTIFY_STATE_ALL | Ci.nsIWebProgress.NOTIFY_LOCATION
|
Ci.nsIWebProgress.NOTIFY_STATE_ALL | Ci.nsIWebProgress.NOTIFY_LOCATION
|
||||||
);
|
);
|
||||||
|
|
||||||
this._deferred = PromiseUtils.defer();
|
this._deferred = Promise.withResolvers();
|
||||||
return this._deferred.promise;
|
return this._deferred.promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ const mockExternalProtocolService = {
|
||||||
},
|
},
|
||||||
|
|
||||||
promiseEvent() {
|
promiseEvent() {
|
||||||
this._deferred = PromiseUtils.defer();
|
this._deferred = Promise.withResolvers();
|
||||||
return this._deferred.promise;
|
return this._deferred.promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -501,7 +501,7 @@ const mockExternalProtocolService = {
|
||||||
},
|
},
|
||||||
|
|
||||||
promiseEvent() {
|
promiseEvent() {
|
||||||
this._deferred = PromiseUtils.defer();
|
this._deferred = Promise.withResolvers();
|
||||||
return this._deferred.promise;
|
return this._deferred.promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ class MockAlertsService {
|
||||||
QueryInterface = ChromeUtils.generateQI(["nsIAlertsService"]);
|
QueryInterface = ChromeUtils.generateQI(["nsIAlertsService"]);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._deferredPromise = PromiseUtils.defer();
|
this._deferredPromise = Promise.withResolvers();
|
||||||
}
|
}
|
||||||
|
|
||||||
showAlert() {
|
showAlert() {
|
||||||
|
@ -110,7 +110,7 @@ class MockAlertsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
deferPromise() {
|
deferPromise() {
|
||||||
this._deferredPromise = PromiseUtils.defer();
|
this._deferredPromise = Promise.withResolvers();
|
||||||
}
|
}
|
||||||
|
|
||||||
get promise() {
|
get promise() {
|
||||||
|
|
|
@ -79,7 +79,7 @@ add_task(async function testCreateCard() {
|
||||||
// Saving the contact will get an immediate notification.
|
// Saving the contact will get an immediate notification.
|
||||||
// Delay the server response so we can test the state of the UI.
|
// Delay the server response so we can test the state of the UI.
|
||||||
const promise1 = TestUtils.topicObserved("addrbook-contact-created");
|
const promise1 = TestUtils.topicObserved("addrbook-contact-created");
|
||||||
CardDAVServer.responseDelay = PromiseUtils.defer();
|
CardDAVServer.responseDelay = Promise.withResolvers();
|
||||||
EventUtils.synthesizeMouseAtCenter(saveEditButton, {}, abWindow);
|
EventUtils.synthesizeMouseAtCenter(saveEditButton, {}, abWindow);
|
||||||
await promise1;
|
await promise1;
|
||||||
await notInEditingMode();
|
await notInEditingMode();
|
||||||
|
@ -105,7 +105,7 @@ add_task(async function testCreateCard() {
|
||||||
// Saving the contact will get an immediate notification.
|
// Saving the contact will get an immediate notification.
|
||||||
// Delay the server response so we can test the state of the UI.
|
// Delay the server response so we can test the state of the UI.
|
||||||
const promise3 = TestUtils.topicObserved("addrbook-contact-updated");
|
const promise3 = TestUtils.topicObserved("addrbook-contact-updated");
|
||||||
CardDAVServer.responseDelay = PromiseUtils.defer();
|
CardDAVServer.responseDelay = Promise.withResolvers();
|
||||||
EventUtils.synthesizeMouseAtCenter(saveEditButton, {}, abWindow);
|
EventUtils.synthesizeMouseAtCenter(saveEditButton, {}, abWindow);
|
||||||
await promise3;
|
await promise3;
|
||||||
await notInEditingMode();
|
await notInEditingMode();
|
||||||
|
@ -129,7 +129,7 @@ add_task(async function testCreateCard() {
|
||||||
// Saving the contact will get an immediate notification.
|
// Saving the contact will get an immediate notification.
|
||||||
// Delay the server response so we can test the state of the UI.
|
// Delay the server response so we can test the state of the UI.
|
||||||
const promise5 = TestUtils.topicObserved("addrbook-contact-deleted");
|
const promise5 = TestUtils.topicObserved("addrbook-contact-deleted");
|
||||||
CardDAVServer.responseDelay = PromiseUtils.defer();
|
CardDAVServer.responseDelay = Promise.withResolvers();
|
||||||
BrowserTestUtils.promiseAlertDialog("accept");
|
BrowserTestUtils.promiseAlertDialog("accept");
|
||||||
EventUtils.synthesizeMouseAtCenter(deleteButton, {}, abWindow);
|
EventUtils.synthesizeMouseAtCenter(deleteButton, {}, abWindow);
|
||||||
await promise5;
|
await promise5;
|
||||||
|
@ -178,7 +178,7 @@ add_task(async function testCreateCardWithUIDChange() {
|
||||||
// Saving the contact will get an immediate notification.
|
// Saving the contact will get an immediate notification.
|
||||||
// Delay the server response so we can test the state of the UI.
|
// Delay the server response so we can test the state of the UI.
|
||||||
const promise1 = TestUtils.topicObserved("addrbook-contact-created");
|
const promise1 = TestUtils.topicObserved("addrbook-contact-created");
|
||||||
CardDAVServer.responseDelay = PromiseUtils.defer();
|
CardDAVServer.responseDelay = Promise.withResolvers();
|
||||||
EventUtils.synthesizeMouseAtCenter(saveEditButton, {}, abWindow);
|
EventUtils.synthesizeMouseAtCenter(saveEditButton, {}, abWindow);
|
||||||
await promise1;
|
await promise1;
|
||||||
await notInEditingMode();
|
await notInEditingMode();
|
||||||
|
@ -219,7 +219,7 @@ add_task(async function testCreateCardWithUIDChange() {
|
||||||
// Saving the contact will get an immediate notification.
|
// Saving the contact will get an immediate notification.
|
||||||
// Delay the server response so we can test the state of the UI.
|
// Delay the server response so we can test the state of the UI.
|
||||||
const promise4 = TestUtils.topicObserved("addrbook-contact-deleted");
|
const promise4 = TestUtils.topicObserved("addrbook-contact-deleted");
|
||||||
CardDAVServer.responseDelay = PromiseUtils.defer();
|
CardDAVServer.responseDelay = Promise.withResolvers();
|
||||||
BrowserTestUtils.promiseAlertDialog("accept");
|
BrowserTestUtils.promiseAlertDialog("accept");
|
||||||
EventUtils.synthesizeMouseAtCenter(deleteButton, {}, abWindow);
|
EventUtils.synthesizeMouseAtCenter(deleteButton, {}, abWindow);
|
||||||
await promise4;
|
await promise4;
|
||||||
|
|
|
@ -354,7 +354,7 @@ var gBrowserInit = {
|
||||||
|
|
||||||
const initiallyFocusedElement = document.commandDispatcher.focusedElement;
|
const initiallyFocusedElement = document.commandDispatcher.focusedElement;
|
||||||
const promise = gBrowser.selectedBrowser.isRemoteBrowser
|
const promise = gBrowser.selectedBrowser.isRemoteBrowser
|
||||||
? PromiseUtils.defer().promise
|
? Promise.withResolvers().promise
|
||||||
: Promise.resolve();
|
: Promise.resolve();
|
||||||
|
|
||||||
contentProgress.addListener({
|
contentProgress.addListener({
|
||||||
|
|
|
@ -70,7 +70,7 @@ const tabListener = {
|
||||||
awaitTabReady(nativeTabInfo) {
|
awaitTabReady(nativeTabInfo) {
|
||||||
let deferred = this.tabReadyPromises.get(nativeTabInfo);
|
let deferred = this.tabReadyPromises.get(nativeTabInfo);
|
||||||
if (!deferred) {
|
if (!deferred) {
|
||||||
deferred = PromiseUtils.defer();
|
deferred = Promise.withResolvers();
|
||||||
const browser = getTabBrowser(nativeTabInfo);
|
const browser = getTabBrowser(nativeTabInfo);
|
||||||
if (
|
if (
|
||||||
!this.initializingTabs.has(nativeTabInfo) &&
|
!this.initializingTabs.has(nativeTabInfo) &&
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["PopupNotifications"];
|
var EXPORTED_SYMBOLS = ["PopupNotifications"];
|
||||||
|
|
||||||
const { PromiseUtils } = ChromeUtils.importESModule(
|
|
||||||
"resource://gre/modules/PromiseUtils.sys.mjs"
|
|
||||||
);
|
|
||||||
|
|
||||||
const NOTIFICATION_EVENT_DISMISSED = "dismissed";
|
const NOTIFICATION_EVENT_DISMISSED = "dismissed";
|
||||||
const NOTIFICATION_EVENT_REMOVED = "removed";
|
const NOTIFICATION_EVENT_REMOVED = "removed";
|
||||||
const NOTIFICATION_EVENT_SHOWING = "showing";
|
const NOTIFICATION_EVENT_SHOWING = "showing";
|
||||||
|
@ -638,7 +634,7 @@ PopupNotifications.prototype = {
|
||||||
if (this._ignoreDismissal) {
|
if (this._ignoreDismissal) {
|
||||||
return this._ignoreDismissal.promise;
|
return this._ignoreDismissal.promise;
|
||||||
}
|
}
|
||||||
const deferred = PromiseUtils.defer();
|
const deferred = Promise.withResolvers();
|
||||||
this._ignoreDismissal = deferred;
|
this._ignoreDismissal = deferred;
|
||||||
this.panel.hidePopup();
|
this.panel.hidePopup();
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
|
|
|
@ -50,12 +50,12 @@ var gDBView;
|
||||||
var gTreeView;
|
var gTreeView;
|
||||||
|
|
||||||
var CommandUpdaterWithPromise = function () {
|
var CommandUpdaterWithPromise = function () {
|
||||||
this.deferred = PromiseUtils.defer();
|
this.deferred = Promise.withResolvers();
|
||||||
};
|
};
|
||||||
CommandUpdaterWithPromise.prototype = {
|
CommandUpdaterWithPromise.prototype = {
|
||||||
async promiseSelectionSummarized() {
|
async promiseSelectionSummarized() {
|
||||||
await this.deferred.promise;
|
await this.deferred.promise;
|
||||||
this.deferred = PromiseUtils.defer();
|
this.deferred = Promise.withResolvers();
|
||||||
return this.deferred.promise;
|
return this.deferred.promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ add_task(async function testBccWithSendLater() {
|
||||||
);
|
);
|
||||||
await promise;
|
await promise;
|
||||||
|
|
||||||
const onStopSendingPromise = PromiseUtils.defer();
|
const onStopSendingPromise = Promise.withResolvers();
|
||||||
const msgSendLater = Cc[
|
const msgSendLater = Cc[
|
||||||
"@mozilla.org/messengercompose/sendlater;1"
|
"@mozilla.org/messengercompose/sendlater;1"
|
||||||
].getService(Ci.nsIMsgSendLater);
|
].getService(Ci.nsIMsgSendLater);
|
||||||
|
@ -299,7 +299,7 @@ add_task(async function testBccOnlyWithSendLater() {
|
||||||
);
|
);
|
||||||
await promise;
|
await promise;
|
||||||
|
|
||||||
const onStopSendingPromise = PromiseUtils.defer();
|
const onStopSendingPromise = Promise.withResolvers();
|
||||||
const msgSendLater = Cc[
|
const msgSendLater = Cc[
|
||||||
"@mozilla.org/messengercompose/sendlater;1"
|
"@mozilla.org/messengercompose/sendlater;1"
|
||||||
].getService(Ci.nsIMsgSendLater);
|
].getService(Ci.nsIMsgSendLater);
|
||||||
|
|
|
@ -47,7 +47,7 @@ var msgSendLater = Cc["@mozilla.org/messengercompose/sendlater;1"].getService(
|
||||||
);
|
);
|
||||||
|
|
||||||
var messageListener;
|
var messageListener;
|
||||||
var onStopCopyPromise = PromiseUtils.defer();
|
var onStopCopyPromise = Promise.withResolvers();
|
||||||
|
|
||||||
/* exported OnStopCopy */
|
/* exported OnStopCopy */
|
||||||
// for head_compose.js
|
// for head_compose.js
|
||||||
|
@ -184,7 +184,7 @@ async function sendMessageLater(aTestFileIndex) {
|
||||||
);
|
);
|
||||||
await onStopCopyPromise.promise;
|
await onStopCopyPromise.promise;
|
||||||
// Reset onStopCopyPromise.
|
// Reset onStopCopyPromise.
|
||||||
onStopCopyPromise = PromiseUtils.defer();
|
onStopCopyPromise = Promise.withResolvers();
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetCounts() {
|
function resetCounts() {
|
||||||
|
@ -214,7 +214,7 @@ async function sendUnsentMessages() {
|
||||||
// sequence and ensures the data is correct.
|
// sequence and ensures the data is correct.
|
||||||
class MsgSendLaterListener {
|
class MsgSendLaterListener {
|
||||||
constructor() {
|
constructor() {
|
||||||
this._deferredPromise = PromiseUtils.defer();
|
this._deferredPromise = Promise.withResolvers();
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMessageSend(aCurrentMessage) {
|
checkMessageSend(aCurrentMessage) {
|
||||||
|
@ -292,7 +292,7 @@ class MsgSendLaterListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
deferPromise() {
|
deferPromise() {
|
||||||
this._deferredPromise = PromiseUtils.defer();
|
this._deferredPromise = Promise.withResolvers();
|
||||||
}
|
}
|
||||||
|
|
||||||
get promise() {
|
get promise() {
|
||||||
|
|
|
@ -44,7 +44,7 @@ const contents = "Sundays are nothing without callaloo.";
|
||||||
*/
|
*/
|
||||||
const headerSink = {
|
const headerSink = {
|
||||||
expectResults(maxLen) {
|
expectResults(maxLen) {
|
||||||
this._deferred = PromiseUtils.defer();
|
this._deferred = Promise.withResolvers();
|
||||||
this.expectedCount = maxLen;
|
this.expectedCount = maxLen;
|
||||||
this.countReceived = 0;
|
this.countReceived = 0;
|
||||||
this.results = [];
|
this.results = [];
|
||||||
|
|
|
@ -81,7 +81,7 @@ var smimeDataDirectory = "../../../data/smime/";
|
||||||
const smimeHeaderSink = {
|
const smimeHeaderSink = {
|
||||||
expectResults(maxLen) {
|
expectResults(maxLen) {
|
||||||
// dump("Restarting for next test\n");
|
// dump("Restarting for next test\n");
|
||||||
this._deferred = PromiseUtils.defer();
|
this._deferred = Promise.withResolvers();
|
||||||
this._expectedEvents = maxLen;
|
this._expectedEvents = maxLen;
|
||||||
this.countReceived = 0;
|
this.countReceived = 0;
|
||||||
this._results = [];
|
this._results = [];
|
||||||
|
@ -605,7 +605,7 @@ var gMessages = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const gCopyWaiter = PromiseUtils.defer();
|
const gCopyWaiter = Promise.withResolvers();
|
||||||
|
|
||||||
add_task(async function copy_messages() {
|
add_task(async function copy_messages() {
|
||||||
for (const msg of gMessages) {
|
for (const msg of gMessages) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ var smimeDataDirectory = "../../../data/smime/";
|
||||||
const smimeHeaderSink = {
|
const smimeHeaderSink = {
|
||||||
expectResults(maxLen) {
|
expectResults(maxLen) {
|
||||||
// dump("Restarting for next test\n");
|
// dump("Restarting for next test\n");
|
||||||
this._deferred = PromiseUtils.defer();
|
this._deferred = Promise.withResolvers();
|
||||||
this._expectedEvents = maxLen;
|
this._expectedEvents = maxLen;
|
||||||
this.countReceived = 0;
|
this.countReceived = 0;
|
||||||
this._results = [];
|
this._results = [];
|
||||||
|
@ -621,7 +621,7 @@ var gMessages = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const gCopyWaiter = PromiseUtils.defer();
|
const gCopyWaiter = Promise.withResolvers();
|
||||||
|
|
||||||
add_task(async function copy_messages() {
|
add_task(async function copy_messages() {
|
||||||
for (const msg of gMessages) {
|
for (const msg of gMessages) {
|
||||||
|
|
|
@ -88,7 +88,7 @@ var smimeDataDirectory = "../../../data/smime/";
|
||||||
const smimeHeaderSink = {
|
const smimeHeaderSink = {
|
||||||
expectResults(maxLen) {
|
expectResults(maxLen) {
|
||||||
// dump("Restarting for next test\n");
|
// dump("Restarting for next test\n");
|
||||||
this._deferred = PromiseUtils.defer();
|
this._deferred = Promise.withResolvers();
|
||||||
this._expectedEvents = maxLen;
|
this._expectedEvents = maxLen;
|
||||||
this.countReceived = 0;
|
this.countReceived = 0;
|
||||||
this._results = [];
|
this._results = [];
|
||||||
|
|
|
@ -167,7 +167,7 @@ add_task(async function test_search() {
|
||||||
add_task(async function test_grouplist() {
|
add_task(async function test_grouplist() {
|
||||||
// This tests nsNntpService::GetListOfGroupsOnServer.
|
// This tests nsNntpService::GetListOfGroupsOnServer.
|
||||||
const subserver = localserver.QueryInterface(Ci.nsISubscribableServer);
|
const subserver = localserver.QueryInterface(Ci.nsISubscribableServer);
|
||||||
const subscribablePromise = PromiseUtils.defer();
|
const subscribablePromise = Promise.withResolvers();
|
||||||
const subscribeListener = {
|
const subscribeListener = {
|
||||||
OnDonePopulating() {
|
OnDonePopulating() {
|
||||||
subscribablePromise.resolve();
|
subscribablePromise.resolve();
|
||||||
|
@ -271,7 +271,7 @@ class DummyMsgWindow {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._deferredPromise = PromiseUtils.defer();
|
this._deferredPromise = Promise.withResolvers();
|
||||||
}
|
}
|
||||||
|
|
||||||
get statusFeedback() {
|
get statusFeedback() {
|
||||||
|
@ -290,7 +290,7 @@ class DummyMsgWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
deferPromise() {
|
deferPromise() {
|
||||||
this._deferredPromise = PromiseUtils.defer();
|
this._deferredPromise = Promise.withResolvers();
|
||||||
}
|
}
|
||||||
|
|
||||||
get promise() {
|
get promise() {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче