Bug 1918630 - Port bug 1575506: Fix some of the new eslint failures. r=kaie

Subset of the patch, excluding
- mailnews/test/resources/MailTestUtils.sys.mjs
- mail/test/browser/shared-modules/EventUtils.sys.mjs

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

--HG--
extra : rebase_source : 69e22acc3233034f4337548726d37ff1fe56fcc9
This commit is contained in:
Martin Giger 2024-09-13 16:32:33 +00:00
Родитель 2f43b70b9d
Коммит 85ad8ae333
56 изменённых файлов: 236 добавлений и 223 удалений

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

@ -20,9 +20,9 @@ function removeOverrides(config) {
return config;
}
function readFile(path) {
function readFile(filePath) {
return fs
.readFileSync(path, { encoding: "utf-8" })
.readFileSync(filePath, { encoding: "utf-8" })
.split("\n")
.filter(p => p && !p.startsWith("#"))
.map(p => p.replace(/^comm\//, ""));
@ -122,11 +122,12 @@ module.exports = {
},
{
...removeOverrides(xpcshellTestConfig),
files: xpcshellTestPaths.map(path => `${path}**`),
files: xpcshellTestPaths.map(filePath => `${filePath}**`),
rules: {
...xpcshellTestConfig.rules,
"func-names": "off",
},
excludedFiles: ["**/*.mjs", "**/*.sjs"],
},
{
// If it is a test head file, we turn off global unused variable checks, as it
@ -134,8 +135,8 @@ module.exports = {
// This would be expensive and slow, and it isn't worth it for head files.
// We could get developers to declare as exported, but that doesn't seem worth it.
files: [
...browserTestPaths.map(path => `${path}head*.js`),
...xpcshellTestPaths.map(path => `${path}head*.js`),
...browserTestPaths.map(filePath => `${filePath}head*.js`),
...xpcshellTestPaths.map(filePath => `${filePath}head*.js`),
],
rules: {
"no-unused-vars": [
@ -149,11 +150,12 @@ module.exports = {
},
{
...browserTestConfig,
files: browserTestPaths.map(path => `${path}**`),
files: browserTestPaths.map(filePath => `${filePath}**`),
rules: {
...browserTestConfig.rules,
"func-names": "off",
},
excludedFiles: ["**/*.mjs", "**/*.sjs"],
},
{
files: [

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

@ -91,10 +91,10 @@ function checkAddresses(win, expectedFields) {
const expected = expectedFields[type];
const obtained = obtainedFields[type];
for (let i = 0; i < expected.length; i++) {
if (!obtained || !obtained.includes(expected[i])) {
for (let j = 0; j < expected.length; j++) {
if (!obtained || !obtained.includes(expected[j])) {
throw new Error(
expected[i] +
expected[j] +
" is not in " +
type +
" fields; " +

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

@ -75,10 +75,10 @@ async function subtest(path) {
);
}
if (range == range2) {
const text = pre.textContent;
const line = text.slice(
text.indexOf("line 7"),
text.lastIndexOf("line 7") + 6
const textContent = pre.textContent;
const line = textContent.slice(
textContent.indexOf("line 7"),
textContent.lastIndexOf("line 7") + 6
);
Assert.ok(
!line.includes("\n"),

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

@ -341,13 +341,13 @@ add_task(async function test_update_pill_before_send() {
// if the pill is updated we get an invalid recipient error. Otherwise the
// error would be an imap error because the email would still be sent to
// `recipient@fake.invalid`.
const dialogPromise = promise_modal_dialog("commonDialogWindow", cwc => {
const dialogTitle = cwc.document.getElementById("infoTitle").textContent;
const dialogPromise = promise_modal_dialog("commonDialogWindow", cdw => {
const dialogTitle = cdw.document.getElementById("infoTitle").textContent;
Assert.ok(
dialogTitle.includes("Invalid Recipient Address"),
"The pill edit has been updated before sending the email"
);
cwc.document.querySelector("dialog").getButton("accept").click();
cdw.document.querySelector("dialog").getButton("accept").click();
});
// Click the send button.
EventUtils.synthesizeMouseAtCenter(

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

@ -88,11 +88,11 @@ function addToFolder(aSubject, aBody, aFolder) {
return aFolder.msgDatabase.getMsgHdrForMessageID(msgId);
}
async function addMsgToFolder(folder) {
async function addMsgToFolder(targetFolder) {
const msgDbHdr = addToFolder(
"exposed test message " + gMsgNo,
msgBody,
folder
targetFolder
);
// select the newly created message

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

@ -82,11 +82,11 @@ function addToFolder(aSubject, aBody, aFolder) {
return aFolder.msgDatabase.getMsgHdrForMessageID(msgId);
}
async function addMsgToFolder(folder) {
async function addMsgToFolder(targetFolder) {
const msgDbHdr = addToFolder(
"exposed test message " + gMsgNo,
msgBody,
folder
targetFolder
);
// select the newly created message

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

@ -257,12 +257,12 @@ function addToFolder(aSubject, aBody, aFolder) {
return aFolder.msgDatabase.getMsgHdrForMessageID(msgId);
}
async function addMsgToFolderAndCheckContent(folder, test) {
async function addMsgToFolderAndCheckContent(targetFolder, test) {
info(`Checking msg in folder; test=${test.type}`);
const msgDbHdr = addToFolder(
test.type + " test message ",
msgBodyStart + test.body + msgBodyEnd,
folder
targetFolder
);
// select the newly created message

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

@ -268,12 +268,8 @@ async function check_display_name(index, columnName, expectedName) {
// Generate a test for each message in |messages|.
for (const [i, message] of messages.entries()) {
this["test_" + message.name] = async function (i, message) {
await check_display_name(
i,
message.expected.column,
message.expected.value
);
this["test_" + message.name] = async function (index, msg) {
await check_display_name(index, msg.expected.column, msg.expected.value);
}.bind(this, i, message);
add_task(this[`test_${message.name}`]);
}

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

@ -88,8 +88,8 @@ add_setup(async function () {
* @param read true if the messages should be marked read, false otherwise
*/
function check_read_status(messages, read) {
function read_str(read) {
return read ? "read" : "unread";
function read_str(isRead) {
return isRead ? "read" : "unread";
}
for (let i = 0; i < messages.length; i++) {

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

@ -291,14 +291,14 @@ add_task(async function test_summary_when_multiple_identities() {
// only one thread
const folder1 = await create_folder("Search1");
await be_in_folder(folder1);
let thread1 = create_thread(1);
await add_message_sets_to_folders([folder1], [thread1]);
let thread = create_thread(1);
await add_message_sets_to_folders([folder1], [thread]);
const folder2 = await create_folder("Search2");
await be_in_folder(folder2);
await make_message_sets_in_folders(
[folder2],
[{ count: 1, inReplyTo: thread1 }]
[{ count: 1, inReplyTo: thread }]
);
const folderVirtual = create_virtual_folder(
@ -343,8 +343,8 @@ add_task(async function test_summary_when_multiple_identities() {
// Second half of the test, makes sure MultiMessageSummary groups messages
// according to their view thread id
thread1 = create_thread(1);
await add_message_sets_to_folders([folder1], [thread1]);
thread = create_thread(1);
await add_message_sets_to_folders([folder1], [thread]);
await be_in_folder(folderVirtual);
await select_shift_click_row(1);

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

@ -26,10 +26,10 @@ add_task(async function testProfileExport() {
});
const tab = await new Promise(resolve => {
const tab = window.openTab("contentTab", {
const newTab = window.openTab("contentTab", {
url: "about:import#export",
onLoad() {
resolve(tab);
resolve(newTab);
},
});
});

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

@ -82,10 +82,10 @@ add_task(async function testProfileImport() {
});
const tab = await new Promise(resolve => {
const tab = window.openTab("contentTab", {
const newTab = window.openTab("contentTab", {
url: "about:import",
onLoad() {
resolve(tab);
resolve(newTab);
},
});
});
@ -253,10 +253,10 @@ add_task(async function testImportLargeZIP() {
});
const tab = await new Promise(resolve => {
const tab = window.openTab("contentTab", {
const newTab = window.openTab("contentTab", {
url: "about:import",
onLoad() {
resolve(tab);
resolve(newTab);
},
});
});

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

@ -21,10 +21,10 @@ async function waitForHash(targetHash, tabWindow) {
add_task(async function test_paneChange() {
const tab = await new Promise(resolve => {
const tab = window.openTab("contentTab", {
const newTab = window.openTab("contentTab", {
url: "about:import",
onLoad() {
resolve(tab);
resolve(newTab);
},
});
});
@ -71,10 +71,10 @@ add_task(async function test_paneChange() {
add_task(async function test_profileImportRestore() {
const tab = await new Promise(resolve => {
const tab = window.openTab("contentTab", {
const newTab = window.openTab("contentTab", {
url: "about:import#app",
onLoad() {
resolve(tab);
resolve(newTab);
},
});
});

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

@ -483,7 +483,7 @@ add_task(async function test_message_pane_width_persistence() {
add_task(async function test_multiple_3pane_periodic_session_persistence() {
// open a few more 3pane windows
for (var i = 0; i < 3; ++i) {
for (let i = 0; i < 3; ++i) {
await open3PaneWindow();
}

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

@ -1563,8 +1563,8 @@ export class FormatHelper {
assertMessageBodyContent(content, assertMessage) {
const cls = this.constructor;
function message(message, below, index) {
return `${message} (at index ${index} below ${below})`;
function message(messageText, below, index) {
return `${messageText} (at index ${index} below ${below})`;
}
function getDifference(node, expect, below, index) {

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

@ -8,6 +8,7 @@ import * as wh from "resource://testing-common/mail/WindowHelpers.sys.mjs";
import { Assert } from "resource://testing-common/Assert.sys.mjs";
import { TestUtils } from "resource://testing-common/TestUtils.sys.mjs";
import { EventUtils } from "resource://testing-common/EventUtils.sys.mjs";
var FAST_TIMEOUT = 1000;
var FAST_INTERVAL = 100;

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

@ -1143,7 +1143,7 @@ export function assert_folder_expanded(aFolder) {
export function select_click_folder(aFolder) {
const win = get_about_3pane();
const folderTree = win.document.getElementById("folderTree");
const row = folderTree.rows.find(row => row.uri == aFolder.URI);
const row = folderTree.rows.find(treeRow => treeRow.uri == aFolder.URI);
row.scrollIntoView();
EventUtils.synthesizeMouseAtCenter(row.querySelector(".container"), {}, win);
}
@ -1190,7 +1190,7 @@ export async function right_click_on_folder(aFolder) {
win.document.getElementById("folderPaneContext"),
"popupshown"
);
const row = folderTree.rows.find(row => row.uri == aFolder.URI);
const row = folderTree.rows.find(treeRow => treeRow.uri == aFolder.URI);
EventUtils.synthesizeMouseAtCenter(
row.querySelector(".container"),
{ type: "contextmenu" },
@ -1209,7 +1209,7 @@ export async function right_click_on_folder(aFolder) {
export function middle_click_on_folder(aFolder, shiftPressed) {
const win = get_about_3pane();
const folderTree = win.document.getElementById("folderTree");
const row = folderTree.rows.find(row => row.uri == aFolder.URI);
const row = folderTree.rows.find(treeRow => treeRow.uri == aFolder.URI);
EventUtils.synthesizeMouseAtCenter(
row.querySelector(".container"),
{ button: 1, shiftKey: shiftPressed },
@ -1466,13 +1466,13 @@ export async function wait_for_message_display_completion(aWin, aLoadDemanded) {
await TestUtils.waitForCondition(() => win.document.readyState == "complete");
const browser = win.getMessagePaneBrowser();
const messagePaneBrowser = win.getMessagePaneBrowser();
await TestUtils.waitForCondition(
() =>
!browser.docShell?.isLoadingDocument &&
(!aLoadDemanded || browser.currentURI?.spec != "about:blank"),
`Timeout waiting for a message. Current location: ${browser.currentURI?.spec}`
!messagePaneBrowser.docShell?.isLoadingDocument &&
(!aLoadDemanded || messagePaneBrowser.currentURI?.spec != "about:blank"),
`Timeout waiting for a message. Current location: ${messagePaneBrowser.currentURI?.spec}`
);
await TestUtils.waitForTick();
}
@ -1490,16 +1490,16 @@ export async function wait_for_blank_content_pane(win = mc) {
() => aboutMessage.document.readyState == "complete"
);
const browser = aboutMessage.getMessagePaneBrowser();
if (BrowserTestUtils.isHidden(browser)) {
const messagePaneBrowser = aboutMessage.getMessagePaneBrowser();
if (BrowserTestUtils.isHidden(messagePaneBrowser)) {
return;
}
await TestUtils.waitForCondition(
() =>
!browser.docShell?.isLoadingDocument &&
browser.currentURI?.spec == "about:blank",
`Timeout waiting for blank content pane. Current location: ${browser.currentURI?.spec}`
!messagePaneBrowser.docShell?.isLoadingDocument &&
messagePaneBrowser.currentURI?.spec == "about:blank",
`Timeout waiting for blank content pane. Current location: ${messagePaneBrowser.currentURI?.spec}`
);
// the above may return immediately, meaning the event queue might not get a

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

@ -48,8 +48,8 @@ export function setupNNTPDaemon() {
export function startupNNTPServer(daemon, port) {
var handler = NNTP_RFC977_handler;
function createHandler(daemon) {
return new handler(daemon);
function createHandler(createdDaemon) {
return new handler(createdDaemon);
}
var server = new nsMailServer(createHandler, daemon);

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

@ -247,12 +247,12 @@ export const OpenPGPTestUtils = {
/**
* Updates the acceptance value of the provided key(s) in the database.
*
* @param {string|string[]} id - The id or list of ids to update.
* @param {string|string[]} idOrList - The id or list of ids to update.
* @param {string} acceptance - The new acceptance level for the key id.
* @returns {string[]} - A list of the key ids processed.
*/
async updateKeyIdAcceptance(id, acceptance) {
const ids = Array.isArray(id) ? id : [id];
async updateKeyIdAcceptance(idOrList, acceptance) {
const ids = Array.isArray(idOrList) ? idOrList : [idOrList];
for (const id of ids) {
const key = lazy.EnigmailKeyRing.getKeyById(id);
const email = lazy.EnigmailFuncs.getEmailFromUserID(key.userId);
@ -270,11 +270,11 @@ export const OpenPGPTestUtils = {
* Removes a key by its id, clearing its acceptance and refreshing the
* cache.
*
* @param {string|string[]} id - The id or list of ids to remove.
* @param {string|string[]} idOrList - The id or list of ids to remove.
* @param {boolean} [deleteSecret=false] - If true, secret keys will be removed too.
*/
async removeKeyById(id, deleteSecret = false) {
const ids = Array.isArray(id) ? id : [id];
async removeKeyById(idOrList, deleteSecret = false) {
const ids = Array.isArray(idOrList) ? idOrList : [idOrList];
for (const id of ids) {
const key = lazy.EnigmailKeyRing.getKeyById(id);
await lazy.RNP.deleteKey(key.fpr, deleteSecret);

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

@ -33,13 +33,13 @@ export async function open_subscribe_window_from_context_menu(
const win = get_about_3pane();
await right_click_on_folder(aFolder);
const callback = async function (win) {
const callback = async function (dialogWindow) {
// When the "stop button" is disabled, the panel is populated.
await TestUtils.waitForCondition(
() => win.document.getElementById("stopButton").disabled
() => dialogWindow.document.getElementById("stopButton").disabled
);
await aFunction(win);
win.close();
await aFunction(dialogWindow);
dialogWindow.close();
};
const dialogPromise = promise_modal_dialog("mailnews:subscribe", callback);
await click_menus_in_sequence(

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

@ -327,15 +327,20 @@ export function close_popup_sequence(aCloseStack) {
async function _click_appmenu_in_sequence(navTargets, nonNavTarget, win) {
const rootPopup = win.document.getElementById("appMenu-popup");
async function viewShownListener(navTargets, nonNavTarget, allDone, event) {
async function viewShownListener(
shownNavTargets,
shownNonNavTarget,
allDone,
event
) {
// Set up the next listener if there are more navigation targets.
if (navTargets.length > 0) {
if (shownNavTargets.length > 0) {
rootPopup.addEventListener(
"ViewShown",
viewShownListener.bind(
null,
navTargets.slice(1),
nonNavTarget,
shownNavTargets.slice(1),
shownNonNavTarget,
allDone
),
{ once: true }
@ -345,7 +350,7 @@ async function _click_appmenu_in_sequence(navTargets, nonNavTarget, win) {
const subview = event.target.querySelector(".panel-subview-body");
// Click a target if there is a target left to click.
const clickTarget = navTargets[0] || nonNavTarget;
const clickTarget = shownNavTargets[0] || shownNonNavTarget;
if (clickTarget) {
const kids = Array.from(subview.children);
@ -373,7 +378,7 @@ async function _click_appmenu_in_sequence(navTargets, nonNavTarget, win) {
}
// We are all done when there are no more navigation targets.
if (navTargets.length == 0) {
if (shownNavTargets.length == 0) {
allDone(subview);
}
}

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

@ -118,10 +118,10 @@ function ensureInitialized() {
`${prefName}.filename`,
""
);
const uri = Services.prefs.getStringPref(`${prefName}.uri`, "");
switch (dirType) {
case Ci.nsIAbManager.MAPI_DIRECTORY_TYPE:
case Ci.nsIAbManager.MAPI_DIRECTORY_TYPE: {
const uri = Services.prefs.getStringPref(`${prefName}.uri`, "");
if (
Cu.isInAutomation ||
Services.env.exists("XPCSHELL_TEST_PROFILE_DIR")
@ -147,6 +147,7 @@ function ensureInitialized() {
}
}
break;
}
case Ci.nsIAbManager.JS_DIRECTORY_TYPE:
if (fileName) {
const uri = `jsaddrbook://${fileName}`;

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

@ -388,7 +388,7 @@ export class CardDAVDirectory extends SQLiteDirectory {
* conflict status code.
*/
async _sendCardToServer(card) {
const href = this._getCardHref(card);
const cardHref = this._getCardHref(card);
const requestDetails = {
method: "PUT",
contentType: "text/vcard",
@ -408,8 +408,8 @@ export class CardDAVDirectory extends SQLiteDirectory {
let response;
try {
log.debug(`Sending ${href} to server.`);
response = await this._makeRequest(href, requestDetails);
log.debug(`Sending ${cardHref} to server.`);
response = await this._makeRequest(cardHref, requestDetails);
} catch (ex) {
Services.obs.notifyObservers(this, "addrbook-directory-sync-failed");
this._uidsToSync.add(card.UID);
@ -428,7 +428,7 @@ export class CardDAVDirectory extends SQLiteDirectory {
// telling us where it went (c'mon, really?). Fortunately a multiget
// request at the original location works.
response = await this._multigetRequest([href]);
response = await this._multigetRequest([cardHref]);
for (const { href, properties } of this._readResponse(response.dom)) {
if (!properties) {
@ -436,11 +436,11 @@ export class CardDAVDirectory extends SQLiteDirectory {
}
const etag = properties.querySelector("getetag")?.textContent;
const vCard = normalizeLineEndings(
const responseCard = normalizeLineEndings(
properties.querySelector("address-data")?.textContent
);
const abCard = lazy.VCardUtils.vCardToAbCard(vCard);
const abCard = lazy.VCardUtils.vCardToAbCard(responseCard);
abCard.setProperty("_etag", etag);
abCard.setProperty("_href", href);

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

@ -379,19 +379,19 @@ export var CardDAVUtils = {
let response;
const triedURLs = new Set();
async function tryURL(url) {
if (triedURLs.has(url)) {
async function tryURL(urlCandidate) {
if (triedURLs.has(urlCandidate)) {
return;
}
triedURLs.add(url);
triedURLs.add(urlCandidate);
log.log(`Attempting to connect to ${url}`);
response = await CardDAVUtils.makeRequest(url, requestParams);
log.log(`Attempting to connect to ${urlCandidate}`);
response = await CardDAVUtils.makeRequest(urlCandidate, requestParams);
if (response.status == 207 && response.dom) {
log.log(`${url} ... success`);
log.log(`${urlCandidate} ... success`);
} else {
log.log(
`${url} ... response was "${response.status} ${response.statusText}"`
`${urlCandidate} ... response was "${response.status} ${response.statusText}"`
);
response = null;
}

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

@ -342,20 +342,20 @@ export class SearchRequest extends LDAPMessage {
// An extensibleMatch filter is in the form of
// <type>:dn:<rule>:=<value>. We need to further parse the field.
const parts = field.split(":");
let value = [];
let matchValue = [];
if (parts.length == 3) {
// field is <type>:dn:<rule>.
if (parts[2]) {
value.push(
matchValue.push(
this._contextStringBlock(this.MATCHING_RULE, parts[2])
);
}
if (parts[0]) {
value.push(
matchValue.push(
this._contextStringBlock(this.MATCHING_TYPE, parts[0])
);
}
value.push(
matchValue.push(
this._contextStringBlock(this.MATCHING_VALUE, fieldValue)
);
if (parts[1] == "dn") {
@ -364,34 +364,34 @@ export class SearchRequest extends LDAPMessage {
});
dn.idBlock.tagClass = LDAPMessage.TAG_CLASS_CONTEXT;
dn.idBlock.tagNumber = this.MATCHING_DN;
value.push(dn);
matchValue.push(dn);
}
} else if (parts.length == 2) {
// field is <type>:<rule>.
if (parts[1]) {
value.push(
matchValue.push(
this._contextStringBlock(this.MATCHING_RULE, parts[1])
);
}
if (parts[0]) {
value.push(
matchValue.push(
this._contextStringBlock(this.MATCHING_TYPE, parts[0])
);
}
value.push(
matchValue.push(
this._contextStringBlock(this.MATCHING_VALUE, fieldValue)
);
} else {
// field is <type>.
value = [
matchValue = [
this._contextStringBlock(this.MATCHING_TYPE, field),
this._contextStringBlock(this.MATCHING_VALUE, fieldValue),
];
}
block = new asn1js.Constructed({
idBlock,
value,
value: matchValue,
});
} else if (tagNumber != this.FILTER_SUBSTRINGS) {
// A filter that is not substrings filter.

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

@ -461,7 +461,6 @@ AbAutoCompleteSearch.prototype = {
// (see bug 558931 for explanations).
// Use helper method to split up search query to multi-word search
// query against multiple fields.
const searchWords = getSearchTokens(fullString);
const searchQuery = generateQueryURI(result.modelQuery, searchWords);
// Now do the searching

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

@ -419,10 +419,10 @@ function checkDirectoryIsAllowed(aLocalPath) {
* - Linux = Linux
* @param {string} aDirToCheck.safeSubdirs - An array of directory names that
* are allowed to be used under the tested directory.
* @param {nsIFile} aLocalPath - An nsIFile of the directory to check,
* @param {nsIFile} localPath - An nsIFile of the directory to check,
* intended for message storage.
*/
function checkLocalDirectoryIsSafe(aDirToCheck, aLocalPath) {
function checkLocalDirectoryIsSafe(aDirToCheck, localPath) {
if (aDirToCheck.OS) {
if (!aDirToCheck.OS.split(",").includes(Services.appinfo.OS)) {
return true;
@ -458,11 +458,11 @@ function checkDirectoryIsAllowed(aLocalPath) {
testDir.normalize();
if (testDir.equals(aLocalPath) || aLocalPath.contains(testDir)) {
if (testDir.equals(localPath) || localPath.contains(testDir)) {
return false;
}
if (testDir.contains(aLocalPath)) {
if (testDir.contains(localPath)) {
if (!("safeSubdirs" in aDirToCheck)) {
return false;
}
@ -473,7 +473,7 @@ function checkDirectoryIsAllowed(aLocalPath) {
for (const subDir of aDirToCheck.safeSubdirs) {
const checkDir = testDir.clone();
checkDir.append(subDir);
if (checkDir.contains(aLocalPath)) {
if (checkDir.contains(localPath)) {
isInSubdir = true;
break;
}
@ -1853,8 +1853,10 @@ var gAccountTree = {
"/locale/am-" +
svc.name +
".properties";
const bundle = Services.strings.createBundle(bundleName);
const title = bundle.GetStringFromName("prefPanel-" + svc.name);
const panelBundle = Services.strings.createBundle(bundleName);
const title = panelBundle.GetStringFromName(
"prefPanel-" + svc.name
);
panelsToKeep.push({
string: title,
src: "am-" + svc.name + ".xhtml",

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

@ -106,12 +106,13 @@ function showInfo() {
}
function removeAccount() {
const removeAccount = document.getElementById("removeAccount").checked;
const removeAccountCheckbox =
document.getElementById("removeAccount").checked;
const removeData = document.getElementById("removeData").checked;
let account = window.arguments[0].account;
try {
// Remove the requested account data.
if (removeAccount) {
if (removeAccountCheckbox) {
try {
// Remove password information first.
account.incomingServer.forgetPassword();

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

@ -91,10 +91,10 @@ export class NewMailNotificationService {
let unreadCount = 0;
const allFolders = [folder, ...folder.descendants];
for (const folder of allFolders) {
if (this.confirmShouldCount(folder)) {
const count = folder.getNumUnread(false);
this.#log.debug(`${folder.URI} has ${count} unread`);
for (const candidateFolder of allFolders) {
if (this.confirmShouldCount(candidateFolder)) {
const count = candidateFolder.getNumUnread(false);
this.#log.debug(`${candidateFolder.URI} has ${count} unread`);
if (count > 0) {
unreadCount += count;
}
@ -186,10 +186,10 @@ export class NewMailNotificationService {
this.#log.debug(`${folder.URI} notified; will check subfolders`);
let newCount = 0;
for (const folder of allFolders) {
if (this.confirmShouldCount(folder)) {
const folderNew = folder.getNumNewMessages(false);
this.#log.debug(`${folder.URI}: ${folderNew} new`);
for (const candidateFolder of allFolders) {
if (this.confirmShouldCount(candidateFolder)) {
const folderNew = candidateFolder.getNumNewMessages(false);
this.#log.debug(`${candidateFolder.URI}: ${folderNew} new`);
if (folderNew > 0) {
newCount += folderNew;
}

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

@ -793,7 +793,7 @@ export class MsgIncomingServer {
relativeToKey: "ProfD",
});
return file;
} catch (e) {
} catch (exception) {
return null;
}
}

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

@ -36,7 +36,7 @@ export class MsgProtocolInfo {
relativeToKey: "ProfD",
});
return file;
} catch (e) {
} catch (exception) {
return null;
}
}

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

@ -211,14 +211,14 @@ OAuth2.prototype = {
this._parent.onAuthorizationReceived(url);
},
onStateChange(aWebProgress, aRequest, aStateFlags) {
onStateChange(webProgress, aRequest, aStateFlags) {
const wpl = Ci.nsIWebProgressListener;
if (aStateFlags & (wpl.STATE_START | wpl.STATE_IS_NETWORK)) {
const channel = aRequest.QueryInterface(Ci.nsIChannel);
this._checkForRedirect(channel.URI.spec);
}
},
onLocationChange(aWebProgress, aRequest, aLocation) {
onLocationChange(webProgress, aRequest, aLocation) {
this._checkForRedirect(aLocation.spec);
},
onProgressChange() {},

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

@ -106,7 +106,7 @@ export function convertMailStoreTo(
"Conversion complete. Converted dir installed as: " + finalRoot
);
resolve(finalRoot);
} catch (e) {
} catch (exception) {
bailout("installNewRoot() failed");
}
}

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

@ -483,18 +483,19 @@ export class MessageSend {
"@mozilla.org/messenger/progress;1"
].createInstance(Ci.nsIMsgProgress);
const params = Cc[
const composeParams = Cc[
"@mozilla.org/messengercompose/composeprogressparameters;1"
].createInstance(Ci.nsIMsgComposeProgressParams);
params.subject = this._parentWindow.gMsgCompose.compFields.subject;
params.deliveryMode = this._deliverMode;
composeParams.subject =
this._parentWindow.gMsgCompose.compFields.subject;
composeParams.deliveryMode = this._deliverMode;
progress.openProgressDialog(
this._parentWindow,
this._sendProgress.msgWindow,
"chrome://messenger/content/messengercompose/sendProgress.xhtml",
false,
params
composeParams
);
progress.onStateChange(
@ -983,8 +984,8 @@ export class MessageSend {
) {
// Typically, this appends "Sent-", "Drafts-" or "Templates-" to folder
// and then has the account name appended, e.g., .../Sent-MyImapAccount.
const folder = lazy.MailUtils.getOrCreateFolder(this._folderUri);
folderUri += folder.name + "-";
const localFolder = lazy.MailUtils.getOrCreateFolder(this._folderUri);
folderUri += localFolder.name + "-";
}
if (this._fcc) {
// Get the account name where the "save to" failed.

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

@ -2073,9 +2073,7 @@ export var Gloda = {
}
}
// anything still on oldValueMap was removed.
const valuesRemoved = Object.keys(oldValueMap).map(
key => oldValueMap[key]
);
const valuesRemoved = Object.values(oldValueMap);
// convert the values to database-style attribute rows
addDBAttribs.push.apply(
addDBAttribs,

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

@ -88,17 +88,17 @@ export function GlodaDatabind(aNounDef, aDatastore) {
coldef[3] = iColDef + 1;
}
const insertColumns = [];
const insertValues = [];
const updateItems = [];
const fulltextInsertColumns = [];
const fulltextInsertValues = [];
const fulltextUpdateItems = [];
for (var [iColDef, coldef] of this._tableDef.fulltextColumns.entries()) {
const column = coldef[0];
// +2 instead of +1 because docid is implied
const placeholder = "?" + (iColDef + 2);
insertColumns.push(column);
insertValues.push(placeholder);
fulltextInsertColumns.push(column);
fulltextInsertValues.push(placeholder);
if (column != "id") {
updateItems.push(column + " = " + placeholder);
fulltextUpdateItems.push(column + " = " + placeholder);
}
}
@ -106,9 +106,9 @@ export function GlodaDatabind(aNounDef, aDatastore) {
"INSERT INTO " +
this._tableName +
"Text (docid," +
insertColumns.join(", ") +
fulltextInsertColumns.join(", ") +
") VALUES (?1," +
insertValues.join(", ") +
fulltextInsertValues.join(", ") +
")";
// For the update, we want the 'id' to be a constraint and not a value
@ -117,7 +117,7 @@ export function GlodaDatabind(aNounDef, aDatastore) {
"UPDATE " +
this._tableName +
"Text SET " +
updateItems.join(", ") +
fulltextUpdateItems.join(", ") +
" WHERE docid = ?1";
this._insertFulltextStmt =

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

@ -1398,16 +1398,16 @@ export var GlodaDatastore = {
// - Create the fulltext table if applicable
if (aTableDef.fulltextColumns) {
const columnDefs = [];
const fulltextColumnDefs = [];
for (const [column, type] of aTableDef.fulltextColumns) {
columnDefs.push(column + " " + type);
fulltextColumnDefs.push(column + " " + type);
}
const createFulltextSQL =
"CREATE VIRTUAL TABLE " +
aTableName +
"Text" +
" USING fts3(tokenize mozporter, " +
columnDefs.join(", ") +
fulltextColumnDefs.join(", ") +
")";
this._log.info("Creating fulltext table: " + createFulltextSQL);
aDBConnection.executeSimpleSQL(createFulltextSQL);

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

@ -556,18 +556,18 @@ export var GlodaFundAttr = {
aGlodaMessage.attachmentTypes = Array.from(attachmentTypes);
}
const aMsgHdr = aRawReps.header;
const msgHdr = aRawReps.header;
const wasStreamed =
aMsgHdr &&
msgHdr &&
!aGlodaMessage.isEncrypted &&
(aMsgHdr.flags & Ci.nsMsgMessageFlags.Offline ||
aMsgHdr.folder instanceof Ci.nsIMsgLocalMailFolder);
(msgHdr.flags & Ci.nsMsgMessageFlags.Offline ||
msgHdr.folder instanceof Ci.nsIMsgLocalMailFolder);
// Clear the flag if it turns out there's no attachment after all and we
// streamed completely the message (if we didn't, then we have no
// knowledge of attachments, unless bug 673370 is fixed).
if (wasStreamed && !aMimeMsg.allAttachments.length) {
aMsgHdr.markHasAttachments(false);
msgHdr.markHasAttachments(false);
}
// This is not the same kind of attachments as above. Now, we want to

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

@ -2682,19 +2682,19 @@ export var GlodaMsgIndexer = {
folderDeleted(aFolder) {
this.indexer._log.debug("folderDeleted notification");
try {
const delFunc = function (aFolder, indexer) {
if (indexer._datastore._folderKnown(aFolder)) {
const delFunc = function (folder, indexer) {
if (indexer._datastore._folderKnown(folder)) {
indexer._log.info(
"Processing deletion of folder " + aFolder.prettyName + "."
"Processing deletion of folder " + folder.prettyName + "."
);
const glodaFolder = GlodaDatastore._mapFolder(aFolder);
const glodaFolder = GlodaDatastore._mapFolder(folder);
indexer._datastore.markMessagesDeletedByFolderID(glodaFolder.id);
indexer._datastore.deleteFolderByID(glodaFolder.id);
GlodaDatastore._killGlodaFolderIntoTombstone(glodaFolder);
} else {
indexer._log.info(
"Ignoring deletion of folder " +
aFolder.prettyName +
folder.prettyName +
" because it is unknown to gloda."
);
}

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

@ -215,12 +215,12 @@ export function MsgHdrToMimeMessage(
// Gloda), unless the client asked for encrypted data, we pass to the client
// callback a stripped-down version of the MIME structure where encrypted
// parts have been removed.
const wrapCallback = function (aCallback, aCallbackThis) {
const wrapCallback = function (callback, callbackThis) {
if (aOptions && aOptions.examineEncryptedParts) {
return aCallback;
return callback;
}
return (aMsgHdr, aMimeMsg) =>
aCallback.call(aCallbackThis, aMsgHdr, stripEncryptedParts(aMimeMsg));
return (msgHdr, aMimeMsg) =>
callback.call(callbackThis, msgHdr, stripEncryptedParts(aMimeMsg));
};
// Apparently there used to be an old syntax where the callback was the second

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

@ -17,6 +17,7 @@ var log = console.createInstance({
});
var _defaultExpectationExtractors = {};
/* eslint-disable func-names */
_defaultExpectationExtractors[GlodaConstants.NOUN_MESSAGE] = [
function expectExtract_message_gloda(aGlodaMessage) {
return aGlodaMessage.headerMessageID;
@ -41,6 +42,7 @@ _defaultExpectationExtractors[GlodaConstants.NOUN_IDENTITY] = [
return aAddress;
},
];
/* eslint-enable func-names */
function expectExtract_default_toString(aThing) {
return aThing.toString();

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

@ -455,22 +455,22 @@ FeedParser.prototype = {
// a relative URN.
let itemURI = itemNode.getAttribute("about") || "";
itemURI = this.removeUnprintableASCII(itemURI.trim());
const linkNode = this.childByTagNameNS(
const itemLinkNode = this.childByTagNameNS(
itemNode,
lazy.FeedUtils.RSS_NS,
"link"
);
item.id = this.getNodeValue(linkNode) || itemURI;
item.id = this.getNodeValue(itemLinkNode) || itemURI;
item.url = this.validLink(item.id);
const descNode = this.childByTagNameNS(
const itemDescNode = this.childByTagNameNS(
itemNode,
lazy.FeedUtils.RSS_NS,
"description"
);
item.description = this.getNodeValueFormatted(descNode);
item.description = this.getNodeValueFormatted(itemDescNode);
const titleNode = this.childByTagNameNS(
const itemTitleNode = this.childByTagNameNS(
itemNode,
lazy.FeedUtils.RSS_NS,
"title"
@ -482,7 +482,7 @@ FeedParser.prototype = {
);
item.title =
this.getNodeValue(titleNode) || this.getNodeValue(subjectNode);
this.getNodeValue(itemTitleNode) || this.getNodeValue(subjectNode);
if (!item.title && item.description) {
item.title = this.stripTags(item.description).substr(0, 150);
}

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

@ -944,16 +944,16 @@ export var FeedUtils = {
/**
* Try getting favicon from url.
* @param {string} url - The favicon url.
* @param {string} faviconUrl - The favicon url.
* @returns {Blob} - Existing favicon.
*/
const fetchFavicon = async url => {
const response = await fetch(url);
const fetchFavicon = async faviconUrl => {
const response = await fetch(faviconUrl);
if (!response.ok) {
throw new Error(`No favicon for url ${url}`);
throw new Error(`No favicon for url ${faviconUrl}`);
}
if (!/^image\//i.test(response.headers.get("Content-Type"))) {
throw new Error(`Non-image favicon for ${url}`);
throw new Error(`Non-image favicon for ${faviconUrl}`);
}
return response.blob();
};
@ -1363,27 +1363,32 @@ export var FeedUtils = {
*/
Mixins: {
meld(source, keep, replace) {
function meldin(source, target, keep, replace) {
for (const attribute in source) {
function meldin(meldSource, target, meldKeep, meldReplace) {
for (const attribute in meldSource) {
// Recurse for objects.
if (
typeof source[attribute] == "object" &&
typeof meldSource[attribute] == "object" &&
typeof target[attribute] == "object"
) {
meldin(source[attribute], target[attribute], keep, replace);
meldin(
meldSource[attribute],
target[attribute],
meldKeep,
meldReplace
);
} else {
// Use attribute values from source for the target, unless
// replace is false.
if (attribute in target && !replace) {
if (attribute in target && !meldReplace) {
continue;
}
// Don't copy attribute from source to target if it is not in the
// target, unless keep is true.
if (!(attribute in target) && !keep) {
if (!(attribute in target) && !meldKeep) {
continue;
}
target[attribute] = source[attribute];
target[attribute] = meldSource[attribute];
}
}
}

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

@ -1199,8 +1199,8 @@ var FeedSubscriptions = {
// We need to find the index of the new parent folder.
let newParentIndex = this.mView.kRowIndexUndefined;
for (let index = 0; index < this.mView.rowCount; index++) {
const item = this.mView.getItemAtIndex(index);
if (item && item.container && item.url == editFolderURI) {
const viewItem = this.mView.getItemAtIndex(index);
if (viewItem && viewItem.container && viewItem.url == editFolderURI) {
newParentIndex = index;
break;
}
@ -1482,8 +1482,8 @@ var FeedSubscriptions = {
updateEnabled.parentNode
.querySelectorAll("input,radio,label")
.forEach(item => {
item.disabled = !updateEnabled.checked;
.forEach(element => {
element.disabled = !updateEnabled.checked;
});
autotagUsePrefix.disabled = !autotagEnable.checked;
@ -1507,8 +1507,8 @@ var FeedSubscriptions = {
updateEnabled.disabled = disable;
updateEnabled.parentNode
.querySelectorAll("input,radio,label")
.forEach(item => {
item.disabled = disable;
.forEach(element => {
element.disabled = disable;
});
autotagEnable.disabled = disable;
@ -3054,7 +3054,7 @@ var FeedSubscriptions = {
feedFolder = aParentFolder
.QueryInterface(Ci.nsIMsgLocalMailFolder)
.createLocalSubfolder(folderName);
} catch (ex) {
} catch (exception) {
// An error creating. Skip it.
FeedUtils.log.info(
"importOPMLOutlines: skipping, error creating folder - '" +

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

@ -358,7 +358,7 @@ function openComposeWindowForRSSArticle(
MsgHdrToMimeMessage(
msgHdr,
null,
function (aMsgHdr, aMimeMsg) {
function (messageHeader, aMimeMsg) {
if (
aMimeMsg &&
aMimeMsg.headers["content-base"] &&
@ -374,7 +374,7 @@ function openComposeWindowForRSSArticle(
// No content-base url, use the summary.
MailServices.compose.OpenComposeWindow(
aMsgComposeWindow,
aMsgHdr,
messageHeader,
aMessageUri,
aType,
aFormat,

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

@ -61,9 +61,9 @@ function threadTreeClick(row, event = {}) {
* @returns {Promise} when subscription is done.
*/
async function subsribeToFeed(feedURL) {
const account = MailServices.accounts.getAccount("account1");
const rootFolder = account.incomingServer.rootFolder;
about3Pane.displayFolder(rootFolder.URI);
const account1 = MailServices.accounts.getAccount("account1");
const account1RootFolder = account1.incomingServer.rootFolder;
about3Pane.displayFolder(account1RootFolder.URI);
const index = about3Pane.folderTree.selectedIndex;
Assert.equal(index, 0, "index 0 (account1 root folder) should be selected");
@ -97,13 +97,13 @@ async function subsribeToFeed(feedURL) {
// There's no good way to know if we're ready to continue.
await new Promise(r => dialogWindow.setTimeout(r, 250));
const hiddenPromise = BrowserTestUtils.waitForAttribute(
const feedButtonHiddenPRomise = BrowserTestUtils.waitForAttribute(
"hidden",
addFeedButton,
"true"
);
EventUtils.synthesizeMouseAtCenter(addFeedButton, {}, dialogWindow);
await hiddenPromise;
await feedButtonHiddenPRomise;
EventUtils.synthesizeMouseAtCenter(
dialogDocument.querySelector("dialog").getButton("accept"),

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

@ -231,12 +231,12 @@ export class ImapChannel extends MailChannel {
*
* @param {nsIInputStream} cacheStream - The input stream to read.
*/
_readFromCacheStream(stream) {
_readFromCacheStream(cacheStream) {
const pump = Cc["@mozilla.org/network/input-stream-pump;1"].createInstance(
Ci.nsIInputStreamPump
);
this._contentType = "";
pump.init(stream, 0, 0, true);
pump.init(cacheStream, 0, 0, true);
pump.asyncRead({
onStartRequest: () => {
this._listener.onStartRequest(this);

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

@ -665,21 +665,21 @@ export class ImapClient {
this._actionDone(Cr.NS_ERROR_FAILURE);
return;
}
this._nextAction = res => {
this._nextAction = response => {
this._folderSink = dstFolder.QueryInterface(Ci.nsIImapMailFolderSink);
if (
// See rfc4315.
this._capabilities.includes("UIDPLUS") &&
res.attributes.appenduid
response.attributes.appenduid
) {
// The response is like `<tag> OK [APPENDUID <uidvalidity> <uid>]`.
this._folderSink.setAppendMsgUid(
res.attributes.appenduid[1],
response.attributes.appenduid[1],
this.runningUri
);
}
this._actionDone();
if (res.exists) {
if (response.exists) {
// FIXME: _actionNoopResponse should be enough here, but it breaks
// test_imapAttachmentSaves.js.
this.folder = null;
@ -1194,9 +1194,9 @@ export class ImapClient {
this._server.wrappedJSObject.capabilities = res.capabilities;
this._actionId();
} else {
this._nextAction = res => {
this._capabilities = res.capabilities;
this._server.wrappedJSObject.capabilities = res.capabilities;
this._nextAction = response => {
this._capabilities = response.capabilities;
this._server.wrappedJSObject.capabilities = response.capabilities;
this._actionId();
};
this._sendTagged("CAPABILITY");

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

@ -92,7 +92,7 @@ class CsvFieldMap extends HTMLElement {
*/
_enableSelect(select) {
const selects = [...this._elTbody.querySelectorAll("select")];
const selectedFieldIndexes = selects.map(select => select.value);
const selectedFieldIndexes = selects.map(fieldSelect => fieldSelect.value);
const availableFieldIndexes = this._allFieldIndexes.filter(
index => !selectedFieldIndexes.includes(index)
);

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

@ -103,7 +103,7 @@ JSAccountUtils.jaFactory = function (aProperties, aJsDelegateConstructor) {
log.info(
"creating delegate list for contractID " + aProperties.contractID
);
const delegateList = delegator.methodsToDelegate;
const delegatedMethodsList = delegator.methodsToDelegate;
Object.keys(delegator).forEach(name => {
log.debug("delegator has key " + name);
});
@ -147,21 +147,21 @@ JSAccountUtils.jaFactory = function (aProperties, aJsDelegateConstructor) {
const upperCaseName = name[0].toUpperCase() + name.substr(1);
if ("value" in jsDescriptor) {
log.info("delegating " + upperCaseName);
delegateList.add(upperCaseName);
delegatedMethodsList.add(upperCaseName);
} else {
if (jsDescriptor.set) {
log.info("delegating Set" + upperCaseName);
delegateList.add("Set" + upperCaseName);
delegatedMethodsList.add("Set" + upperCaseName);
}
if (jsDescriptor.get) {
log.info("delegating Get" + upperCaseName);
delegateList.add("Get" + upperCaseName);
delegatedMethodsList.add("Get" + upperCaseName);
}
}
}
// Save the delegate list for reuse, statically for all instances.
Object.getPrototypeOf(jsDelegate).delegateList = delegateList;
Object.getPrototypeOf(jsDelegate).delegateList = delegatedMethodsList;
}
for (const iface of aProperties.baseInterfaces) {

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

@ -1203,7 +1203,7 @@ export class Pop3Client {
this._newMessageTotal++;
// Fetch the full message or only headers depending on server settings
// and message size.
const status =
const fetchHeaderStatus =
this._server.headersOnly ||
this._messageSizeMap.get(messageNumber) > this._maxMessageSize
? UIDL_TOO_BIG
@ -1211,7 +1211,7 @@ export class Pop3Client {
this._messagesToHandle.push({
messageNumber,
uidl,
status,
status: fetchHeaderStatus,
});
}
this._sendNoopIfInactive();

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

@ -143,8 +143,8 @@ class BaseMessageService {
// NOTE: jsmimeemitter relies on this.
const url = new URL(uri.spec);
const params = new URLSearchParams(`?header=${additionalHeader}`);
for (const [key, value] of params.entries()) {
url.searchParams.set(key, value);
for (const [param, value] of params.entries()) {
url.searchParams.set(param, value);
}
uri = uri.mutate().setQuery(url.search).finalize();
}

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

@ -149,8 +149,8 @@ function filterEditorOnLoad() {
// copy the actions
for (let i = 0; i < copiedFilter.actionCount; i++) {
const filterAction = copiedFilter.getActionAt(i);
newFilter.appendAction(filterAction);
const copiedFilterAction = copiedFilter.getActionAt(i);
newFilter.appendAction(copiedFilterAction);
}
// copy the search terms

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

@ -96,7 +96,7 @@ export class BinaryServer {
const server = this;
socket.asyncListen({
async onSocketAccepted(socket, transport) {
async onSocketAccepted(acceptedSocket, transport) {
const conn = new Connection(transport);
server._connections.add(conn);
try {

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

@ -469,7 +469,7 @@ export class ImapMessage {
getPartBody(partNum) {
var body = "";
var emitter = {
deliverPartData(partNum, data) {
deliverPartData(partNumber, data) {
body += data;
},
};
@ -1477,7 +1477,7 @@ export class IMAP_RFC3501_handler {
if (
!items.includes("FLAGS") &&
(flagsAfter.length != flagsBefore.length ||
flagsAfter.some((f, i) => f != flagsBefore[i]))
flagsAfter.some((f, index) => f != flagsBefore[index]))
) {
// Flags changed, send them too, even though they weren't requested.
parts.push(this._FETCH_FLAGS(messages[i], "FLAGS"));
@ -2012,8 +2012,8 @@ export var IMAP_GMAIL_extension = {
break;
case "-X-GM-LABELS":
if (message.xGmLabels) {
for (let i = 0; i < args[2].length; i++) {
const idx = message.xGmLabels.indexOf(args[2][i]);
for (let j = 0; j < args[2].length; j++) {
const idx = message.xGmLabels.indexOf(args[2][j]);
if (idx != -1) {
message.xGmLabels.splice(idx, 1);
}
@ -2146,8 +2146,8 @@ export var IMAP_CUSTOM_extension = {
break;
case "-X-CUSTOM-LIST":
if (message.xCustomList) {
for (let i = 0; i < args[2].length; i++) {
const idx = message.xCustomList.indexOf(args[2][i]);
for (let j = 0; j < args[2].length; j++) {
const idx = message.xCustomList.indexOf(args[2][j]);
if (idx != -1) {
message.xCustomList.splice(idx, 1);
}

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

@ -507,8 +507,8 @@ class nsMailReader {
dump("SEND: " + response.split(" ", 1)[0] + "\n");
} else if (this._debug == nsMailServer.debugAll) {
var responses = response.split("\n");
responses.forEach(function (line) {
dump("SEND: " + line + "\n");
responses.forEach(function (responseLine) {
dump("SEND: " + responseLine + "\n");
});
}