Bug 1360293 - Enable the Mozilla ESlint recommended rules for tools/. r=jryans

MozReview-Commit-ID: JMcgZ9taEV5

--HG--
extra : rebase_source : 806d9aa8c470ab35253682a5f16e528ca8d73cc5
This commit is contained in:
Dan Banner 2017-05-01 11:38:39 +01:00
Родитель fe285a1f9e
Коммит c07b5f8b23
11 изменённых файлов: 60 добавлений и 54 удалений

11
tools/.eslintrc.js Normal file
Просмотреть файл

@ -0,0 +1,11 @@
"use strict";
module.exports = {
extends: [
"plugin:mozilla/recommended"
],
plugins: [
"mozilla"
]
}

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

@ -21,8 +21,7 @@ function runfile(file) {
var result = "Results of processing log " + file.fileName + " :\n";
var fileReader = new FileReader();
fileReader.onload = function(e)
{
fileReader.onload = function(e) {
runContents(result, e.target.result);
}
fileReader.readAsText(file, "iso-8859-1");
@ -36,14 +35,14 @@ function runContents(result, contents) {
"DOMWINDOW": {
count: 0,
windows: {},
handle_line: function(line) {
handle_line(line) {
var match = line.match(/^([0-9a-f]*) (\S*)(.*)/);
if (match) {
var addr = match[1];
var verb = match[2];
var rest = match[3];
if (verb == "created") {
var m = rest.match(/ outer=([0-9a-f]*)$/);
let m = rest.match(/ outer=([0-9a-f]*)$/);
if (!m)
throw "outer expected";
this.windows[addr] = { outer: m[1] };
@ -51,14 +50,14 @@ function runContents(result, contents) {
} else if (verb == "destroyed") {
delete this.windows[addr];
} else if (verb == "SetNewDocument") {
var m = rest.match(/^ (.*)$/);
let m = rest.match(/^ (.*)$/);
if (!m)
throw "URI expected";
this.windows[addr][m[1]] = true;
}
}
},
dump: function() {
dump() {
for (var addr in this.windows) {
var winobj = this.windows[addr];
var outer = winobj.outer;
@ -72,18 +71,15 @@ function runContents(result, contents) {
}
}
},
summary: function() {
var len = 0;
for (var w in this.windows)
++len;
result += 'Leaked ' + len + ' out of ' +
summary() {
result += "Leaked " + Object.keys(this.windows).length + " out of " +
this.count + " DOM Windows\n";
}
},
"DOCUMENT": {
count: 0,
docs: {},
handle_line: function(line) {
handle_line(line) {
var match = line.match(/^([0-9a-f]*) (\S*)(.*)/);
if (match) {
var addr = match[1];
@ -108,7 +104,7 @@ function runContents(result, contents) {
}
}
},
dump: function() {
dump() {
for (var addr in this.docs) {
var doc = this.docs[addr];
result += "Leaked document at address " + addr + ".\n";
@ -119,18 +115,15 @@ function runContents(result, contents) {
}
}
},
summary: function() {
var len = 0;
for (var w in this.docs)
++len;
result += 'Leaked ' + len + ' out of ' +
summary() {
result += "Leaked " + Object.keys(this.docs).length + " out of " +
this.count + " documents\n";
}
},
"DOCSHELL": {
count: 0,
shells: {},
handle_line: function(line) {
handle_line(line) {
var match = line.match(/^([0-9a-f]*) (\S*)(.*)/);
if (match) {
var addr = match[1];
@ -150,7 +143,7 @@ function runContents(result, contents) {
}
}
},
dump: function() {
dump() {
for (var addr in this.shells) {
var doc = this.shells[addr];
result += "Leaked docshell at address " + addr + ".\n";
@ -159,18 +152,15 @@ function runContents(result, contents) {
}
}
},
summary: function() {
var len = 0;
for (var w in this.shells)
++len;
result += 'Leaked ' + len + ' out of ' +
summary() {
result += "Leaked " + Object.keys(this.shells).length + " out of " +
this.count + " docshells\n";
}
},
"NODEINFOMANAGER": {
count: 0,
nims: {},
handle_line: function(line) {
handle_line(line) {
var match = line.match(/^([0-9a-f]*) (\S*)(.*)/);
if (match) {
var addr = match[1];
@ -197,7 +187,7 @@ function runContents(result, contents) {
}
}
},
dump: function() {
dump() {
for (var addr in this.nims) {
var nim = this.nims[addr];
result += "Leaked content nodes associated with node info manager at address " + addr + ".\n";
@ -206,11 +196,8 @@ function runContents(result, contents) {
}
}
},
summary: function() {
var len = 0;
for (var w in this.nims)
++len;
result += 'Leaked content nodes in ' + len + ' out of ' +
summary() {
result += "Leaked content nodes in " + Object.keys(this.nims).length + " out of " +
this.count + " documents\n";
}
}
@ -223,7 +210,7 @@ function runContents(result, contents) {
// first word and rest
var matches = line.match(/^\-?[0-9]*\[[0-9a-f]*\]: (\S*) (.*)$/);
if (matches) {
var handler = matches[1];
let handler = matches[1];
var data = matches[2];
if (typeof(handlers[handler]) != "undefined") {
handlers[handler].handle_line(data);
@ -231,12 +218,12 @@ function runContents(result, contents) {
}
}
for (var handler in handlers)
for (let handler in handlers)
handlers[handler].dump();
if (result.length)
result += "\n";
result += "Summary:\n";
for (var handler in handlers)
for (let handler in handlers)
handlers[handler].summary();
result += "\n";

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

@ -0,0 +1,7 @@
"use strict";
module.exports = {
"extends": [
"plugin:mozilla/xpcshell-test"
]
};

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

@ -22,11 +22,13 @@ function run_test() {
p.StartProfiler(10000, ms, ["js"], 1);
let stack = null;
function ffi_function(){
function ffi_function() {
var delayMS = 5;
while (1) {
let then = Date.now();
do {} while (Date.now() - then < delayMS);
do {
// do nothing
} while (Date.now() - then < delayMS);
var thread0 = p.getProfileData().threads[0];
@ -56,7 +58,7 @@ function run_test() {
do_check_true(jsFuns.isAsmJSModule(asmjs_module));
var asmjs_function = asmjs_module(null, {ffi:ffi_function});
var asmjs_function = asmjs_module(null, {ffi: ffi_function});
do_check_true(jsFuns.isAsmJSFunction(asmjs_function));
asmjs_function();

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

@ -18,7 +18,7 @@ function run_test() {
const ms = 5;
p.StartProfiler(100, ms, ["js"], 1);
function arbitrary_name(){
function arbitrary_name() {
// A frame for |arbitrary_name| has been pushed. Do a sequence of
// increasingly long spins until we get a sample.
var delayMS = 5;
@ -35,7 +35,7 @@ function run_test() {
return pr;
delayMS *= 2;
}
};
}
var profile = arbitrary_name();

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

@ -11,7 +11,7 @@ function run_test() {
p.StartProfiler(100, 10, ["js"], 1);
// The function is entered with the profiler enabled
(function (){
(function() {
p.StopProfiler();
let n = 10000;
while (--n); // OSR happens here with the profiler disabled.

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

@ -10,7 +10,7 @@ function run_test() {
do_check_true(!p.IsActive());
// The function is entered with the profiler disabled.
(function (){
(function() {
p.StartProfiler(100, 10, ["js"], 1);
let n = 10000;
while (--n); // OSR happens here with the profiler enabled.

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

@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function run_test() {
// If we can't get the profiler component then assume gecko was
// built without it and pass all the tests

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

@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function run_test() {
// If we can't get the profiler component then assume gecko was
// built without it and pass all the tests

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

@ -21,8 +21,7 @@ QuitterObserver.prototype = {
_xpcom_categories: [{category: "profile-after-change", service: true }],
isFrameScriptLoaded: false,
observe: function(aSubject, aTopic, aData)
{
observe(aSubject, aTopic, aData) {
if (aTopic == "profile-after-change") {
this.init();
} else if (!this.isFrameScriptLoaded &&
@ -40,15 +39,13 @@ QuitterObserver.prototype = {
}
},
init: function()
{
init() {
var obs = Services.obs;
obs.addObserver(this, "xpcom-shutdown");
obs.addObserver(this, "chrome-document-global-created");
},
uninit: function()
{
uninit() {
var obs = Services.obs;
obs.removeObserver(this, "chrome-document-global-created");
},
@ -57,8 +54,8 @@ QuitterObserver.prototype = {
* messageManager callback function
* This will get requests from our API in the window and process them in chrome for it
**/
receiveMessage: function(aMessage) {
switch(aMessage.name) {
receiveMessage(aMessage) {
switch (aMessage.name) {
case "Quitter.Quit":
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
appStartup.quit(Ci.nsIAppStartup.eForceQuit);

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

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-env mozilla/frame-script */
var Ci = Components.interfaces;
var Cc = Components.classes;
var Cu = Components.utils;
@ -10,8 +12,8 @@ function Quitter() {
}
Quitter.prototype = {
toString: function() { return "[Quitter]"; },
quit: function() { sendSyncMessage('Quitter.Quit', {}); }
toString() { return "[Quitter]"; },
quit() { sendSyncMessage("Quitter.Quit", {}); }
};
// This is a frame script, so it may be running in a content process.