Bug 1579420 - Fix remaining ESLint no-async-promise-executor issues in browser/ and toolkit/. r=mossop

Differential Revision: https://phabricator.services.mozilla.com/D45010

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Banner 2019-09-16 17:26:58 +00:00
parent e075d5cd6e
commit 9569721e58
11 changed files with 79 additions and 101 deletions

View File

@ -294,13 +294,6 @@ module.exports = {
}
}, {
"files": [
"browser/components/extensions/ExtensionControlledPopup.jsm",
"browser/components/extensions/test/browser/browser_ext_devtools_network.js",
"browser/components/extensions/test/browser/browser_ext_tabs_zoom.js",
"browser/components/places/tests/browser/browser_bookmarksProperties.js",
"browser/components/preferences/in-content/tests/browser_extension_controlled.js",
"browser/extensions/formautofill/FormAutofillParent.jsm",
"browser/tools/mozscreenshots/head.js",
"devtools/client/aboutdebugging/test/browser/helper-addons.js",
"devtools/client/inspector/animation/animation.js",
"devtools/client/inspector/changes/ChangesView.js",
@ -320,18 +313,6 @@ module.exports = {
"dom/tests/browser/browser_persist_cookies.js",
"dom/tests/browser/browser_persist_mixed_content_image.js",
"netwerk/test/unit/test_http2-proxy.js",
"toolkit/components/contentprefs/ContentPrefService2.jsm",
"toolkit/components/extensions/ExtensionShortcuts.jsm",
"toolkit/components/extensions/ExtensionTestCommon.jsm",
"toolkit/components/extensions/test/browser/browser_ext_themes_dynamic_getCurrent.js",
"toolkit/components/extensions/test/browser/browser_ext_themes_warnings.js",
"toolkit/components/passwordmgr/test/browser/browser_autocomplete_footer.js",
"toolkit/components/remotebrowserutils/tests/browser/browser_httpResponseProcessSelection.js",
"toolkit/components/satchel/FormHistory.jsm",
"toolkit/content/tests/browser/browser_findbar.js",
"toolkit/modules/NewTabUtils.jsm",
"toolkit/mozapps/extensions/test/browser/browser_CTP_plugins.js",
"toolkit/mozapps/extensions/test/browser/head.js",
],
"rules": {
"no-async-promise-executor": "off",

View File

@ -467,8 +467,7 @@ function execute_test_in_sidebar(test) {
});
}
function open_properties_dialog(test) {
return new Promise(async resolve => {
async function open_properties_dialog(test) {
var sidebar = document.getElementById("sidebar");
// If this is history sidebar, set the required view.
@ -496,6 +495,7 @@ function open_properties_dialog(test) {
"We have a places node selected: " + tree.selectedNode.title
);
return new Promise(resolve => {
// Wait for the Properties dialog.
function windowObserver(observerWindow, aTopic, aData) {
if (aTopic != "domwindowopened") {
@ -548,7 +548,10 @@ function open_properties_dialog(test) {
" command '" + command + "' on current selected node is enabled"
);
// This will open the dialog.
// This will open the dialog. For some reason this needs to be executed
// later, as otherwise opening the dialog throws an exception.
executeSoon(() => {
tree.controller.doCommand(command);
});
});
}

View File

@ -35,13 +35,13 @@ function getSupportsFile(path) {
return fileurl.QueryInterface(Ci.nsIFileURL);
}
function installAddon(xpiName) {
async function installAddon(xpiName) {
let filePath = getSupportsFile(`addons/${xpiName}`).file;
return new Promise(async (resolve, reject) => {
let install = await AddonManager.getInstallForFile(filePath);
if (!install) {
throw new Error(`An install was not created for ${filePath}`);
}
return new Promise((resolve, reject) => {
install.addListener({
onDownloadFailed: reject,
onDownloadCancelled: reject,

View File

@ -762,14 +762,12 @@ FormAutofillParent.prototype = {
!!pendingDoorhanger && typeof pendingDoorhanger == "function"
);
})
.map(
pendingDoorhangers =>
new Promise(async resolve => {
.map(pendingDoorhangers =>
(async () => {
for (const showDoorhanger of pendingDoorhangers) {
await showDoorhanger();
}
resolve();
})
})()
)
);
},

View File

@ -33,7 +33,7 @@ async function setup() {
await AddonManager.installTemporaryAddon(dir);
info("Checking for mozscreenshots extension");
return new Promise(async resolve => {
let aAddon = await AddonManager.getAddonByID("mozscreenshots@mozilla.org");
isnot(aAddon, null, "The mozscreenshots extension should be installed");
TestRunner = ChromeUtils.import(
@ -41,8 +41,6 @@ async function setup() {
{}
).TestRunner;
TestRunner.initTest(this);
resolve();
});
}
/**

View File

@ -139,16 +139,16 @@ ContentPrefService2.prototype = {
return this._connPromise;
}
return (this._connPromise = new Promise(async (resolve, reject) => {
return (this._connPromise = (async () => {
let conn;
try {
conn = await this._getConnection();
} catch (e) {
this.log("Failed to establish database connection: " + e);
reject(e);
throw e;
}
resolve(conn);
}));
return conn;
})());
},
// nsIContentPrefService

View File

@ -20,8 +20,7 @@ function loginList() {
];
}
function openPopup(popup, browser) {
return new Promise(async resolve => {
async function openPopup(popup, browser) {
let promiseShown = BrowserTestUtils.waitForEvent(popup, "popupshown");
await SimpleTest.promiseFocus(browser);
@ -34,8 +33,7 @@ function openPopup(popup, browser) {
let shown = await promiseShown;
ok(shown, "autocomplete popup shown");
resolve(shown);
});
return shown;
}
/**

View File

@ -42,7 +42,7 @@ const EXTENSION_DATA = {
// sets the notificationCallbacks on the channel to a JS object that we
// can't do directly QueryObject on with expected results.
// This triggered a crash which was fixed in bug 1528188.
return new Promise(async (resolve, reject) => {
return new Promise((resolve, reject) => {
setTimeout(resolve, 0);
});
},

View File

@ -683,17 +683,16 @@ var DB = {
*/
get conn() {
delete this.conn;
let conn = new Promise(async (resolve, reject) => {
let conn = (async () => {
try {
this._instance = await this._establishConn();
} catch (e) {
log("Failed to establish database connection: " + e);
reject(e);
return;
throw e;
}
resolve(this._instance);
});
return this._instance;
})();
return (this.conn = conn);
},

View File

@ -254,14 +254,14 @@ add_task(async function e10sLostKeys() {
BrowserTestUtils.removeTab(tab);
});
function promiseFindFinished(searchText, highlightOn) {
return new Promise(async resolve => {
async function promiseFindFinished(searchText, highlightOn) {
let findbar = await gBrowser.getFindBar();
findbar.startFind(findbar.FIND_NORMAL);
let highlightElement = findbar.getElement("highlight");
if (highlightElement.checked != highlightOn) {
highlightElement.click();
}
return new Promise(resolve => {
executeSoon(() => {
findbar._findField.value = searchText;

View File

@ -966,6 +966,7 @@ var ActivityStreamProvider = {
return Promise.all(
aLinks.map(
link =>
// eslint-disable-next-line no-async-promise-executor
new Promise(async resolve => {
// Never add favicon data for pocket items
if (link.type === "pocket") {