Bug 1695820 remove AddonTestUtils.awaitPromise event loop spinner r=robwu

Differential Revision: https://phabricator.services.mozilla.com/D106865
This commit is contained in:
Shane Caraveo 2021-03-02 15:00:05 +00:00
Родитель 8a63815f27
Коммит f4ebf61baf
18 изменённых файлов: 56 добавлений и 58 удалений

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

@ -27,7 +27,10 @@ AddonTestUtils.createAppInfo(
"1",
"1.9.2"
);
AddonTestUtils.awaitPromise(AddonTestUtils.promiseStartupManager());
add_task(async function setup() {
await AddonTestUtils.promiseStartupManager();
});
function createAndStartHTTPServer(port = HTTP_PORT) {
try {

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

@ -21,7 +21,6 @@ AddonTestUtils.createAppInfo(
"1.9.2"
);
AddonTestUtils.overrideCertDB();
AddonTestUtils.awaitPromise(AddonTestUtils.promiseStartupManager());
const ADDON_ID = "addon1@tests.mozilla.org";
const XPI = AddonTestUtils.createTempWebExtensionFile({
@ -39,6 +38,7 @@ function makeAddonsReconciler() {
}
add_task(async function setup() {
await AddonTestUtils.promiseStartupManager();
Svc.Prefs.set("engine.addons", true);
await Service.engineManager.register(AddonsEngine);
});

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

@ -21,7 +21,6 @@ Services.prefs.setCharPref("extensions.minCompatibleAppVersion", "0");
Services.prefs.setCharPref("extensions.minCompatiblePlatformVersion", "0");
Services.prefs.setBoolPref("extensions.experiments.enabled", true);
AddonTestUtils.awaitPromise(AddonTestUtils.promiseStartupManager());
Svc.Prefs.set("engine.addons", true);
let engine;
@ -40,9 +39,6 @@ const ADDONS = {
};
const XPIS = {};
for (let [name, data] of Object.entries(ADDONS)) {
XPIS[name] = AddonTestUtils.createTempWebExtensionFile(data);
}
async function cleanup() {
tracker.stop();
@ -56,6 +52,10 @@ async function cleanup() {
}
add_task(async function setup() {
await AddonTestUtils.promiseStartupManager();
for (let [name, data] of Object.entries(ADDONS)) {
XPIS[name] = AddonTestUtils.createTempWebExtensionFile(data);
}
await Service.engineManager.register(AddonsEngine);
engine = Service.engineManager.get("addons");
reconciler = engine._reconciler;

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

@ -292,7 +292,7 @@ function wrapWithExceptionHandler(f) {
return wrapper;
}
function loadAddonManager(...args) {
async function loadAddonManager(...args) {
AddonTestUtils.init(gGlobalScope);
AddonTestUtils.overrideCertDB();
createAppInfo(...args);
@ -301,11 +301,9 @@ function loadAddonManager(...args) {
// used by system add-ons.
const distroDir = FileUtils.getDir("ProfD", ["sysfeatures", "app0"], true);
AddonTestUtils.registerDirectory("XREAppFeat", distroDir);
AddonTestUtils.awaitPromise(
AddonTestUtils.overrideBuiltIns({
system: ["tel-system-xpi@tests.mozilla.org"],
})
);
await AddonTestUtils.overrideBuiltIns({
system: ["tel-system-xpi@tests.mozilla.org"],
});
return AddonTestUtils.promiseStartupManager();
}

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

@ -89,7 +89,7 @@ add_task(async function() {
// Setup.
do_get_profile(true);
loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
await loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
finishAddonManagerStartup();
fakeIntlReady();
await TelemetryController.testSetup();

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

@ -174,7 +174,7 @@ add_task(async function() {
// Setup.
do_get_profile(true);
loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
await loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
finishAddonManagerStartup();
fakeIntlReady();
await TelemetryController.testSetup();

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

@ -205,7 +205,7 @@ add_task(async function() {
// Setup.
do_get_profile(true);
loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
await loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
finishAddonManagerStartup();
fakeIntlReady();
await TelemetryController.testSetup();

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

@ -141,7 +141,12 @@ add_task(async function test_setup() {
// Addon manager needs a profile directory
do_get_profile();
loadAddonManager("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
await loadAddonManager(
"xpcshell@tests.mozilla.org",
"XPCShell",
"1",
"1.9.2"
);
finishAddonManagerStartup();
fakeIntlReady();
// Make sure we don't generate unexpected pings due to pref changes.

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

@ -46,7 +46,7 @@ add_task(async function test_setup() {
// Setup.
do_get_profile(true);
loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
await loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
finishAddonManagerStartup();
fakeIntlReady();
await TelemetryController.testSetup();

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

@ -145,7 +145,12 @@ function checkPingFormat(aPing, aType, aHasClientId, aHasEnvironment) {
add_task(async function test_setup() {
// Addon manager needs a profile directory
do_get_profile();
loadAddonManager("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
await loadAddonManager(
"xpcshell@tests.mozilla.org",
"XPCShell",
"1",
"1.9.2"
);
finishAddonManagerStartup();
fakeIntlReady();
// Make sure we don't generate unexpected pings due to pref changes.

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

@ -32,7 +32,12 @@ function contentHandler(metadata, response) {
add_task(async function test_setup() {
// Addon manager needs a profile directory
do_get_profile();
loadAddonManager("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
await loadAddonManager(
"xpcshell@tests.mozilla.org",
"XPCShell",
"1",
"1.9.2"
);
finishAddonManagerStartup();
fakeIntlReady();
// Make sure we don't generate unexpected pings due to pref changes.

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

@ -1084,7 +1084,7 @@ add_task(async function setup() {
let system_addon = FileUtils.File(distroDir.path);
system_addon.append("tel-system-xpi@tests.mozilla.org.xpi");
system_addon.lastModifiedTime = SYSTEM_ADDON_INSTALL_DATE;
loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
await loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
// The test runs in a fresh profile so starting the AddonManager causes
// the addons database to be created (as does setting new theme).

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

@ -59,7 +59,12 @@ function setMinimumPolicyVersion(aNewPolicyVersion) {
add_task(async function test_setup() {
// Addon manager needs a profile directory
do_get_profile(true);
loadAddonManager("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
await loadAddonManager(
"xpcshell@tests.mozilla.org",
"XPCShell",
"1",
"1.9.2"
);
finishAddonManagerStartup();
fakeIntlReady();

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

@ -119,7 +119,12 @@ add_task(async function test_setup() {
do_get_profile(true);
// Addon manager needs a profile directory.
loadAddonManager("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
await loadAddonManager(
"xpcshell@tests.mozilla.org",
"XPCShell",
"1",
"1.9.2"
);
finishAddonManagerStartup();
fakeIntlReady();

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

@ -142,7 +142,12 @@ add_task(async function test_setup() {
PingServer.start();
PingServer.registerPingHandler(pingHandler);
do_get_profile();
loadAddonManager("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
await loadAddonManager(
"xpcshell@tests.mozilla.org",
"XPCShell",
"1",
"1.9.2"
);
finishAddonManagerStartup();
fakeIntlReady();
// Make sure we don't generate unexpected pings due to pref changes.

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

@ -528,7 +528,7 @@ function write_fake_failedprofilelocks_file() {
add_task(async function test_setup() {
// Addon manager needs a profile directory
do_get_profile();
loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
await loadAddonManager(APP_ID, APP_NAME, APP_VERSION, PLATFORM_VERSION);
finishAddonManagerStartup();
fakeIntlReady();
// Make sure we don't generate unexpected pings due to pref changes.

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

@ -25,7 +25,7 @@ function getSimpleMeasurementsFromTelemetryController() {
add_task(async function test_setup() {
// Telemetry needs the AddonManager.
loadAddonManager();
await loadAddonManager();
finishAddonManagerStartup();
fakeIntlReady();
// Make profile available for |TelemetryController.testShutdown()|.

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

@ -620,39 +620,6 @@ var AddonTestUtils = {
}
},
/**
* Helper to spin the event loop until a promise resolves or rejects
*
* @param {Promise} promise
* The promise to wait on.
* @returns {*} The promise's resolution value.
* @throws The promise's rejection value, if it rejects.
*/
awaitPromise(promise) {
let done = false;
let result;
let error;
promise
.then(
val => {
result = val;
},
err => {
error = err;
}
)
.then(() => {
done = true;
});
Services.tm.spinEventLoopUntil(() => done);
if (error !== undefined) {
throw error;
}
return result;
},
createAppInfo(ID, name, version, platformVersion = "1.0") {
AppInfo.updateAppInfo({
ID,