зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1613867 - Enable ESLint on testing/xpcshell/moz-http2/ (manual changes). r=dragana
Differential Revision: https://phabricator.services.mozilla.com/D62017 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
389bc795fe
Коммит
0a71a3d8ce
|
@ -190,6 +190,7 @@ testing/mochitest/tests/SimpleTest/
|
||||||
# octothorpe used for pref file comment causes parsing error
|
# octothorpe used for pref file comment causes parsing error
|
||||||
testing/mozbase/mozprofile/tests/files/prefs_with_comments.js
|
testing/mozbase/mozprofile/tests/files/prefs_with_comments.js
|
||||||
|
|
||||||
|
# Test files that we don't want to lint.
|
||||||
testing/talos/talos/scripts/jszip.min.js
|
testing/talos/talos/scripts/jszip.min.js
|
||||||
testing/talos/talos/startup_test/sessionrestore/profile/sessionstore.js
|
testing/talos/talos/startup_test/sessionrestore/profile/sessionstore.js
|
||||||
testing/talos/talos/startup_test/sessionrestore/profile-manywindows/sessionstore.js
|
testing/talos/talos/startup_test/sessionrestore/profile-manywindows/sessionstore.js
|
||||||
|
@ -199,7 +200,6 @@ testing/talos/talos/tests/tp5n/
|
||||||
testing/talos/talos/fis/tp5n/
|
testing/talos/talos/fis/tp5n/
|
||||||
|
|
||||||
testing/web-platform/
|
testing/web-platform/
|
||||||
testing/xpcshell/moz-http2/
|
|
||||||
|
|
||||||
# toolkit/ exclusions
|
# toolkit/ exclusions
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* eslint-env node */
|
||||||
|
|
||||||
function sendBackResponse(evalResult, e) {
|
function sendBackResponse(evalResult, e) {
|
||||||
const output = { result: evalResult, error: "", errorStack: "" };
|
const output = { result: evalResult, error: "", errorStack: "" };
|
||||||
if (e) {
|
if (e) {
|
||||||
|
@ -11,6 +13,7 @@ process.on("message", msg => {
|
||||||
const code = msg.code;
|
const code = msg.code;
|
||||||
let evalResult = null;
|
let evalResult = null;
|
||||||
try {
|
try {
|
||||||
|
// eslint-disable-next-line no-eval
|
||||||
evalResult = eval(code);
|
evalResult = eval(code);
|
||||||
if (evalResult instanceof Promise) {
|
if (evalResult instanceof Promise) {
|
||||||
evalResult
|
evalResult
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
// This module is the stateful server side of test_http2.js and is meant
|
// This module is the stateful server side of test_http2.js and is meant
|
||||||
// to have node be restarted in between each invocation
|
// to have node be restarted in between each invocation
|
||||||
|
|
||||||
|
/* eslint-env node */
|
||||||
|
|
||||||
var node_http2_root = "../node-http2";
|
var node_http2_root = "../node-http2";
|
||||||
if (process.env.NODE_HTTP2_ROOT) {
|
if (process.env.NODE_HTTP2_ROOT) {
|
||||||
node_http2_root = process.env.NODE_HTTP2_ROOT;
|
node_http2_root = process.env.NODE_HTTP2_ROOT;
|
||||||
}
|
}
|
||||||
var http2 = require(node_http2_root);
|
var http2 = require(node_http2_root);
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var net = require("net");
|
|
||||||
var url = require("url");
|
var url = require("url");
|
||||||
var crypto = require("crypto");
|
var crypto = require("crypto");
|
||||||
const dnsPacket = require(`${node_http2_root}/../dns-packet`);
|
const dnsPacket = require(`${node_http2_root}/../dns-packet`);
|
||||||
|
@ -19,13 +20,6 @@ const ip = require(`${node_http2_root}/../node-ip`);
|
||||||
const { fork } = require("child_process");
|
const { fork } = require("child_process");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
let http2_internal = null;
|
|
||||||
try {
|
|
||||||
http2_internal = require("http2");
|
|
||||||
} catch (_) {
|
|
||||||
// silently ignored
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hook into the decompression code to log the decompressed name-value pairs
|
// Hook into the decompression code to log the decompressed name-value pairs
|
||||||
var compression_module = node_http2_root + "/lib/protocol/compressor";
|
var compression_module = node_http2_root + "/lib/protocol/compressor";
|
||||||
var http2_compression = require(compression_module);
|
var http2_compression = require(compression_module);
|
||||||
|
@ -64,7 +58,7 @@ var originalTransform = Serializer.prototype._transform;
|
||||||
var newTransform = function(frame, encoding, done) {
|
var newTransform = function(frame, encoding, done) {
|
||||||
if (frame.type == "DATA") {
|
if (frame.type == "DATA") {
|
||||||
// Insert our empty DATA frame
|
// Insert our empty DATA frame
|
||||||
emptyFrame = {};
|
const emptyFrame = {};
|
||||||
emptyFrame.type = "DATA";
|
emptyFrame.type = "DATA";
|
||||||
emptyFrame.data = Buffer.alloc(0);
|
emptyFrame.data = Buffer.alloc(0);
|
||||||
emptyFrame.flags = [];
|
emptyFrame.flags = [];
|
||||||
|
@ -82,14 +76,14 @@ var newTransform = function(frame, encoding, done) {
|
||||||
originalTransform.apply(this, arguments);
|
originalTransform.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
function getHttpContent(path) {
|
function getHttpContent(pathName) {
|
||||||
var content =
|
var content =
|
||||||
"<!doctype html>" +
|
"<!doctype html>" +
|
||||||
"<html>" +
|
"<html>" +
|
||||||
"<head><title>HOORAY!</title></head>" +
|
"<head><title>HOORAY!</title></head>" +
|
||||||
// 'You Win!' used in tests to check we reached this server
|
// 'You Win!' used in tests to check we reached this server
|
||||||
"<body>You Win! (by requesting" +
|
"<body>You Win! (by requesting" +
|
||||||
path +
|
pathName +
|
||||||
")</body>" +
|
")</body>" +
|
||||||
"</html>";
|
"</html>";
|
||||||
return content;
|
return content;
|
||||||
|
@ -152,7 +146,7 @@ moreData.prototype = {
|
||||||
|
|
||||||
onTimeout: function onTimeout() {
|
onTimeout: function onTimeout() {
|
||||||
// 1mb of data
|
// 1mb of data
|
||||||
content = generateContent(1024 * 1024);
|
const content = generateContent(1024 * 1024);
|
||||||
this.resp.write(content); // 1mb chunk
|
this.resp.write(content); // 1mb chunk
|
||||||
this.iter--;
|
this.iter--;
|
||||||
if (!this.iter) {
|
if (!this.iter) {
|
||||||
|
@ -234,6 +228,7 @@ var illegalheader_conn = null;
|
||||||
|
|
||||||
var cname_confirm = 0;
|
var cname_confirm = 0;
|
||||||
|
|
||||||
|
// eslint-disable-next-line complexity
|
||||||
function handleRequest(req, res) {
|
function handleRequest(req, res) {
|
||||||
// We do this first to ensure nothing goes wonky in our tests that don't want
|
// We do this first to ensure nothing goes wonky in our tests that don't want
|
||||||
// the headers to have something illegal in them
|
// the headers to have something illegal in them
|
||||||
|
@ -262,7 +257,7 @@ function handleRequest(req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u.pathname === "/750ms") {
|
if (u.pathname === "/750ms") {
|
||||||
var rl = new runlater();
|
let rl = new runlater();
|
||||||
rl.req = req;
|
rl.req = req;
|
||||||
rl.resp = res;
|
rl.resp = res;
|
||||||
setTimeout(executeRunLater, 750, rl);
|
setTimeout(executeRunLater, 750, rl);
|
||||||
|
@ -395,14 +390,14 @@ function handleRequest(req, res) {
|
||||||
content = generateContent(128 * 1024);
|
content = generateContent(128 * 1024);
|
||||||
var hash = crypto.createHash("md5");
|
var hash = crypto.createHash("md5");
|
||||||
hash.update(content);
|
hash.update(content);
|
||||||
var md5 = hash.digest("hex");
|
let md5 = hash.digest("hex");
|
||||||
res.setHeader("X-Expected-MD5", md5);
|
res.setHeader("X-Expected-MD5", md5);
|
||||||
} else if (u.pathname === "/huge") {
|
} else if (u.pathname === "/huge") {
|
||||||
content = generateContent(1024);
|
content = generateContent(1024);
|
||||||
res.setHeader("Content-Type", "text/plain");
|
res.setHeader("Content-Type", "text/plain");
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
// 1mb of data
|
// 1mb of data
|
||||||
for (var i = 0; i < 1024 * 1; i++) {
|
for (let i = 0; i < 1024 * 1; i++) {
|
||||||
res.write(content); // 1kb chunk
|
res.write(content); // 1kb chunk
|
||||||
}
|
}
|
||||||
res.end();
|
res.end();
|
||||||
|
@ -419,7 +414,7 @@ function handleRequest(req, res) {
|
||||||
post_hash.update(chunk.toString());
|
post_hash.update(chunk.toString());
|
||||||
});
|
});
|
||||||
req.on("end", function finishPost() {
|
req.on("end", function finishPost() {
|
||||||
var md5 = post_hash.digest("hex");
|
let md5 = post_hash.digest("hex");
|
||||||
res.setHeader("X-Calculated-MD5", md5);
|
res.setHeader("X-Calculated-MD5", md5);
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.end(content);
|
res.end(content);
|
||||||
|
@ -439,7 +434,7 @@ function handleRequest(req, res) {
|
||||||
});
|
});
|
||||||
req.on("end", function finishPost() {
|
req.on("end", function finishPost() {
|
||||||
res.setHeader("X-Recvd", accum);
|
res.setHeader("X-Recvd", accum);
|
||||||
var rl = new runlater();
|
let rl = new runlater();
|
||||||
rl.req = req;
|
rl.req = req;
|
||||||
rl.resp = res;
|
rl.resp = res;
|
||||||
setTimeout(executeRunLater, 750, rl);
|
setTimeout(executeRunLater, 750, rl);
|
||||||
|
@ -456,7 +451,7 @@ function handleRequest(req, res) {
|
||||||
res.setHeader("Content-Type", "text/html");
|
res.setHeader("Content-Type", "text/html");
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
|
|
||||||
var rl = new moreData();
|
let rl = new moreData();
|
||||||
rl.req = req;
|
rl.req = req;
|
||||||
rl.resp = res;
|
rl.resp = res;
|
||||||
setTimeout(executeRunLater, 1, rl);
|
setTimeout(executeRunLater, 1, rl);
|
||||||
|
@ -504,7 +499,7 @@ function handleRequest(req, res) {
|
||||||
.split("")
|
.split("")
|
||||||
.reverse()
|
.reverse()
|
||||||
.join("");
|
.join("");
|
||||||
for (var i = 0; i < 265; i++) {
|
for (let i = 0; i < 265; i++) {
|
||||||
pushRequestHeaders["X-Push-Test-Header-" + i] = pushHdrTxt;
|
pushRequestHeaders["X-Push-Test-Header-" + i] = pushHdrTxt;
|
||||||
res.setHeader("X-Pull-Test-Header-" + i, pullHdrTxt);
|
res.setHeader("X-Pull-Test-Header-" + i, pullHdrTxt);
|
||||||
}
|
}
|
||||||
|
@ -555,25 +550,25 @@ function handleRequest(req, res) {
|
||||||
// for use with test_trr.js
|
// for use with test_trr.js
|
||||||
else if (u.pathname === "/dns-cname") {
|
else if (u.pathname === "/dns-cname") {
|
||||||
// asking for cname.example.com
|
// asking for cname.example.com
|
||||||
var content;
|
let rContent;
|
||||||
if (0 == cname_confirm) {
|
if (0 == cname_confirm) {
|
||||||
// ... this sends a CNAME back to pointing-elsewhere.example.com
|
// ... this sends a CNAME back to pointing-elsewhere.example.com
|
||||||
content = Buffer.from(
|
rContent = Buffer.from(
|
||||||
"00000100000100010000000005636E616D65076578616D706C6503636F6D0000050001C00C0005000100000037002012706F696E74696E672D656C73657768657265076578616D706C6503636F6D00",
|
"00000100000100010000000005636E616D65076578616D706C6503636F6D0000050001C00C0005000100000037002012706F696E74696E672D656C73657768657265076578616D706C6503636F6D00",
|
||||||
"hex"
|
"hex"
|
||||||
);
|
);
|
||||||
cname_confirm++;
|
cname_confirm++;
|
||||||
} else {
|
} else {
|
||||||
// ... this sends an A 99.88.77.66 entry back for pointing-elsewhere.example.com
|
// ... this sends an A 99.88.77.66 entry back for pointing-elsewhere.example.com
|
||||||
content = Buffer.from(
|
rContent = Buffer.from(
|
||||||
"00000100000100010000000012706F696E74696E672D656C73657768657265076578616D706C6503636F6D0000010001C00C0001000100000037000463584D42",
|
"00000100000100010000000012706F696E74696E672D656C73657768657265076578616D706C6503636F6D0000010001C00C0001000100000037000463584D42",
|
||||||
"hex"
|
"hex"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
res.setHeader("Content-Type", "application/dns-message");
|
res.setHeader("Content-Type", "application/dns-message");
|
||||||
res.setHeader("Content-Length", content.length);
|
res.setHeader("Content-Length", rContent.length);
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.write(content);
|
res.write(rContent);
|
||||||
res.end("");
|
res.end("");
|
||||||
return;
|
return;
|
||||||
} else if (u.pathname == "/doh") {
|
} else if (u.pathname == "/doh") {
|
||||||
|
@ -713,16 +708,13 @@ function handleRequest(req, res) {
|
||||||
answers,
|
answers,
|
||||||
});
|
});
|
||||||
|
|
||||||
function writeResponse(response, buf) {
|
function writeResponse(resp, buffer) {
|
||||||
response.setHeader("Content-Length", buf.length);
|
resp.setHeader("Content-Length", buffer.length);
|
||||||
response.setHeader(
|
resp.setHeader("Set-Cookie", "trackyou=yes; path=/; max-age=100000;");
|
||||||
"Set-Cookie",
|
resp.setHeader("Content-Type", "application/dns-message");
|
||||||
"trackyou=yes; path=/; max-age=100000;"
|
resp.writeHead(200);
|
||||||
);
|
resp.write(buffer);
|
||||||
response.setHeader("Content-Type", "application/dns-message");
|
resp.end("");
|
||||||
response.writeHead(200);
|
|
||||||
response.write(buf);
|
|
||||||
response.end("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let delay = undefined;
|
let delay = undefined;
|
||||||
|
@ -763,9 +755,9 @@ function handleRequest(req, res) {
|
||||||
// test23 asks for cname-a.example.com
|
// test23 asks for cname-a.example.com
|
||||||
// this responds with a CNAME to here.example.com *and* an A record
|
// this responds with a CNAME to here.example.com *and* an A record
|
||||||
// for here.example.com
|
// for here.example.com
|
||||||
var content;
|
let rContent;
|
||||||
|
|
||||||
content = Buffer.from(
|
rContent = Buffer.from(
|
||||||
"0000" +
|
"0000" +
|
||||||
"0100" +
|
"0100" +
|
||||||
"0001" + // QDCOUNT
|
"0001" + // QDCOUNT
|
||||||
|
@ -793,9 +785,9 @@ function handleRequest(req, res) {
|
||||||
"hex"
|
"hex"
|
||||||
);
|
);
|
||||||
res.setHeader("Content-Type", "application/dns-message");
|
res.setHeader("Content-Type", "application/dns-message");
|
||||||
res.setHeader("Content-Length", content.length);
|
res.setHeader("Content-Length", rContent.length);
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.write(content);
|
res.write(rContent);
|
||||||
res.end("");
|
res.end("");
|
||||||
return;
|
return;
|
||||||
} else if (u.pathname === "/dns-750ms") {
|
} else if (u.pathname === "/dns-750ms") {
|
||||||
|
@ -832,7 +824,7 @@ function handleRequest(req, res) {
|
||||||
// for use with test_esni_dns_fetch.js
|
// for use with test_esni_dns_fetch.js
|
||||||
else if (u.pathname === "/esni-dns-push") {
|
else if (u.pathname === "/esni-dns-push") {
|
||||||
// _esni_push.example.com has A entry 127.0.0.1
|
// _esni_push.example.com has A entry 127.0.0.1
|
||||||
var content = Buffer.from(
|
let rContent = Buffer.from(
|
||||||
"0000010000010001000000000A5F65736E695F70757368076578616D706C6503636F6D0000010001C00C000100010000003700047F000001",
|
"0000010000010001000000000A5F65736E695F70757368076578616D706C6503636F6D0000010001C00C000100010000003700047F000001",
|
||||||
"hex"
|
"hex"
|
||||||
);
|
);
|
||||||
|
@ -861,9 +853,9 @@ function handleRequest(req, res) {
|
||||||
});
|
});
|
||||||
push.end(pcontent);
|
push.end(pcontent);
|
||||||
res.setHeader("Content-Type", "application/dns-message");
|
res.setHeader("Content-Type", "application/dns-message");
|
||||||
res.setHeader("Content-Length", content.length);
|
res.setHeader("Content-Length", rContent.length);
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
res.write(content);
|
res.write(rContent);
|
||||||
res.end("");
|
res.end("");
|
||||||
return;
|
return;
|
||||||
} else if (u.pathname === "/.well-known/http-opportunistic") {
|
} else if (u.pathname === "/.well-known/http-opportunistic") {
|
||||||
|
@ -1099,11 +1091,11 @@ function handleRequest(req, res) {
|
||||||
}
|
}
|
||||||
// default response from here
|
// default response from here
|
||||||
} else if (u.pathname === "/origin-4") {
|
} else if (u.pathname === "/origin-4") {
|
||||||
var originList = [];
|
let originList = [];
|
||||||
req.stream.connection.originFrame(originList);
|
req.stream.connection.originFrame(originList);
|
||||||
res.setHeader("x-client-port", req.remotePort);
|
res.setHeader("x-client-port", req.remotePort);
|
||||||
} else if (u.pathname === "/origin-6") {
|
} else if (u.pathname === "/origin-6") {
|
||||||
var originList = [
|
let originList = [
|
||||||
"https://alt1.example.com:" + serverPort,
|
"https://alt1.example.com:" + serverPort,
|
||||||
"https://alt2.example.com:" + serverPort,
|
"https://alt2.example.com:" + serverPort,
|
||||||
"https://bar.example.com:" + serverPort,
|
"https://bar.example.com:" + serverPort,
|
||||||
|
@ -1113,7 +1105,7 @@ function handleRequest(req, res) {
|
||||||
} else if (u.pathname === "/origin-11-a") {
|
} else if (u.pathname === "/origin-11-a") {
|
||||||
res.setHeader("x-client-port", req.remotePort);
|
res.setHeader("x-client-port", req.remotePort);
|
||||||
|
|
||||||
pushb = res.push({
|
const pushb = res.push({
|
||||||
hostname: "foo.example.com:" + serverPort,
|
hostname: "foo.example.com:" + serverPort,
|
||||||
port: serverPort,
|
port: serverPort,
|
||||||
path: "/origin-11-b",
|
path: "/origin-11-b",
|
||||||
|
@ -1126,7 +1118,7 @@ function handleRequest(req, res) {
|
||||||
});
|
});
|
||||||
pushb.end("1");
|
pushb.end("1");
|
||||||
|
|
||||||
pushc = res.push({
|
const pushc = res.push({
|
||||||
hostname: "bar.example.com:" + serverPort,
|
hostname: "bar.example.com:" + serverPort,
|
||||||
port: serverPort,
|
port: serverPort,
|
||||||
path: "/origin-11-c",
|
path: "/origin-11-c",
|
||||||
|
@ -1139,7 +1131,7 @@ function handleRequest(req, res) {
|
||||||
});
|
});
|
||||||
pushc.end("1");
|
pushc.end("1");
|
||||||
|
|
||||||
pushd = res.push({
|
const pushd = res.push({
|
||||||
hostname: "madeup.example.com:" + serverPort,
|
hostname: "madeup.example.com:" + serverPort,
|
||||||
port: serverPort,
|
port: serverPort,
|
||||||
path: "/origin-11-d",
|
path: "/origin-11-d",
|
||||||
|
@ -1152,7 +1144,7 @@ function handleRequest(req, res) {
|
||||||
});
|
});
|
||||||
pushd.end("1");
|
pushd.end("1");
|
||||||
|
|
||||||
pushe = res.push({
|
const pushe = res.push({
|
||||||
hostname: "alt1.example.com:" + serverPort,
|
hostname: "alt1.example.com:" + serverPort,
|
||||||
port: serverPort,
|
port: serverPort,
|
||||||
path: "/origin-11-e",
|
path: "/origin-11-e",
|
||||||
|
@ -1269,8 +1261,8 @@ function makeid(length) {
|
||||||
let globalObjects = {};
|
let globalObjects = {};
|
||||||
var serverPort;
|
var serverPort;
|
||||||
|
|
||||||
const listen = (server, envport) => {
|
const listen = (serv, envport) => {
|
||||||
if (!server) {
|
if (!serv) {
|
||||||
return Promise.resolve(0);
|
return Promise.resolve(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1283,8 +1275,8 @@ const listen = (server, envport) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
server.listen(portSelection, "0.0.0.0", 2000, () => {
|
serv.listen(portSelection, "0.0.0.0", 2000, () => {
|
||||||
resolve(server.address().port);
|
resolve(serv.address().port);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -1437,6 +1429,6 @@ function forkProcess() {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
listen(server, process.env.MOZHTTP2_PORT).then(port => (serverPort = port)),
|
listen(server, process.env.MOZHTTP2_PORT).then(port => (serverPort = port)),
|
||||||
listen(httpServer, process.env.MOZNODE_EXEC_PORT),
|
listen(httpServer, process.env.MOZNODE_EXEC_PORT),
|
||||||
]).then(([serverPort, nodeExecPort]) => {
|
]).then(([sPort, nodeExecPort]) => {
|
||||||
console.log(`HTTP2 server listening on ports ${serverPort},${nodeExecPort}`);
|
console.log(`HTTP2 server listening on ports ${sPort},${nodeExecPort}`);
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче