Skip to content

Commit

Permalink
Bug 1850244 - Fix remaining ESLint no-shadow issues in netwerk/test. …
Browse files Browse the repository at this point in the history
…r=necko-reviewers,kershaw

Differential Revision: https://phabricator.services.mozilla.com/D186880
  • Loading branch information
Standard8 committed Aug 28, 2023
1 parent 1f31fc9 commit 4c0d604
Show file tree
Hide file tree
Showing 46 changed files with 224 additions and 267 deletions.
6 changes: 0 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,6 @@ module.exports = {
...testPaths.chrome.map(path => `${path}/**/*.js`),
],
},
{
files: ["netwerk/test/mochitests/**", "netwerk/test/unit*/**"],
rules: {
"no-shadow": "warn",
},
},
{
// Bug 877389 - Gradually migrate from Cu.reportError to console.error.
// Enable these as we fix more areas.
Expand Down
22 changes: 11 additions & 11 deletions netwerk/test/unit/head_trr.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ function trrQueryHandler(req, resp, url) {
resp.end("Unexpected method");
}

function processRequest(req, resp, payload) {
function processRequest(req1, resp1, payload) {
let dnsQuery = global.dnsPacket.decode(payload);
let domain = dnsQuery.questions[0].name;
let type = dnsQuery.questions[0].type;
Expand All @@ -387,24 +387,24 @@ function trrQueryHandler(req, resp, url) {
additionals: response.additionals || [],
});

let writeResponse = (resp, buf, context) => {
let writeResponse = (resp2, buf2, context) => {
try {
if (context.error) {
// If the error is a valid HTTP response number just write it out.
if (context.error < 600) {
resp.writeHead(context.error);
resp.end("Intentional error");
resp2.writeHead(context.error);
resp2.end("Intentional error");
return;
}

// Bigger error means force close the session
req.stream.session.close();
req1.stream.session.close();
return;
}
resp.setHeader("Content-Length", buf.length);
resp.writeHead(200, { "Content-Type": "application/dns-message" });
resp.write(buf);
resp.end("");
resp2.setHeader("Content-Length", buf2.length);
resp2.writeHead(200, { "Content-Type": "application/dns-message" });
resp2.write(buf2);
resp2.end("");
} catch (e) {}
};

Expand All @@ -417,12 +417,12 @@ function trrQueryHandler(req, resp, url) {
writeResponse(arg[0], arg[1], arg[2]);
},
response.delay,
[resp, buf, response]
[resp1, buf, response]
);
return;
}

writeResponse(resp, buf, response);
writeResponse(resp1, buf, response);
}
}

Expand Down
4 changes: 2 additions & 2 deletions netwerk/test/unit/test_backgroundfilesaver.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ function promiseVerifyContents(aFile, aExpectedContents) {
function promiseSaverComplete(aSaver, aOnTargetChangeFn) {
return new Promise((resolve, reject) => {
aSaver.observer = {
onTargetChange: function BFSO_onSaveComplete(aSaver, aTarget) {
onTargetChange: function BFSO_onSaveComplete(saver, aTarget) {
if (aOnTargetChangeFn) {
aOnTargetChangeFn(aTarget);
}
},
onSaveComplete: function BFSO_onSaveComplete(aSaver, aStatus) {
onSaveComplete: function BFSO_onSaveComplete(saver, aStatus) {
if (Components.isSuccessCode(aStatus)) {
resolve();
} else {
Expand Down
8 changes: 4 additions & 4 deletions netwerk/test/unit/test_cache2-01d-basic-not-wanted.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW, "a1m", "a1d", function (entry) {
new OpenCallback(NEW, "a1m", "a1d", function () {
// Open for read and check
asyncOpenCacheEntry(
"http://a/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NORMAL, "a1m", "a1d", function (entry) {
new OpenCallback(NORMAL, "a1m", "a1d", function () {
// Open but don't want the entry
asyncOpenCacheEntry(
"http://a/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NOTWANTED, "a1m", "a1d", function (entry) {
new OpenCallback(NOTWANTED, "a1m", "a1d", function () {
// Open for read again and check the entry is OK
asyncOpenCacheEntry(
"http://a/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NORMAL, "a1m", "a1d", function (entry) {
new OpenCallback(NORMAL, "a1m", "a1d", function () {
finish_cache2_test();
})
);
Expand Down
4 changes: 2 additions & 2 deletions netwerk/test/unit/test_cache2-01e-basic-bypass-if-busy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW | DONTFILL, "a1m", "a1d", function (entry) {
new OpenCallback(NEW | DONTFILL, "a1m", "a1d", function () {
var bypassed = false;

// Open and bypass
Expand All @@ -18,7 +18,7 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_BYPASS_IF_BUSY,
null,
new OpenCallback(NOTFOUND, "", "", function (entry) {
new OpenCallback(NOTFOUND, "", "", function () {
Assert.ok(!bypassed);
bypassed = true;
})
Expand Down
8 changes: 4 additions & 4 deletions netwerk/test/unit/test_cache2-02-open-non-existing.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_READONLY,
null,
new OpenCallback(NOTFOUND, null, null, function (entry) {
new OpenCallback(NOTFOUND, null, null, function () {
// Open the same non-existing for read again, should fail second time
asyncOpenCacheEntry(
"http://b/",
"disk",
Ci.nsICacheStorage.OPEN_READONLY,
null,
new OpenCallback(NOTFOUND, null, null, function (entry) {
new OpenCallback(NOTFOUND, null, null, function () {
// Try it again normally, should go
asyncOpenCacheEntry(
"http://b/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW, "b1m", "b1d", function (entry) {
new OpenCallback(NEW, "b1m", "b1d", function () {
// ...and check
asyncOpenCacheEntry(
"http://b/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NORMAL, "b1m", "b1d", function (entry) {
new OpenCallback(NORMAL, "b1m", "b1d", function () {
finish_cache2_test();
})
);
Expand Down
6 changes: 3 additions & 3 deletions netwerk/test/unit/test_cache2-03-oncacheentryavail-throws.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW | THROWAVAIL, null, null, function (entry) {
new OpenCallback(NEW | THROWAVAIL, null, null, function () {
// Try it again, should go
asyncOpenCacheEntry(
"http://c/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW, "c1m", "c1d", function (entry) {
new OpenCallback(NEW, "c1m", "c1d", function () {
// ...and check
asyncOpenCacheEntry(
"http://c/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(false, "c1m", "c1d", function (entry) {
new OpenCallback(false, "c1m", "c1d", function () {
finish_cache2_test();
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW | THROWAVAIL, null, null, function (entry) {
new OpenCallback(NEW | THROWAVAIL, null, null, function () {
// Open but let OCEA throw ones again
asyncOpenCacheEntry(
"http://d/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW | THROWAVAIL, null, null, function (entry) {
new OpenCallback(NEW | THROWAVAIL, null, null, function () {
// Try it again, should go
asyncOpenCacheEntry(
"http://d/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW, "d1m", "d1d", function (entry) {
new OpenCallback(NEW, "d1m", "d1d", function () {
// ...and check
asyncOpenCacheEntry(
"http://d/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NORMAL, "d1m", "d1d", function (entry) {
new OpenCallback(NORMAL, "d1m", "d1d", function () {
finish_cache2_test();
})
);
Expand Down
16 changes: 8 additions & 8 deletions netwerk/test/unit/test_cache2-05-visit.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW, "a1m", "a1d", function (entry) {
new OpenCallback(NEW, "a1m", "a1d", function () {
asyncOpenCacheEntry(
"http://a/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NORMAL, "a1m", "a1d", function (entry) {
new OpenCallback(NORMAL, "a1m", "a1d", function () {
mc.fired();
})
);
Expand All @@ -60,13 +60,13 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW, "b1m", "b1d", function (entry) {
new OpenCallback(NEW, "b1m", "b1d", function () {
asyncOpenCacheEntry(
"http://b/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NORMAL, "b1m", "b1d", function (entry) {
new OpenCallback(NORMAL, "b1m", "b1d", function () {
mc.fired();
})
);
Expand All @@ -78,13 +78,13 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW, "c1m", "c1d", function (entry) {
new OpenCallback(NEW, "c1m", "c1d", function () {
asyncOpenCacheEntry(
"http://c/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NORMAL, "c1m", "c1d", function (entry) {
new OpenCallback(NORMAL, "c1m", "c1d", function () {
mc.fired();
})
);
Expand All @@ -96,13 +96,13 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW, "d1m", "d1d", function (entry) {
new OpenCallback(NEW, "d1m", "d1d", function () {
asyncOpenCacheEntry(
"http://d/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NORMAL, "d1m", "d1d", function (entry) {
new OpenCallback(NORMAL, "d1m", "d1d", function () {
mc.fired();
})
);
Expand Down
4 changes: 2 additions & 2 deletions netwerk/test/unit/test_cache2-06-pb-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
Services.loadContextInfo.private,
new OpenCallback(NEW, "p1m", "p1d", function (entry) {
new OpenCallback(NEW, "p1m", "p1d", function () {
asyncOpenCacheEntry(
"http://p1/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
Services.loadContextInfo.private,
new OpenCallback(NORMAL, "p1m", "p1d", function (entry) {
new OpenCallback(NORMAL, "p1m", "p1d", function () {
// Check it's there
syncWithCacheIOThread(function () {
var storage = getCacheStorage(
Expand Down
20 changes: 10 additions & 10 deletions netwerk/test/unit/test_cache2-07-visit-memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ function run_test() {
"memory",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW, "m1m", "m1d", function (entry) {
new OpenCallback(NEW, "m1m", "m1d", function () {
asyncOpenCacheEntry(
"http://mem1/",
"memory",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NORMAL, "m1m", "m1d", function (entry) {
new OpenCallback(NORMAL, "m1m", "m1d", function () {
mc.fired();
})
);
Expand All @@ -52,13 +52,13 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW, "a1m", "a1d", function (entry) {
new OpenCallback(NEW, "a1m", "a1d", function () {
asyncOpenCacheEntry(
"http://a/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NORMAL, "a1m", "a1d", function (entry) {
new OpenCallback(NORMAL, "a1m", "a1d", function () {
mc.fired();
})
);
Expand All @@ -70,13 +70,13 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW, "a1m", "a1d", function (entry) {
new OpenCallback(NEW, "a1m", "a1d", function () {
asyncOpenCacheEntry(
"http://b/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NORMAL, "a1m", "a1d", function (entry) {
new OpenCallback(NORMAL, "a1m", "a1d", function () {
mc.fired();
})
);
Expand All @@ -88,13 +88,13 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW, "a1m", "a1d", function (entry) {
new OpenCallback(NEW, "a1m", "a1d", function () {
asyncOpenCacheEntry(
"http://c/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NORMAL, "a1m", "a1d", function (entry) {
new OpenCallback(NORMAL, "a1m", "a1d", function () {
mc.fired();
})
);
Expand All @@ -106,13 +106,13 @@ function run_test() {
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NEW, "a1m", "a1d", function (entry) {
new OpenCallback(NEW, "a1m", "a1d", function () {
asyncOpenCacheEntry(
"http://d/",
"disk",
Ci.nsICacheStorage.OPEN_NORMALLY,
null,
new OpenCallback(NORMAL, "a1m", "a1d", function (entry) {
new OpenCallback(NORMAL, "a1m", "a1d", function () {
mc.fired();
})
);
Expand Down
Loading

0 comments on commit 4c0d604

Please sign in to comment.