Bug 1207498 - Part 1: Remove use of expression closure from toolkit/components/, except tests. r=Gijs

This commit is contained in:
Tooru Fujisawa
2015-09-24 20:32:23 +09:00
parent 9dd92bbcc9
commit afbd2956bc
32 changed files with 310 additions and 182 deletions

View File

@@ -829,8 +829,8 @@ ContentPrefService2.prototype = {
cps._genericObservers = []; cps._genericObservers = [];
let tables = ["prefs", "groups", "settings"]; let tables = ["prefs", "groups", "settings"];
let stmts = tables.map(function (t) this._stmt(`DELETE FROM ${t}`), this); let stmts = tables.map(t => this._stmt(`DELETE FROM ${t}`));
this._execStmts(stmts, { onDone: function () callback() }); this._execStmts(stmts, { onDone: () => callback() });
}, },
QueryInterface: function CPS2_QueryInterface(iid) { QueryInterface: function CPS2_QueryInterface(iid) {
@@ -839,7 +839,7 @@ ContentPrefService2.prototype = {
Ci.nsIObserver, Ci.nsIObserver,
Ci.nsISupports, Ci.nsISupports,
]; ];
if (supportedIIDs.some(function (i) iid.equals(i))) if (supportedIIDs.some(i => iid.equals(i)))
return this; return this;
if (iid.equals(Ci.nsIContentPrefService)) if (iid.equals(Ci.nsIContentPrefService))
return this._cps; return this._cps;

View File

@@ -59,7 +59,7 @@ ContentPrefService.prototype = {
Ci.nsIContentPrefService, Ci.nsIContentPrefService,
Ci.nsISupports, Ci.nsISupports,
]; ];
if (supportedIIDs.some(function (i) iid.equals(i))) if (supportedIIDs.some(i => iid.equals(i)))
return this; return this;
if (iid.equals(Ci.nsIContentPrefService2)) { if (iid.equals(Ci.nsIContentPrefService2)) {
if (!this._contentPrefService2) { if (!this._contentPrefService2) {

View File

@@ -647,19 +647,19 @@ extApplication.prototype = {
get console() { get console() {
let console = new Console(); let console = new Console();
this.__defineGetter__("console", function () console); this.__defineGetter__("console", () => console);
return this.console; return this.console;
}, },
get storage() { get storage() {
let storage = new SessionStorage(); let storage = new SessionStorage();
this.__defineGetter__("storage", function () storage); this.__defineGetter__("storage", () => storage);
return this.storage; return this.storage;
}, },
get prefs() { get prefs() {
let prefs = new PreferenceBranch(""); let prefs = new PreferenceBranch("");
this.__defineGetter__("prefs", function () prefs); this.__defineGetter__("prefs", () => prefs);
return this.prefs; return this.prefs;
}, },
@@ -687,7 +687,7 @@ extApplication.prototype = {
} }
let events = new Events(registerCheck); let events = new Events(registerCheck);
this.__defineGetter__("events", function () events); this.__defineGetter__("events", () => events);
return this.events; return this.events;
}, },

View File

@@ -769,8 +769,8 @@ this.Download.prototype = {
if (!this._promiseCanceled) { if (!this._promiseCanceled) {
// Start a new cancellation request. // Start a new cancellation request.
let deferCanceled = Promise.defer(); let deferCanceled = Promise.defer();
this._currentAttempt.then(function () deferCanceled.resolve(), this._currentAttempt.then(() => deferCanceled.resolve(),
function () deferCanceled.resolve()); () => deferCanceled.resolve());
this._promiseCanceled = deferCanceled.promise; this._promiseCanceled = deferCanceled.promise;
// The download can already be restarted. // The download can already be restarted.

View File

@@ -159,7 +159,9 @@ this.DownloadIntegration = {
/** /**
* Gets and sets test mode * Gets and sets test mode
*/ */
get testMode() this._testMode, get testMode() {
return this._testMode;
},
set testMode(mode) { set testMode(mode) {
this._downloadsDirectory = null; this._downloadsDirectory = null;
return (this._testMode = mode); return (this._testMode = mode);

View File

@@ -51,15 +51,21 @@ this.Downloads = {
/** /**
* Work on downloads that were not started from a private browsing window. * Work on downloads that were not started from a private browsing window.
*/ */
get PUBLIC() "{Downloads.PUBLIC}", get PUBLIC() {
return "{Downloads.PUBLIC}";
},
/** /**
* Work on downloads that were started from a private browsing window. * Work on downloads that were started from a private browsing window.
*/ */
get PRIVATE() "{Downloads.PRIVATE}", get PRIVATE() {
return "{Downloads.PRIVATE}";
},
/** /**
* Work on both Downloads.PRIVATE and Downloads.PUBLIC downloads. * Work on both Downloads.PRIVATE and Downloads.PUBLIC downloads.
*/ */
get ALL() "{Downloads.ALL}", get ALL() {
return "{Downloads.ALL}";
},
/** /**
* Creates a new Download object. * Creates a new Download object.

View File

@@ -1247,8 +1247,12 @@ var DirectoryIterator = function DirectoryIterator(path, options) {
this._isClosed = false; this._isClosed = false;
}; };
DirectoryIterator.prototype = { DirectoryIterator.prototype = {
iterator: function () this, iterator: function () {
__iterator__: function () this, return this;
},
__iterator__: function () {
return this;
},
// Once close() is called, _itmsg should reject with a // Once close() is called, _itmsg should reject with a
// StopIteration. However, we don't want to create the promise until // StopIteration. However, we don't want to create the promise until

View File

@@ -955,7 +955,7 @@ var LoginManagerContent = {
// password if we find a matching login. // password if we find a matching login.
var username = usernameField.value.toLowerCase(); var username = usernameField.value.toLowerCase();
let matchingLogins = logins.filter(function(l) let matchingLogins = logins.filter(l =>
l.username.toLowerCase() == username); l.username.toLowerCase() == username);
if (matchingLogins.length == 0) { if (matchingLogins.length == 0) {
log("Password not filled. None of the stored logins match the username already present."); log("Password not filled. None of the stored logins match the username already present.");
@@ -982,9 +982,9 @@ var LoginManagerContent = {
// (user+pass or pass-only) when there's exactly one that matches. // (user+pass or pass-only) when there's exactly one that matches.
let matchingLogins; let matchingLogins;
if (usernameField) if (usernameField)
matchingLogins = logins.filter(function(l) l.username); matchingLogins = logins.filter(l => l.username);
else else
matchingLogins = logins.filter(function(l) !l.username); matchingLogins = logins.filter(l => !l.username);
if (matchingLogins.length != 1) { if (matchingLogins.length != 1) {
log("Multiple logins for form, so not filling any."); log("Multiple logins for form, so not filling any.");

View File

@@ -281,7 +281,10 @@ LoginStore.prototype = {
/** /**
* Called when the data changed, this triggers asynchronous serialization. * Called when the data changed, this triggers asynchronous serialization.
*/ */
saveSoon: function () this._saver.arm(), saveSoon: function ()
{
return this._saver.arm();
},
/** /**
* DeferredTask that handles the save operation. * DeferredTask that handles the save operation.

View File

@@ -313,7 +313,7 @@ function SignonMatchesFilter(aSignon, aFilterValue) {
function FilterPasswords(aFilterValue, view) { function FilterPasswords(aFilterValue, view) {
aFilterValue = aFilterValue.toLowerCase(); aFilterValue = aFilterValue.toLowerCase();
return signons.filter(function (s) SignonMatchesFilter(s, aFilterValue)); return signons.filter(s => SignonMatchesFilter(s, aFilterValue));
} }
function SignonSaveState() { function SignonSaveState() {

View File

@@ -298,7 +298,7 @@ LoginManager.prototype = {
var logins = this.findLogins({}, login.hostname, login.formSubmitURL, var logins = this.findLogins({}, login.hostname, login.formSubmitURL,
login.httpRealm); login.httpRealm);
if (logins.some(function(l) login.matches(l, true))) if (logins.some(l => login.matches(l, true)))
throw new Error("This login already exists."); throw new Error("This login already exists.");
log("Adding login"); log("Adding login");

View File

@@ -1333,7 +1333,7 @@ LoginManagerPrompter.prototype = {
promptToChangePasswordWithUsernames : function (logins, count, aNewLogin) { promptToChangePasswordWithUsernames : function (logins, count, aNewLogin) {
const buttonFlags = Ci.nsIPrompt.STD_YES_NO_BUTTONS; const buttonFlags = Ci.nsIPrompt.STD_YES_NO_BUTTONS;
var usernames = logins.map(function (l) l.username); var usernames = logins.map(l => l.username);
var dialogText = this._getLocalizedString("userSelectText"); var dialogText = this._getLocalizedString("userSelectText");
var dialogTitle = this._getLocalizedString("passwordChangeTitle"); var dialogTitle = this._getLocalizedString("passwordChangeTitle");
var selectedIndex = { value: null }; var selectedIndex = { value: null };

View File

@@ -501,7 +501,7 @@ LoginManagerStorage_mozStorage.prototype = {
// Build query // Build query
let query = "SELECT * FROM moz_logins"; let query = "SELECT * FROM moz_logins";
if (conditions.length) { if (conditions.length) {
conditions = conditions.map(function(c) "(" + c + ")"); conditions = conditions.map(c => "(" + c + ")");
query += " WHERE " + conditions.join(" AND "); query += " WHERE " + conditions.join(" AND ");
} }
@@ -713,7 +713,7 @@ LoginManagerStorage_mozStorage.prototype = {
let query = "SELECT COUNT(1) AS numLogins FROM moz_logins"; let query = "SELECT COUNT(1) AS numLogins FROM moz_logins";
if (conditions.length) { if (conditions.length) {
conditions = conditions.map(function(c) "(" + c + ")"); conditions = conditions.map(c => "(" + c + ")");
query += " WHERE " + conditions.join(" AND "); query += " WHERE " + conditions.join(" AND ");
} }

View File

@@ -91,7 +91,9 @@ this.PlacesBackups = {
* 3: contents hash * 3: contents hash
* 4: file extension * 4: file extension
*/ */
get filenamesRegex() filenamesRegex, get filenamesRegex() {
return filenamesRegex;
},
get folder() { get folder() {
Deprecated.warning( Deprecated.warning(
@@ -133,7 +135,9 @@ this.PlacesBackups = {
}.bind(this)); }.bind(this));
}, },
get profileRelativeFolderPath() "bookmarkbackups", get profileRelativeFolderPath() {
return "bookmarkbackups";
},
/** /**
* Cache current backups in a sorted (by date DESC) array. * Cache current backups in a sorted (by date DESC) array.

View File

@@ -188,8 +188,9 @@ this.PlacesDBUtils = {
* @param [optional] aTasks * @param [optional] aTasks
* Tasks object to execute. * Tasks object to execute.
*/ */
_checkIntegritySkipReindex: function PDBU__checkIntegritySkipReindex(aTasks) _checkIntegritySkipReindex: function PDBU__checkIntegritySkipReindex(aTasks) {
this.checkIntegrity(aTasks, true), return this.checkIntegrity(aTasks, true);
},
/** /**
* Checks integrity and tries to fix the database through a reindex. * Checks integrity and tries to fix the database through a reindex.
@@ -277,7 +278,7 @@ this.PlacesDBUtils = {
PlacesDBUtils._executeTasks(tasks); PlacesDBUtils._executeTasks(tasks);
} }
}); });
stmts.forEach(function (aStmt) aStmt.finalize()); stmts.forEach(aStmt => aStmt.finalize());
}, },
_getBoundCoherenceStatements: function PDBU__getBoundCoherenceStatements() _getBoundCoherenceStatements: function PDBU__getBoundCoherenceStatements()
@@ -1120,7 +1121,10 @@ Tasks.prototype = {
* *
* @return next task or undefined if no task is left. * @return next task or undefined if no task is left.
*/ */
pop: function T_pop() this._list.shift(), pop: function T_pop()
{
return this._list.shift();
},
/** /**
* Removes all tasks. * Removes all tasks.
@@ -1133,7 +1137,10 @@ Tasks.prototype = {
/** /**
* Returns array of tasks ordered from the next to be run to the latest. * Returns array of tasks ordered from the next to be run to the latest.
*/ */
get list() this._list.slice(0, this._list.length), get list()
{
return this._list.slice(0, this._list.length);
},
/** /**
* Adds a message to the log. * Adds a message to the log.
@@ -1149,5 +1156,8 @@ Tasks.prototype = {
/** /**
* Returns array of log messages ordered from oldest to newest. * Returns array of log messages ordered from oldest to newest.
*/ */
get messages() this._log.slice(0, this._log.length), get messages()
{
return this._log.slice(0, this._log.length);
},
} }

View File

@@ -196,7 +196,9 @@ TransactionsHistory.__proto__ = {
// The index of the first undo entry (if any) - See the documentation // The index of the first undo entry (if any) - See the documentation
// at the top of this file. // at the top of this file.
_undoPosition: 0, _undoPosition: 0,
get undoPosition() this._undoPosition, get undoPosition() {
return this._undoPosition;
},
// Handy shortcuts // Handy shortcuts
get topUndoEntry() { get topUndoEntry() {

View File

@@ -71,8 +71,12 @@ function QI_node(aNode, aIID) {
} }
return result; return result;
} }
function asContainer(aNode) QI_node(aNode, Ci.nsINavHistoryContainerResultNode); function asContainer(aNode) {
function asQuery(aNode) QI_node(aNode, Ci.nsINavHistoryQueryResultNode); return QI_node(aNode, Ci.nsINavHistoryContainerResultNode);
}
function asQuery(aNode) {
return QI_node(aNode, Ci.nsINavHistoryQueryResultNode);
}
/** /**
* Sends a bookmarks notification through the given observers. * Sends a bookmarks notification through the given observers.
@@ -241,8 +245,8 @@ this.PlacesUtils = {
TOPIC_BOOKMARKS_RESTORE_SUCCESS: "bookmarks-restore-success", TOPIC_BOOKMARKS_RESTORE_SUCCESS: "bookmarks-restore-success",
TOPIC_BOOKMARKS_RESTORE_FAILED: "bookmarks-restore-failed", TOPIC_BOOKMARKS_RESTORE_FAILED: "bookmarks-restore-failed",
asContainer: function(aNode) asContainer(aNode), asContainer: aNode => asContainer(aNode),
asQuery: function(aNode) asQuery(aNode), asQuery: aNode => asQuery(aNode),
endl: NEWLINE, endl: NEWLINE,
@@ -2539,45 +2543,61 @@ function TransactionItemCache()
} }
TransactionItemCache.prototype = { TransactionItemCache.prototype = {
set id(v) set id(v) {
this._id = (parseInt(v) > 0 ? v : null), this._id = (parseInt(v) > 0 ? v : null);
get id() },
this._id || -1, get id() {
set parentId(v) return this._id || -1;
this._parentId = (parseInt(v) > 0 ? v : null), },
get parentId() set parentId(v) {
this._parentId || -1, this._parentId = (parseInt(v) > 0 ? v : null);
},
get parentId() {
return this._parentId || -1;
},
keyword: null, keyword: null,
title: null, title: null,
dateAdded: null, dateAdded: null,
lastModified: null, lastModified: null,
postData: null, postData: null,
itemType: null, itemType: null,
set uri(v) set uri(v) {
this._uri = (v instanceof Ci.nsIURI ? v.clone() : null), this._uri = (v instanceof Ci.nsIURI ? v.clone() : null);
get uri() },
this._uri || null, get uri() {
set feedURI(v) return this._uri || null;
this._feedURI = (v instanceof Ci.nsIURI ? v.clone() : null), },
get feedURI() set feedURI(v) {
this._feedURI || null, this._feedURI = (v instanceof Ci.nsIURI ? v.clone() : null);
set siteURI(v) },
this._siteURI = (v instanceof Ci.nsIURI ? v.clone() : null), get feedURI() {
get siteURI() return this._feedURI || null;
this._siteURI || null, },
set index(v) set siteURI(v) {
this._index = (parseInt(v) >= 0 ? v : null), this._siteURI = (v instanceof Ci.nsIURI ? v.clone() : null);
},
get siteURI() {
return this._siteURI || null;
},
set index(v) {
this._index = (parseInt(v) >= 0 ? v : null);
},
// Index can be 0. // Index can be 0.
get index() get index() {
this._index != null ? this._index : PlacesUtils.bookmarks.DEFAULT_INDEX, return this._index != null ? this._index : PlacesUtils.bookmarks.DEFAULT_INDEX;
set annotations(v) },
this._annotations = Array.isArray(v) ? Cu.cloneInto(v, {}) : null, set annotations(v) {
get annotations() this._annotations = Array.isArray(v) ? Cu.cloneInto(v, {}) : null;
this._annotations || null, },
set tags(v) get annotations() {
this._tags = (v && Array.isArray(v) ? Array.slice(v) : null), return this._annotations || null;
get tags() },
this._tags || null, set tags(v) {
this._tags = (v && Array.isArray(v) ? Array.slice(v) : null);
},
get tags() {
return this._tags || null;
},
}; };
@@ -2592,15 +2612,23 @@ function BaseTransaction()
BaseTransaction.prototype = { BaseTransaction.prototype = {
name: null, name: null,
set childTransactions(v) set childTransactions(v) {
this._childTransactions = (Array.isArray(v) ? Array.slice(v) : null), this._childTransactions = (Array.isArray(v) ? Array.slice(v) : null);
get childTransactions() },
this._childTransactions || null, get childTransactions() {
return this._childTransactions || null;
},
doTransaction: function BTXN_doTransaction() {}, doTransaction: function BTXN_doTransaction() {},
redoTransaction: function BTXN_redoTransaction() this.doTransaction(), redoTransaction: function BTXN_redoTransaction() {
return this.doTransaction();
},
undoTransaction: function BTXN_undoTransaction() {}, undoTransaction: function BTXN_undoTransaction() {},
merge: function BTXN_merge() false, merge: function BTXN_merge() {
get isTransient() false, return false;
},
get isTransient() {
return false;
},
QueryInterface: XPCOMUtils.generateQI([ QueryInterface: XPCOMUtils.generateQI([
Ci.nsITransaction Ci.nsITransaction
]), ]),

View File

@@ -506,8 +506,9 @@ XPCOMUtils.defineLazyGetter(this, "Prefs", () => {
* The text to unescape and modify. * The text to unescape and modify.
* @return the modified spec. * @return the modified spec.
*/ */
function fixupSearchText(spec) function fixupSearchText(spec) {
textURIService.unEscapeURIForUI("UTF-8", stripPrefix(spec)); return textURIService.unEscapeURIForUI("UTF-8", stripPrefix(spec));
}
/** /**
* Generates the tokens used in searching from a given string. * Generates the tokens used in searching from a given string.
@@ -519,8 +520,9 @@ function fixupSearchText(spec)
* empty string. We don't want that, as it'll break our logic, so return * empty string. We don't want that, as it'll break our logic, so return
* an empty array then. * an empty array then.
*/ */
function getUnfilteredSearchTokens(searchString) function getUnfilteredSearchTokens(searchString) {
searchString.length ? searchString.split(REGEXP_SPACES) : []; return searchString.length ? searchString.split(REGEXP_SPACES) : [];
}
/** /**
* Strip prefixes from the URI that we don't care about for searching. * Strip prefixes from the URI that we don't care about for searching.
@@ -1572,18 +1574,20 @@ Search.prototype = {
* @return an array consisting of the correctly optimized query to search the * @return an array consisting of the correctly optimized query to search the
* database with and an object containing the params to bound. * database with and an object containing the params to bound.
*/ */
get _switchToTabQuery() [ get _switchToTabQuery() {
SQL_SWITCHTAB_QUERY, return [
{ SQL_SWITCHTAB_QUERY,
query_type: QUERYTYPE_FILTERED, {
matchBehavior: this._matchBehavior, query_type: QUERYTYPE_FILTERED,
searchBehavior: this._behavior, matchBehavior: this._matchBehavior,
// We only want to search the tokens that we are left with - not the searchBehavior: this._behavior,
// original search string. // We only want to search the tokens that we are left with - not the
searchString: this._searchTokens.join(" "), // original search string.
maxResults: Prefs.maxRichResults searchString: this._searchTokens.join(" "),
} maxResults: Prefs.maxRichResults
], }
];
},
/** /**
* Obtains the query to search for adaptive results. * Obtains the query to search for adaptive results.
@@ -1591,16 +1595,18 @@ Search.prototype = {
* @return an array consisting of the correctly optimized query to search the * @return an array consisting of the correctly optimized query to search the
* database with and an object containing the params to bound. * database with and an object containing the params to bound.
*/ */
get _adaptiveQuery() [ get _adaptiveQuery() {
SQL_ADAPTIVE_QUERY, return [
{ SQL_ADAPTIVE_QUERY,
parent: PlacesUtils.tagsFolderId, {
search_string: this._searchString, parent: PlacesUtils.tagsFolderId,
query_type: QUERYTYPE_FILTERED, search_string: this._searchString,
matchBehavior: this._matchBehavior, query_type: QUERYTYPE_FILTERED,
searchBehavior: this._behavior matchBehavior: this._matchBehavior,
} searchBehavior: this._behavior
], }
];
},
/** /**
* Whether we should try to autoFill. * Whether we should try to autoFill.

View File

@@ -453,7 +453,9 @@ function Livemark(aLivemarkInfo)
} }
Livemark.prototype = { Livemark.prototype = {
get status() this._status, get status() {
return this._status;
},
set status(val) { set status(val) {
if (this._status != val) { if (this._status != val) {
this._status = val; this._status = val;
@@ -553,7 +555,9 @@ Livemark.prototype = {
this.updateChildren(aForceUpdate); this.updateChildren(aForceUpdate);
}, },
get children() this._children, get children() {
return this._children;
},
set children(val) { set children(val) {
this._children = val; this._children = val;
@@ -591,23 +595,48 @@ Livemark.prototype = {
// The QueryInterface is needed cause aContainerNode is a jsval. // The QueryInterface is needed cause aContainerNode is a jsval.
// This is required to avoid issues with scriptable wrappers that would // This is required to avoid issues with scriptable wrappers that would
// not allow the view to correctly set expandos. // not allow the view to correctly set expandos.
get parent() get parent() {
aContainerNode.QueryInterface(Ci.nsINavHistoryContainerResultNode), return aContainerNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
get parentResult() this.parent.parentResult, },
get uri() localChild.uri.spec, get parentResult() {
get type() Ci.nsINavHistoryResultNode.RESULT_TYPE_URI, return this.parent.parentResult;
get title() localChild.title, },
get accessCount() get uri() {
Number(livemark._isURIVisited(NetUtil.newURI(this.uri))), return localChild.uri.spec;
get time() 0, },
get icon() "", get type() {
get indentLevel() this.parent.indentLevel + 1, return Ci.nsINavHistoryResultNode.RESULT_TYPE_URI;
get bookmarkIndex() -1, },
get itemId() -1, get title() {
get dateAdded() now, return localChild.title;
get lastModified() now, },
get tags() get accessCount() {
PlacesUtils.tagging.getTagsForURI(NetUtil.newURI(this.uri)).join(", "), return Number(livemark._isURIVisited(NetUtil.newURI(this.uri)));
},
get time() {
return 0;
},
get icon() {
return "";
},
get indentLevel() {
return this.parent.indentLevel + 1;
},
get bookmarkIndex() {
return -1;
},
get itemId() {
return -1;
},
get dateAdded() {
return now;
},
get lastModified() {
return now;
},
get tags() {
return PlacesUtils.tagging.getTagsForURI(NetUtil.newURI(this.uri)).join(", ");
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryResultNode]) QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryResultNode])
}; };
nodes.push(node); nodes.push(node);

View File

@@ -721,8 +721,9 @@ nsPlacesAutoComplete.prototype = {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//// nsPlacesAutoComplete //// nsPlacesAutoComplete
get _databaseInitialized() get _databaseInitialized() {
Object.getOwnPropertyDescriptor(this, "_db").value !== undefined, return Object.getOwnPropertyDescriptor(this, "_db").value !== undefined;
},
/** /**
* Generates the tokens used in searching from a given string. * Generates the tokens used in searching from a given string.

View File

@@ -721,7 +721,9 @@ nsPlacesExpiration.prototype = {
} }
return aNewStatus; return aNewStatus;
}, },
get status() this._status, get status() {
return this._status;
},
_isIdleObserver: false, _isIdleObserver: false,
_expireOnIdle: false, _expireOnIdle: false,
@@ -746,7 +748,9 @@ nsPlacesExpiration.prototype = {
this._expireOnIdle = aExpireOnIdle; this._expireOnIdle = aExpireOnIdle;
return this._expireOnIdle; return this._expireOnIdle;
}, },
get expireOnIdle() this._expireOnIdle, get expireOnIdle() {
return this._expireOnIdle;
},
_loadPrefs: function PEX__loadPrefs() { _loadPrefs: function PEX__loadPrefs() {
// Get the user's limit, if it was set. // Get the user's limit, if it was set.

View File

@@ -522,7 +522,9 @@ TagAutoCompleteResult.prototype = {
return this._results.length; return this._results.length;
}, },
get typeAheadResult() false, get typeAheadResult() {
return false;
},
/** /**
* Get the value of the result at the given index * Get the value of the result at the given index

View File

@@ -141,7 +141,7 @@ CommonDialog.prototype = {
// set the icon // set the icon
let icon = this.ui.infoIcon; let icon = this.ui.infoIcon;
if (icon) if (icon)
this.iconClass.forEach(function(el,idx,arr) icon.classList.add(el)); this.iconClass.forEach((el,idx,arr) => icon.classList.add(el));
// set default result to cancelled // set default result to cancelled
this.args.ok = false; this.args.ok = false;

View File

@@ -56,7 +56,9 @@ var AutoCompleteE10SView = {
getColumnProperties: function(column) { return ""; }, getColumnProperties: function(column) { return ""; },
// nsIAutoCompleteController // nsIAutoCompleteController
get matchCount() this.rowCount, get matchCount() {
return this.rowCount;
},
handleEnter: function(aIsPopupSelection) { handleEnter: function(aIsPopupSelection) {
AutoCompleteE10S.handleEnter(aIsPopupSelection); AutoCompleteE10S.handleEnter(aIsPopupSelection);

View File

@@ -601,7 +601,7 @@ function dbClose(aShutdown) {
dbStmts = new Map(); dbStmts = new Map();
let closed = false; let closed = false;
_dbConnection.asyncClose(function () closed = true); _dbConnection.asyncClose(() => closed = true);
if (!aShutdown) { if (!aShutdown) {
let thread = Services.tm.currentThread; let thread = Services.tm.currentThread;
@@ -773,7 +773,9 @@ function expireOldEntriesVacuum(aExpireTime, aBeginningCount) {
} }
this.FormHistory = { this.FormHistory = {
get enabled() Prefs.enabled, get enabled() {
return Prefs.enabled;
},
search : function formHistorySearch(aSelectTerms, aSearchData, aCallbacks) { search : function formHistorySearch(aSelectTerms, aSearchData, aCallbacks) {
// if no terms selected, select everything // if no terms selected, select everything

View File

@@ -242,7 +242,7 @@ FormAutoComplete.prototype = {
let entry = entries[i]; let entry = entries[i];
// Remove results that do not contain the token // Remove results that do not contain the token
// XXX bug 394604 -- .toLowerCase can be wrong for some intl chars // XXX bug 394604 -- .toLowerCase can be wrong for some intl chars
if(searchTokens.some(function (tok) entry.textLowerCase.indexOf(tok) < 0)) if(searchTokens.some(tok => entry.textLowerCase.indexOf(tok) < 0))
continue; continue;
this._calculateScore(entry, searchString, searchTokens); this._calculateScore(entry, searchString, searchTokens);
this.log("Reusing autocomplete entry '" + entry.text + this.log("Reusing autocomplete entry '" + entry.text +

View File

@@ -1013,8 +1013,9 @@ function sanitizeName(aName) {
* @param prefName * @param prefName
* The name of the pref. * The name of the pref.
**/ **/
function getMozParamPref(prefName) function getMozParamPref(prefName) {
Services.prefs.getCharPref(BROWSER_SEARCH_PREF + "param." + prefName); return Services.prefs.getCharPref(BROWSER_SEARCH_PREF + "param." + prefName);
}
/** /**
* Notifies watchers of SEARCH_ENGINE_TOPIC about changes to an engine or to * Notifies watchers of SEARCH_ENGINE_TOPIC about changes to an engine or to
@@ -1241,8 +1242,9 @@ EngineURL.prototype = {
return queryParam ? queryParam.name : ""; return queryParam ? queryParam.name : "";
}, },
_hasRelation: function SRC_EURL__hasRelation(aRel) _hasRelation: function SRC_EURL__hasRelation(aRel) {
this.rels.some(function(e) e == aRel.toLowerCase()), return this.rels.some(e => e == aRel.toLowerCase());
},
_initWithJSON: function SRC_EURL__initWithJSON(aJson, aEngine) { _initWithJSON: function SRC_EURL__initWithJSON(aJson, aEngine) {
if (!aJson.params) if (!aJson.params)
@@ -1285,8 +1287,9 @@ EngineURL.prototype = {
if (this.method != "GET") if (this.method != "GET")
json.method = this.method; json.method = this.method;
function collapseMozParams(aParam) function collapseMozParams(aParam) {
this.mozparams[aParam.name] || aParam; return this.mozparams[aParam.name] || aParam;
}
json.params = this.params.map(collapseMozParams, this); json.params = this.params.map(collapseMozParams, this);
return json; return json;
@@ -3194,10 +3197,12 @@ SearchService.prototype = {
cache.directories[aDir.path].lastModifiedTime != aDir.lastModifiedTime); cache.directories[aDir.path].lastModifiedTime != aDir.lastModifiedTime);
} }
function notInCachePath(aPathToLoad) function notInCachePath(aPathToLoad) {
cachePaths.indexOf(aPathToLoad.path) == -1; return cachePaths.indexOf(aPathToLoad.path) == -1;
function notInCacheVisibleEngines(aEngineName) }
cache.visibleDefaultEngines.indexOf(aEngineName) == -1; function notInCacheVisibleEngines(aEngineName) {
return cache.visibleDefaultEngines.indexOf(aEngineName) == -1;
}
let buildID = Services.appinfo.platformBuildID; let buildID = Services.appinfo.platformBuildID;
let cachePaths = [path for (path in cache.directories)]; let cachePaths = [path for (path in cache.directories)];
@@ -3316,10 +3321,12 @@ SearchService.prototype = {
}); });
} }
function notInCachePath(aPathToLoad) function notInCachePath(aPathToLoad) {
cachePaths.indexOf(aPathToLoad.path) == -1; return cachePaths.indexOf(aPathToLoad.path) == -1;
function notInCacheVisibleEngines(aEngineName) }
cache.visibleDefaultEngines.indexOf(aEngineName) == -1; function notInCacheVisibleEngines(aEngineName) {
return cache.visibleDefaultEngines.indexOf(aEngineName) == -1;
}
let buildID = Services.appinfo.platformBuildID; let buildID = Services.appinfo.platformBuildID;
let cachePaths = [path for (path in cache.directories)]; let cachePaths = [path for (path in cache.directories)];
@@ -3748,7 +3755,7 @@ SearchService.prototype = {
_parseListTxt: function SRCH_SVC_parseListTxt(list, jarPackaging, _parseListTxt: function SRCH_SVC_parseListTxt(list, jarPackaging,
chromeFiles, uris) { chromeFiles, uris) {
let names = list.split("\n").filter(function (n) !!n); let names = list.split("\n").filter(n => !!n);
// This maps the names of our built-in engines to a boolean // This maps the names of our built-in engines to a boolean
// indicating whether it should be hidden by default. // indicating whether it should be hidden by default.
let jarNames = new Map(); let jarNames = new Map();
@@ -4913,8 +4920,10 @@ var engineMetadataService = {
/** /**
* Flush any waiting write. * Flush any waiting write.
*/ */
finalize: function () this._lazyWriter ? this._lazyWriter.finalize() finalize: function () {
: Promise.resolve(), return this._lazyWriter ? this._lazyWriter.finalize()
: Promise.resolve();
},
/** /**
* Commit changes to disk, asynchronously. * Commit changes to disk, asynchronously.

View File

@@ -28,7 +28,9 @@ AbstractPort.prototype = {
return "MessagePort(portType='" + this._portType + "', portId=" return "MessagePort(portType='" + this._portType + "', portId="
+ this._portid + (this._closed ? ", closed=true" : "") + ")"; + this._portid + (this._closed ? ", closed=true" : "") + ")";
}, },
_JSONParse: function fw_AbstractPort_JSONParse(data) JSON.parse(data), _JSONParse: function fw_AbstractPort_JSONParse(data) {
return JSON.parse(data);
},
_postControlMessage: function fw_AbstractPort_postControlMessage(topic, data) { _postControlMessage: function fw_AbstractPort_postControlMessage(topic, data) {
let postData = { let postData = {

View File

@@ -34,7 +34,9 @@ XPCOMUtils.defineLazyServiceGetter(this, "etld",
// Internal helper methods and state // Internal helper methods and state
var SocialServiceInternal = { var SocialServiceInternal = {
get enabled() this.providerArray.length > 0, get enabled() {
return this.providerArray.length > 0;
},
get providerArray() { get providerArray() {
return [p for ([, p] of Iterator(this.providers))]; return [p for ([, p] of Iterator(this.providers))];
@@ -122,7 +124,7 @@ var SocialServiceInternal = {
// all enabled providers get sorted even with frecency zero. // all enabled providers get sorted even with frecency zero.
let providerList = SocialServiceInternal.providerArray; let providerList = SocialServiceInternal.providerArray;
// reverse sort // reverse sort
aCallback(providerList.sort(function(a, b) b.frecency - a.frecency)); aCallback(providerList.sort((a, b) => b.frecency - a.frecency));
} }
}); });
} finally { } finally {

View File

@@ -115,17 +115,23 @@ this.PageThumbs = {
/** /**
* The scheme to use for thumbnail urls. * The scheme to use for thumbnail urls.
*/ */
get scheme() "moz-page-thumb", get scheme() {
return "moz-page-thumb";
},
/** /**
* The static host to use for thumbnail urls. * The static host to use for thumbnail urls.
*/ */
get staticHost() "thumbnail", get staticHost() {
return "thumbnail";
},
/** /**
* The thumbnails' image type. * The thumbnails' image type.
*/ */
get contentType() "image/png", get contentType() {
return "image/png";
},
init: function PageThumbs_init() { init: function PageThumbs_init() {
if (!this._initialized) { if (!this._initialized) {

View File

@@ -40,12 +40,16 @@ Protocol.prototype = {
/** /**
* The scheme used by this protocol. * The scheme used by this protocol.
*/ */
get scheme() PageThumbs.scheme, get scheme() {
return PageThumbs.scheme;
},
/** /**
* The default port for this protocol (we don't support ports). * The default port for this protocol (we don't support ports).
*/ */
get defaultPort() -1, get defaultPort() {
return -1;
},
/** /**
* The flags specific to this protocol implementation. * The flags specific to this protocol implementation.
@@ -92,7 +96,7 @@ Protocol.prototype = {
* Decides whether to allow a blacklisted port. * Decides whether to allow a blacklisted port.
* @return Always false, we'll never allow ports. * @return Always false, we'll never allow ports.
*/ */
allowPort: function () false, allowPort: () => false,
classID: Components.ID("{5a4ae9b5-f475-48ae-9dce-0b4c1d347884}"), classID: Components.ID("{5a4ae9b5-f475-48ae-9dce-0b4c1d347884}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler]) QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler])

View File

@@ -87,9 +87,9 @@ nsURLFormatterService.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIURLFormatter]), QueryInterface: XPCOMUtils.generateQI([Ci.nsIURLFormatter]),
_defaults: { _defaults: {
LOCALE: function() Cc["@mozilla.org/chrome/chrome-registry;1"]. LOCALE: () => Cc["@mozilla.org/chrome/chrome-registry;1"].
getService(Ci.nsIXULChromeRegistry). getService(Ci.nsIXULChromeRegistry).
getSelectedLocale('global'), getSelectedLocale('global'),
REGION: function() { REGION: function() {
try { try {
// When the geoip lookup failed to identify the region, we fallback to // When the geoip lookup failed to identify the region, we fallback to
@@ -99,27 +99,27 @@ nsURLFormatterService.prototype = {
return "ZZ"; return "ZZ";
} }
}, },
VENDOR: function() this.appInfo.vendor, VENDOR: function() { return this.appInfo.vendor; },
NAME: function() this.appInfo.name, NAME: function() { return this.appInfo.name; },
ID: function() this.appInfo.ID, ID: function() { return this.appInfo.ID; },
VERSION: function() this.appInfo.version, VERSION: function() { return this.appInfo.version; },
APPBUILDID: function() this.appInfo.appBuildID, APPBUILDID: function() { return this.appInfo.appBuildID; },
PLATFORMVERSION: function() this.appInfo.platformVersion, PLATFORMVERSION: function() { return this.appInfo.platformVersion; },
PLATFORMBUILDID: function() this.appInfo.platformBuildID, PLATFORMBUILDID: function() { return this.appInfo.platformBuildID; },
APP: function() this.appInfo.name.toLowerCase().replace(/ /, ""), APP: function() { return this.appInfo.name.toLowerCase().replace(/ /, ""); },
OS: function() this.appInfo.OS, OS: function() { return this.appInfo.OS; },
XPCOMABI: function() this.ABI, XPCOMABI: function() { return this.ABI; },
BUILD_TARGET: function() this.appInfo.OS + "_" + this.ABI, BUILD_TARGET: function() { return this.appInfo.OS + "_" + this.ABI; },
OS_VERSION: function() this.OSVersion, OS_VERSION: function() { return this.OSVersion; },
CHANNEL: function() UpdateUtils.UpdateChannel, CHANNEL: () => UpdateUtils.UpdateChannel,
MOZILLA_API_KEY: function() "@MOZ_MOZILLA_API_KEY@", MOZILLA_API_KEY: () => "@MOZ_MOZILLA_API_KEY@",
GOOGLE_API_KEY: function() "@MOZ_GOOGLE_API_KEY@", GOOGLE_API_KEY: () => "@MOZ_GOOGLE_API_KEY@",
GOOGLE_OAUTH_API_CLIENTID:function() "@MOZ_GOOGLE_OAUTH_API_CLIENTID@", GOOGLE_OAUTH_API_CLIENTID:() => "@MOZ_GOOGLE_OAUTH_API_CLIENTID@",
GOOGLE_OAUTH_API_KEY: function() "@MOZ_GOOGLE_OAUTH_API_KEY@", GOOGLE_OAUTH_API_KEY: () => "@MOZ_GOOGLE_OAUTH_API_KEY@",
BING_API_CLIENTID:function() "@MOZ_BING_API_CLIENTID@", BING_API_CLIENTID:() => "@MOZ_BING_API_CLIENTID@",
BING_API_KEY: function() "@MOZ_BING_API_KEY@", BING_API_KEY: () => "@MOZ_BING_API_KEY@",
DISTRIBUTION: function() this.distribution.id, DISTRIBUTION: function() { return this.distribution.id; },
DISTRIBUTION_VERSION: function() this.distribution.version DISTRIBUTION_VERSION: function() { return this.distribution.version; }
}, },
formatURL: function uf_formatURL(aFormat) { formatURL: function uf_formatURL(aFormat) {