mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
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:
parent
e075d5cd6e
commit
9569721e58
19
.eslintrc.js
19
.eslintrc.js
@ -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",
|
||||
|
@ -467,35 +467,35 @@ function execute_test_in_sidebar(test) {
|
||||
});
|
||||
}
|
||||
|
||||
function open_properties_dialog(test) {
|
||||
return new Promise(async resolve => {
|
||||
var sidebar = document.getElementById("sidebar");
|
||||
async function open_properties_dialog(test) {
|
||||
var sidebar = document.getElementById("sidebar");
|
||||
|
||||
// If this is history sidebar, set the required view.
|
||||
if (test.sidebar == SIDEBAR_HISTORY_ID) {
|
||||
sidebar.contentDocument.getElementById(test.historyView).doCommand();
|
||||
}
|
||||
// If this is history sidebar, set the required view.
|
||||
if (test.sidebar == SIDEBAR_HISTORY_ID) {
|
||||
sidebar.contentDocument.getElementById(test.historyView).doCommand();
|
||||
}
|
||||
|
||||
// Get sidebar's Places tree.
|
||||
var sidebarTreeID =
|
||||
test.sidebar == SIDEBAR_BOOKMARKS_ID
|
||||
? SIDEBAR_BOOKMARKS_TREE_ID
|
||||
: SIDEBAR_HISTORY_TREE_ID;
|
||||
var tree = sidebar.contentDocument.getElementById(sidebarTreeID);
|
||||
// The sidebar may take a moment to open from the doCommand, therefore wait
|
||||
// until it has opened before continuing.
|
||||
await BrowserTestUtils.waitForCondition(
|
||||
() => tree,
|
||||
"Sidebar tree has been loaded"
|
||||
);
|
||||
// Get sidebar's Places tree.
|
||||
var sidebarTreeID =
|
||||
test.sidebar == SIDEBAR_BOOKMARKS_ID
|
||||
? SIDEBAR_BOOKMARKS_TREE_ID
|
||||
: SIDEBAR_HISTORY_TREE_ID;
|
||||
var tree = sidebar.contentDocument.getElementById(sidebarTreeID);
|
||||
// The sidebar may take a moment to open from the doCommand, therefore wait
|
||||
// until it has opened before continuing.
|
||||
await BrowserTestUtils.waitForCondition(
|
||||
() => tree,
|
||||
"Sidebar tree has been loaded"
|
||||
);
|
||||
|
||||
// Ask current test to select the node to edit.
|
||||
test.selectNode(tree);
|
||||
Assert.ok(
|
||||
tree.selectedNode,
|
||||
"We have a places node selected: " + tree.selectedNode.title
|
||||
);
|
||||
// Ask current test to select the node to edit.
|
||||
test.selectNode(tree);
|
||||
Assert.ok(
|
||||
tree.selectedNode,
|
||||
"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.
|
||||
tree.controller.doCommand(command);
|
||||
// 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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -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}`);
|
||||
}
|
||||
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,
|
||||
|
@ -762,14 +762,12 @@ FormAutofillParent.prototype = {
|
||||
!!pendingDoorhanger && typeof pendingDoorhanger == "function"
|
||||
);
|
||||
})
|
||||
.map(
|
||||
pendingDoorhangers =>
|
||||
new Promise(async resolve => {
|
||||
for (const showDoorhanger of pendingDoorhangers) {
|
||||
await showDoorhanger();
|
||||
}
|
||||
resolve();
|
||||
})
|
||||
.map(pendingDoorhangers =>
|
||||
(async () => {
|
||||
for (const showDoorhanger of pendingDoorhangers) {
|
||||
await showDoorhanger();
|
||||
}
|
||||
})()
|
||||
)
|
||||
);
|
||||
},
|
||||
|
@ -33,16 +33,14 @@ 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(
|
||||
"resource://mozscreenshots/TestRunner.jsm",
|
||||
{}
|
||||
).TestRunner;
|
||||
TestRunner.initTest(this);
|
||||
resolve();
|
||||
});
|
||||
|
||||
let aAddon = await AddonManager.getAddonByID("mozscreenshots@mozilla.org");
|
||||
isnot(aAddon, null, "The mozscreenshots extension should be installed");
|
||||
TestRunner = ChromeUtils.import(
|
||||
"resource://mozscreenshots/TestRunner.jsm",
|
||||
{}
|
||||
).TestRunner;
|
||||
TestRunner.initTest(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
@ -20,22 +20,20 @@ function loginList() {
|
||||
];
|
||||
}
|
||||
|
||||
function openPopup(popup, browser) {
|
||||
return new Promise(async resolve => {
|
||||
let promiseShown = BrowserTestUtils.waitForEvent(popup, "popupshown");
|
||||
async function openPopup(popup, browser) {
|
||||
let promiseShown = BrowserTestUtils.waitForEvent(popup, "popupshown");
|
||||
|
||||
await SimpleTest.promiseFocus(browser);
|
||||
info("content window focused");
|
||||
await SimpleTest.promiseFocus(browser);
|
||||
info("content window focused");
|
||||
|
||||
// Focus the username field to open the popup.
|
||||
await ContentTask.spawn(browser, null, function openAutocomplete() {
|
||||
content.document.getElementById("form-basic-username").focus();
|
||||
});
|
||||
|
||||
let shown = await promiseShown;
|
||||
ok(shown, "autocomplete popup shown");
|
||||
resolve(shown);
|
||||
// Focus the username field to open the popup.
|
||||
await ContentTask.spawn(browser, null, function openAutocomplete() {
|
||||
content.document.getElementById("form-basic-username").focus();
|
||||
});
|
||||
|
||||
let shown = await promiseShown;
|
||||
ok(shown, "autocomplete popup shown");
|
||||
return shown;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
});
|
||||
},
|
||||
|
@ -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);
|
||||
},
|
||||
|
@ -254,14 +254,14 @@ add_task(async function e10sLostKeys() {
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
function promiseFindFinished(searchText, highlightOn) {
|
||||
return new Promise(async resolve => {
|
||||
let findbar = await gBrowser.getFindBar();
|
||||
findbar.startFind(findbar.FIND_NORMAL);
|
||||
let highlightElement = findbar.getElement("highlight");
|
||||
if (highlightElement.checked != highlightOn) {
|
||||
highlightElement.click();
|
||||
}
|
||||
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;
|
||||
|
||||
|
@ -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") {
|
||||
|
Loading…
Reference in New Issue
Block a user