mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 08:45:46 +00:00
Bug 1579420 - Fix ESLint no-async-promise-executor issues in extensions code. r=rpl
Differential Revision: https://phabricator.services.mozilla.com/D45009 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
1fee916641
commit
e075d5cd6e
@ -358,11 +358,9 @@ class ExtensionControlledPopup {
|
||||
description.appendChild(link);
|
||||
}
|
||||
|
||||
_ensureWindowReady(win) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
async _ensureWindowReady(win) {
|
||||
if (win.closed) {
|
||||
reject();
|
||||
return;
|
||||
throw new Error("window is closed");
|
||||
}
|
||||
let promises = [];
|
||||
let listenersToRemove = [];
|
||||
@ -392,6 +390,8 @@ class ExtensionControlledPopup {
|
||||
promiseEvent("focus");
|
||||
}
|
||||
let unloadListener;
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (promises.length) {
|
||||
unloadListener = () => {
|
||||
for (let [type, listener] of listenersToRemove) {
|
||||
@ -401,11 +401,20 @@ class ExtensionControlledPopup {
|
||||
};
|
||||
win.addEventListener("unload", unloadListener, { once: true });
|
||||
}
|
||||
let error;
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
} catch (ex) {
|
||||
error = ex;
|
||||
}
|
||||
if (unloadListener) {
|
||||
win.removeEventListener("unload", unloadListener);
|
||||
}
|
||||
if (error) {
|
||||
reject(new Error("window unloaded"));
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -115,9 +115,9 @@ let extData = {
|
||||
},
|
||||
};
|
||||
|
||||
function waitForRequestAdded(toolbox) {
|
||||
return new Promise(async resolve => {
|
||||
async function waitForRequestAdded(toolbox) {
|
||||
let netPanel = await toolbox.getNetMonitorAPI();
|
||||
return new Promise(resolve => {
|
||||
netPanel.once("NetMonitor:RequestAdded", () => {
|
||||
resolve();
|
||||
});
|
||||
|
@ -60,6 +60,7 @@ add_task(async function test_zoom_api() {
|
||||
let awaitZoom = async (tabId, newValue) => {
|
||||
let listener;
|
||||
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
await new Promise(async resolve => {
|
||||
listener = info => {
|
||||
if (info.tabId == tabId && info.newZoomFactor == newValue) {
|
||||
|
@ -168,7 +168,7 @@ class ExtensionShortcuts {
|
||||
// Map[{String} commandName -> {Object} commandProperties]
|
||||
this.manifestCommands = this.loadCommandsFromManifest(extension.manifest);
|
||||
|
||||
this.commands = new Promise(async resolve => {
|
||||
this.commands = (async () => {
|
||||
// Deep copy the manifest commands to commands so we can keep the original
|
||||
// manifest commands and update commands as needed.
|
||||
let commands = new Map();
|
||||
@ -187,8 +187,8 @@ class ExtensionShortcuts {
|
||||
}
|
||||
});
|
||||
|
||||
resolve(commands);
|
||||
});
|
||||
return commands;
|
||||
})();
|
||||
}
|
||||
|
||||
registerKeys(commands) {
|
||||
|
@ -155,7 +155,7 @@ class MockExtension {
|
||||
});
|
||||
}
|
||||
|
||||
startup() {
|
||||
async startup() {
|
||||
if (this.installType == "temporary") {
|
||||
return AddonManager.installTemporaryAddon(this.file).then(async addon => {
|
||||
this.addon = addon;
|
||||
@ -167,8 +167,8 @@ class MockExtension {
|
||||
this.addonPromise = new Promise(resolve => {
|
||||
this.resolveAddon = resolve;
|
||||
});
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let install = await AddonManager.getInstallForFile(this.file);
|
||||
return new Promise((resolve, reject) => {
|
||||
let listener = {
|
||||
onInstallFailed: reject,
|
||||
onInstallEnded: async (install, newAddon) => {
|
||||
|
@ -41,6 +41,7 @@ add_task(async function test_get_current() {
|
||||
|
||||
function ensureWindowFocused(winId) {
|
||||
browser.test.log("Waiting for focused window to be " + winId);
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async resolve => {
|
||||
let listener = windowId => {
|
||||
if (windowId === winId) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
// This test checks that theme warnings are properly emitted.
|
||||
|
||||
function waitForConsole(task, message) {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async resolve => {
|
||||
SimpleTest.monitorConsole(resolve, [
|
||||
{
|
||||
|
@ -238,7 +238,7 @@ add_task(async function test_blocklisted_plugin_disabled() {
|
||||
});
|
||||
|
||||
// Causes appDisabled to be set.
|
||||
await new Promise(async resolve => {
|
||||
await new Promise(resolve => {
|
||||
// Ensure to reset the blocklist if this test exits earlier because
|
||||
// of a failure.
|
||||
registerCleanupFunction(ensurePluginEnabled);
|
||||
|
@ -553,9 +553,9 @@ function promiseAddonsByIDs(aIDs) {
|
||||
*
|
||||
* The callback will receive the Addon for the installed add-on.
|
||||
*/
|
||||
function install_addon(path, cb, pathPrefix = TESTROOT) {
|
||||
let p = new Promise(async (resolve, reject) => {
|
||||
async function install_addon(path, cb, pathPrefix = TESTROOT) {
|
||||
let install = await AddonManager.getInstallForURL(pathPrefix + path);
|
||||
let p = new Promise((resolve, reject) => {
|
||||
install.addListener({
|
||||
onInstallEnded: () => resolve(install.addon),
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user