зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1536929 - [geckoview] Use const when possible and enforce it. r=geckoview-reviewers,esawin
Generated with ./mach eslint mobile/android/modules/geckoview --fix Differential Revision: https://phabricator.services.mozilla.com/D24246 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
44f182bf3b
Коммит
337193c3e5
|
@ -5,4 +5,7 @@ module.exports = {
|
|||
"debug": false,
|
||||
"warn": false,
|
||||
},
|
||||
"rules": {
|
||||
"prefer-const": "error",
|
||||
},
|
||||
};
|
||||
|
|
|
@ -21,12 +21,12 @@ ChromeUtils.defineModuleGetter(this, "OS",
|
|||
const {debug, warn} = GeckoViewUtils.initLogging("ContentCrashHandler"); // eslint-disable-line no-unused-vars
|
||||
|
||||
function getDir(name) {
|
||||
let uAppDataPath = Services.dirsvc.get("UAppData", Ci.nsIFile).path;
|
||||
const uAppDataPath = Services.dirsvc.get("UAppData", Ci.nsIFile).path;
|
||||
return OS.Path.join(uAppDataPath, "Crash Reports", name);
|
||||
}
|
||||
|
||||
function getPendingMinidump(id) {
|
||||
let pendingDir = getDir("pending");
|
||||
const pendingDir = getDir("pending");
|
||||
|
||||
return [".dmp", ".extra"].map(suffix => {
|
||||
return OS.Path.join(pendingDir, `${id}${suffix}`);
|
||||
|
@ -46,7 +46,7 @@ var ContentCrashHandler = {
|
|||
return;
|
||||
}
|
||||
|
||||
let dumpID = aSubject.get("dumpID");
|
||||
const dumpID = aSubject.get("dumpID");
|
||||
if (!dumpID) {
|
||||
Services.telemetry
|
||||
.getHistogramById("FX_CONTENT_CRASH_DUMP_UNAVAILABLE")
|
||||
|
|
|
@ -52,7 +52,7 @@ var DelayedInit = {
|
|||
},
|
||||
|
||||
scheduleList: function(fns, maxWait) {
|
||||
for (let fn of fns) {
|
||||
for (const fn of fns) {
|
||||
Impl.scheduleInit(fn, null, null, maxWait);
|
||||
}
|
||||
},
|
||||
|
@ -66,13 +66,13 @@ var Impl = {
|
|||
pendingInits: [],
|
||||
|
||||
onIdle: function() {
|
||||
let startTime = Cu.now();
|
||||
const startTime = Cu.now();
|
||||
let time = startTime;
|
||||
let nextDue;
|
||||
|
||||
// Go through all the pending inits. Even if we don't run them,
|
||||
// we still need to find out when the next timeout should be.
|
||||
for (let init of this.pendingInits) {
|
||||
for (const init of this.pendingInits) {
|
||||
if (init.complete) {
|
||||
continue;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ var Impl = {
|
|||
},
|
||||
|
||||
addPendingInit: function(fn, wait) {
|
||||
let init = {
|
||||
const init = {
|
||||
fn: fn,
|
||||
due: Cu.now() + wait,
|
||||
complete: false,
|
||||
|
@ -121,7 +121,7 @@ var Impl = {
|
|||
},
|
||||
|
||||
scheduleInit: function(fn, object, name, wait) {
|
||||
let init = this.addPendingInit(fn, wait);
|
||||
const init = this.addPendingInit(fn, wait);
|
||||
|
||||
if (!object || !name) {
|
||||
// No lazy getter needed.
|
||||
|
@ -146,7 +146,7 @@ var Impl = {
|
|||
|
||||
// If the initializer actually ran, it may have replaced our proxy
|
||||
// property with a real one, so we need to reload he property.
|
||||
let newProp = Object.getOwnPropertyDescriptor(object, name);
|
||||
const newProp = Object.getOwnPropertyDescriptor(object, name);
|
||||
if (newProp.get !== proxy_getter) {
|
||||
// Set prop if newProp doesn't refer to our proxy property.
|
||||
prop = newProp;
|
||||
|
|
|
@ -113,7 +113,7 @@ class GeckoViewAutoFill {
|
|||
return info;
|
||||
};
|
||||
|
||||
let [usernameField] =
|
||||
const [usernameField] =
|
||||
LoginManagerContent.getUserNameAndPasswordFields(aFormLike.elements[0]);
|
||||
|
||||
const rootInfo = getInfo(aFormLike.rootElement, null, undefined, null);
|
||||
|
@ -131,7 +131,7 @@ class GeckoViewAutoFill {
|
|||
const AUTOFILL_STATE = "-moz-autofill";
|
||||
const winUtils = window.windowUtils;
|
||||
|
||||
for (let id in responses) {
|
||||
for (const id in responses) {
|
||||
const entry = this._autoFillElements &&
|
||||
this._autoFillElements.get(+id);
|
||||
const element = entry && entry.get();
|
||||
|
@ -173,8 +173,8 @@ class GeckoViewAutoFill {
|
|||
onFocus(aTarget) {
|
||||
debug `Auto-fill focus on ${aTarget && aTarget.tagName}`;
|
||||
|
||||
let info = aTarget && this._autoFillInfos &&
|
||||
this._autoFillInfos.get(aTarget);
|
||||
const info = aTarget && this._autoFillInfos &&
|
||||
this._autoFillInfos.get(aTarget);
|
||||
if (!aTarget || info) {
|
||||
this._eventDispatcher.dispatch("GeckoView:OnAutoFillFocus", info);
|
||||
}
|
||||
|
|
|
@ -51,36 +51,36 @@ var GeckoViewConsole = {
|
|||
_handleConsoleMessage(aMessage) {
|
||||
aMessage = aMessage.wrappedJSObject;
|
||||
|
||||
let mappedArguments = Array.map(aMessage.arguments, this.formatResult, this);
|
||||
let joinedArguments = Array.join(mappedArguments, " ");
|
||||
const mappedArguments = Array.map(aMessage.arguments, this.formatResult, this);
|
||||
const joinedArguments = Array.join(mappedArguments, " ");
|
||||
|
||||
if (aMessage.level == "error" || aMessage.level == "warn") {
|
||||
let flag = (aMessage.level == "error" ? Ci.nsIScriptError.errorFlag : Ci.nsIScriptError.warningFlag);
|
||||
let consoleMsg = Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError);
|
||||
const flag = (aMessage.level == "error" ? Ci.nsIScriptError.errorFlag : Ci.nsIScriptError.warningFlag);
|
||||
const consoleMsg = Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError);
|
||||
consoleMsg.init(joinedArguments, null, null, 0, 0, flag, "content javascript");
|
||||
Services.console.logMessage(consoleMsg);
|
||||
} else if (aMessage.level == "trace") {
|
||||
let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
||||
let args = aMessage.arguments;
|
||||
let filename = this.abbreviateSourceURL(args[0].filename);
|
||||
let functionName = args[0].functionName || bundle.GetStringFromName("stacktrace.anonymousFunction");
|
||||
let lineNumber = args[0].lineNumber;
|
||||
const bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
||||
const args = aMessage.arguments;
|
||||
const filename = this.abbreviateSourceURL(args[0].filename);
|
||||
const functionName = args[0].functionName || bundle.GetStringFromName("stacktrace.anonymousFunction");
|
||||
const lineNumber = args[0].lineNumber;
|
||||
|
||||
let body = bundle.formatStringFromName("stacktrace.outputMessage", [filename, functionName, lineNumber], 3);
|
||||
body += "\n";
|
||||
args.forEach(function(aFrame) {
|
||||
let functionName = aFrame.functionName || bundle.GetStringFromName("stacktrace.anonymousFunction");
|
||||
const functionName = aFrame.functionName || bundle.GetStringFromName("stacktrace.anonymousFunction");
|
||||
body += " " + aFrame.filename + " :: " + functionName + " :: " + aFrame.lineNumber + "\n";
|
||||
});
|
||||
|
||||
Services.console.logStringMessage(body);
|
||||
} else if (aMessage.level == "time" && aMessage.arguments) {
|
||||
let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
||||
let body = bundle.formatStringFromName("timer.start", [aMessage.arguments.name], 1);
|
||||
const bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
||||
const body = bundle.formatStringFromName("timer.start", [aMessage.arguments.name], 1);
|
||||
Services.console.logStringMessage(body);
|
||||
} else if (aMessage.level == "timeEnd" && aMessage.arguments) {
|
||||
let bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
||||
let body = bundle.formatStringFromName("timer.end", [aMessage.arguments.name, aMessage.arguments.duration], 2);
|
||||
const bundle = Services.strings.createBundle("chrome://browser/locale/browser.properties");
|
||||
const body = bundle.formatStringFromName("timer.end", [aMessage.arguments.name, aMessage.arguments.duration], 2);
|
||||
Services.console.logStringMessage(body);
|
||||
} else if (["group", "groupCollapsed", "groupEnd"].includes(aMessage.level)) {
|
||||
// Do nothing yet
|
||||
|
@ -98,7 +98,7 @@ var GeckoViewConsole = {
|
|||
|
||||
formatResult(aResult) {
|
||||
let output = "";
|
||||
let type = this.getResultType(aResult);
|
||||
const type = this.getResultType(aResult);
|
||||
switch (type) {
|
||||
case "string":
|
||||
case "boolean":
|
||||
|
@ -122,7 +122,7 @@ var GeckoViewConsole = {
|
|||
|
||||
abbreviateSourceURL(aSourceURL) {
|
||||
// Remove any query parameters.
|
||||
let hookIndex = aSourceURL.indexOf("?");
|
||||
const hookIndex = aSourceURL.indexOf("?");
|
||||
if (hookIndex > -1)
|
||||
aSourceURL = aSourceURL.substring(0, hookIndex);
|
||||
|
||||
|
@ -131,7 +131,7 @@ var GeckoViewConsole = {
|
|||
aSourceURL = aSourceURL.substring(0, aSourceURL.length - 1);
|
||||
|
||||
// Remove all but the last path component.
|
||||
let slashIndex = aSourceURL.lastIndexOf("/");
|
||||
const slashIndex = aSourceURL.lastIndexOf("/");
|
||||
if (slashIndex > -1)
|
||||
aSourceURL = aSourceURL.substring(slashIndex + 1);
|
||||
|
||||
|
|
|
@ -301,7 +301,7 @@ class GeckoViewNavigation extends GeckoViewModule {
|
|||
onEnable() {
|
||||
debug `onEnable`;
|
||||
|
||||
let flags = Ci.nsIWebProgress.NOTIFY_LOCATION;
|
||||
const flags = Ci.nsIWebProgress.NOTIFY_LOCATION;
|
||||
this.progressFilter =
|
||||
Cc["@mozilla.org/appshell/component/browser-status-filter;1"]
|
||||
.createInstance(Ci.nsIWebProgress);
|
||||
|
@ -329,7 +329,7 @@ class GeckoViewNavigation extends GeckoViewModule {
|
|||
fixedURI = Services.uriFixup.createExposableURI(aLocationURI);
|
||||
} catch (ex) { }
|
||||
|
||||
let message = {
|
||||
const message = {
|
||||
type: "GeckoView:LocationChange",
|
||||
uri: fixedURI.displaySpec,
|
||||
canGoBack: this.browser.canGoBack,
|
||||
|
|
|
@ -85,10 +85,10 @@ var IdentityHandler = {
|
|||
* (if available). Return the data needed to update the UI.
|
||||
*/
|
||||
checkIdentity: function checkIdentity(aState, aBrowser) {
|
||||
let identityMode = this.getIdentityMode(aState);
|
||||
let mixedDisplay = this.getMixedDisplayMode(aState);
|
||||
let mixedActive = this.getMixedActiveMode(aState);
|
||||
let result = {
|
||||
const identityMode = this.getIdentityMode(aState);
|
||||
const mixedDisplay = this.getMixedDisplayMode(aState);
|
||||
const mixedActive = this.getMixedActiveMode(aState);
|
||||
const result = {
|
||||
mode: {
|
||||
identity: identityMode,
|
||||
mixed_display: mixedDisplay,
|
||||
|
@ -122,7 +122,7 @@ var IdentityHandler = {
|
|||
result.host = uri.host;
|
||||
}
|
||||
|
||||
let cert = aBrowser.securityUI.secInfo.serverCert;
|
||||
const cert = aBrowser.securityUI.secInfo.serverCert;
|
||||
|
||||
result.organization = cert.organization;
|
||||
result.subjectName = cert.subjectName;
|
||||
|
@ -147,9 +147,9 @@ class GeckoViewProgress extends GeckoViewModule {
|
|||
onEnable() {
|
||||
debug `onEnable`;
|
||||
|
||||
let flags = Ci.nsIWebProgress.NOTIFY_STATE_NETWORK |
|
||||
Ci.nsIWebProgress.NOTIFY_SECURITY |
|
||||
Ci.nsIWebProgress.NOTIFY_LOCATION;
|
||||
const flags = Ci.nsIWebProgress.NOTIFY_STATE_NETWORK |
|
||||
Ci.nsIWebProgress.NOTIFY_SECURITY |
|
||||
Ci.nsIWebProgress.NOTIFY_LOCATION;
|
||||
this.progressFilter =
|
||||
Cc["@mozilla.org/appshell/component/browser-status-filter;1"]
|
||||
.createInstance(Ci.nsIWebProgress);
|
||||
|
@ -203,7 +203,7 @@ class GeckoViewProgress extends GeckoViewModule {
|
|||
} else if (isStop && !aWebProgress.isLoadingDocument) {
|
||||
this._inProgress = false;
|
||||
|
||||
let message = {
|
||||
const message = {
|
||||
type: "GeckoView:PageStop",
|
||||
success: isSuccess,
|
||||
};
|
||||
|
@ -223,9 +223,9 @@ class GeckoViewProgress extends GeckoViewModule {
|
|||
this._state = aState;
|
||||
this._hostChanged = false;
|
||||
|
||||
let identity = IdentityHandler.checkIdentity(aState, this.browser);
|
||||
const identity = IdentityHandler.checkIdentity(aState, this.browser);
|
||||
|
||||
let message = {
|
||||
const message = {
|
||||
type: "GeckoView:SecurityChanged",
|
||||
identity: identity,
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ XPCOMUtils.defineLazyGetter(this, "DebuggerServer", () => {
|
|||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "SocketListener", () => {
|
||||
let { SocketListener } = require("devtools/shared/security/socket");
|
||||
const { SocketListener } = require("devtools/shared/security/socket");
|
||||
return SocketListener;
|
||||
});
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class Tab {
|
|||
// Stub BrowserApp implementation for WebExtensions support.
|
||||
class GeckoViewTab extends GeckoViewModule {
|
||||
onInit() {
|
||||
let tab = new Tab(0, this.browser);
|
||||
const tab = new Tab(0, this.browser);
|
||||
|
||||
this.window.gBrowser = this.window.BrowserApp = {
|
||||
selectedBrowser: this.browser,
|
||||
|
|
|
@ -103,7 +103,7 @@ var GeckoViewUtils = {
|
|||
});
|
||||
|
||||
if (observers) {
|
||||
let observer = (subject, topic, data) => {
|
||||
const observer = (subject, topic, data) => {
|
||||
Services.obs.removeObserver(observer, topic);
|
||||
if (!once) {
|
||||
Services.obs.addObserver(scope[name], topic);
|
||||
|
@ -118,8 +118,8 @@ var GeckoViewUtils = {
|
|||
return;
|
||||
}
|
||||
|
||||
let addMMListener = (target, names) => {
|
||||
let listener = msg => {
|
||||
const addMMListener = (target, names) => {
|
||||
const listener = msg => {
|
||||
target.removeMessageListener(msg.name, listener);
|
||||
if (!once) {
|
||||
target.addMessageListener(msg.name, scope[name]);
|
||||
|
@ -136,7 +136,7 @@ var GeckoViewUtils = {
|
|||
}
|
||||
|
||||
if (ged) {
|
||||
let listener = (event, data, callback) => {
|
||||
const listener = (event, data, callback) => {
|
||||
EventDispatcher.instance.unregisterListener(listener, event);
|
||||
if (!once) {
|
||||
EventDispatcher.instance.registerListener(scope[name], event);
|
||||
|
@ -151,7 +151,7 @@ var GeckoViewUtils = {
|
|||
if (!handler) {
|
||||
handler = (_ => Array.isArray(name) ? name.map(n => scope[n]) : scope[name]);
|
||||
}
|
||||
let listener = (...args) => {
|
||||
const listener = (...args) => {
|
||||
let handlers = handler(...args);
|
||||
if (!handlers) {
|
||||
return;
|
||||
|
@ -213,7 +213,7 @@ var GeckoViewUtils = {
|
|||
*/
|
||||
registerLazyWindowEventListener: function(window, events,
|
||||
{handler, scope, name, once}) {
|
||||
let dispatcher = this.getDispatcherForWindow(window);
|
||||
const dispatcher = this.getDispatcherForWindow(window);
|
||||
|
||||
this._addLazyListeners(events, handler, scope, name,
|
||||
(events, listener) => {
|
||||
|
@ -339,13 +339,13 @@ var GeckoViewUtils = {
|
|||
},
|
||||
|
||||
getActiveDispatcherAndWindow: function() {
|
||||
let win = Services.focus.activeWindow;
|
||||
const win = Services.focus.activeWindow;
|
||||
let dispatcher = this.getDispatcherForWindow(win);
|
||||
if (dispatcher) {
|
||||
return [dispatcher, win];
|
||||
}
|
||||
|
||||
for (let win of Services.wm.getEnumerator(/* windowType */ null)) {
|
||||
for (const win of Services.wm.getEnumerator(/* windowType */ null)) {
|
||||
dispatcher = this.getDispatcherForWindow(win);
|
||||
if (dispatcher) {
|
||||
return [dispatcher, win];
|
||||
|
|
|
@ -55,8 +55,8 @@ const LoadURIDelegate = {
|
|||
aErrorModule) {
|
||||
let errorClass = 0;
|
||||
try {
|
||||
let nssErrorsService = Cc["@mozilla.org/nss_errors_service;1"]
|
||||
.getService(Ci.nsINSSErrorsService);
|
||||
const nssErrorsService = Cc["@mozilla.org/nss_errors_service;1"]
|
||||
.getService(Ci.nsINSSErrorsService);
|
||||
errorClass = nssErrorsService.getErrorClass(aError);
|
||||
} catch (e) {}
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ DispatcherDelegate.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
let mm = this._messageManager || Services.cpmm;
|
||||
let forwardData = {
|
||||
const mm = this._messageManager || Services.cpmm;
|
||||
const forwardData = {
|
||||
global: !this._messageManager,
|
||||
event: aEvent,
|
||||
data: aData,
|
||||
|
@ -182,11 +182,11 @@ var EventDispatcher = {
|
|||
* @param aWindow a chrome DOM window.
|
||||
*/
|
||||
for: function(aWindow) {
|
||||
let view = aWindow && aWindow.arguments && aWindow.arguments[0] &&
|
||||
aWindow.arguments[0].QueryInterface(Ci.nsIAndroidView);
|
||||
const view = aWindow && aWindow.arguments && aWindow.arguments[0] &&
|
||||
aWindow.arguments[0].QueryInterface(Ci.nsIAndroidView);
|
||||
|
||||
if (!view) {
|
||||
let mm = !IS_PARENT_PROCESS && aWindow && aWindow.messageManager;
|
||||
const mm = !IS_PARENT_PROCESS && aWindow && aWindow.messageManager;
|
||||
if (!mm) {
|
||||
throw new Error("window is not a GeckoView-connected window and does" +
|
||||
" not have a message manager");
|
||||
|
@ -211,7 +211,7 @@ var EventDispatcher = {
|
|||
// aMsg.data includes keys: global, event, data, uuid
|
||||
let callback;
|
||||
if (aMsg.data.uuid) {
|
||||
let reply = (type, response) => {
|
||||
const reply = (type, response) => {
|
||||
const mm = aMsg.data.global ? aMsg.target : aMsg.target.messageManager;
|
||||
if (!mm) {
|
||||
if (type === "finalize") {
|
||||
|
@ -241,8 +241,8 @@ var EventDispatcher = {
|
|||
return;
|
||||
}
|
||||
|
||||
let win = aMsg.target.ownerGlobal;
|
||||
let dispatcher = win.WindowEventDispatcher || this.for(win);
|
||||
const win = aMsg.target.ownerGlobal;
|
||||
const dispatcher = win.WindowEventDispatcher || this.for(win);
|
||||
dispatcher.dispatch(aMsg.data.event, aMsg.data.data, callback, callback);
|
||||
},
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче