Bug 1783565 - Enable ESLint rule no-redeclare on the rest of netwerk. r=dragana,necko-reviewers

Depends on D153896

Differential Revision: https://phabricator.services.mozilla.com/D153897
This commit is contained in:
Mark Banner 2022-08-08 14:30:34 +00:00
parent 3a58ec0d05
commit 072eb34ade
30 changed files with 139 additions and 140 deletions

View File

@ -238,7 +238,6 @@ module.exports = {
],
rules: {
"no-global-assign": "off",
"no-redeclare": "off",
"no-shadow": "off",
},
},

View File

@ -69,7 +69,7 @@ function pumpReadStream(inputStream, goon) {
Ci.nsIInputStreamPump
);
pump.init(inputStream, 0, 0, true);
var data = "";
let data = "";
pump.asyncRead({
onStartRequest(aRequest) {},
onDataAvailable(aRequest, aInputStream, aOffset, aCount) {
@ -89,7 +89,7 @@ function pumpReadStream(inputStream, goon) {
});
} else {
// blocking stream
var data = read_stream(inputStream, inputStream.available());
let data = read_stream(inputStream, inputStream.available());
goon(data);
}
}
@ -187,7 +187,7 @@ OpenCallback.prototype = {
return;
}
var self = this;
let self = this;
executeSoon(function() {
// emulate network latency
entry.setMetaDataElement("meto", self.workingMetadata);
@ -210,7 +210,7 @@ OpenCallback.prototype = {
if (self.behavior & DOOMED) {
LOG_C2(self, "checking doom state");
try {
var os = entry.openOutputStream(0, -1);
let os = entry.openOutputStream(0, -1);
// Unfortunately, in the undetermined state we cannot even check whether the entry
// is actually doomed or not.
os.close();
@ -226,7 +226,7 @@ OpenCallback.prototype = {
var offset = self.behavior & PARTIAL ? entry.dataSize : 0;
LOG_C2(self, "openOutputStream @ " + offset);
var os = entry.openOutputStream(offset, -1);
let os = entry.openOutputStream(offset, -1);
LOG_C2(self, "writing data");
var wrt = os.write(self.workingData, self.workingData.length);
Assert.equal(wrt, self.workingData.length);
@ -249,7 +249,7 @@ OpenCallback.prototype = {
this.goon(entry, true);
}
var self = this;
let self = this;
pumpReadStream(entry.openInputStream(0), function(data) {
Assert.equal(data, self.workingData);
self.onDataCheckPassed = true;

View File

@ -690,7 +690,7 @@ function do_tests(whichRFC) {
tests[i].length == 3 || whichRFC == 0 ? tests[i][1] : tests[i][3];
try {
var result;
let result;
if (whichRFC == 0) {
result = mhp.getParameter(tests[i][0], "", "UTF-8", true, unused);
@ -715,7 +715,7 @@ function do_tests(whichRFC) {
tests[i].length == 3 || whichRFC == 0 ? tests[i][2] : tests[i][4];
try {
var result;
let result;
if (whichRFC == 0) {
result = mhp.getParameter(

View File

@ -167,7 +167,7 @@ function run_test() {
var xhr;
for (var i = 0; i < tests.length; ++i) {
for (let i = 0; i < tests.length; ++i) {
dump("Testing " + tests[i] + "\n");
xhr = createXHR(
false,
@ -178,7 +178,7 @@ function run_test() {
checkResults(xhr, tests[i][2], tests[i][3], tests[i][4]);
}
for (var i = 0; i < othertests.length; ++i) {
for (let i = 0; i < othertests.length; ++i) {
dump("Testing " + othertests[i] + " (cross-origin)\n");
xhr = createXHR(
false,

View File

@ -53,10 +53,11 @@ function contentHandler(metadata, response) {
response.setHeader("Cache-Control", "no-cache");
response.setHeader("ETag", "test-etag1");
let etag;
try {
var etag = metadata.getHeader("If-None-Match");
etag = metadata.getHeader("If-None-Match");
} catch (ex) {
var etag = "";
etag = "";
}
if (etag == "test-etag1" && shouldPassRevalidation) {

View File

@ -42,10 +42,11 @@ function contentHandler(metadata, response) {
response.setHeader("Cache-Control", "no-cache");
response.setHeader("ETag", "test-etag1");
let etag;
try {
var etag = metadata.getHeader("If-None-Match");
etag = metadata.getHeader("If-None-Match");
} catch (ex) {
var etag = "";
etag = "";
}
if (etag == "test-etag1" && shouldPassRevalidation) {

View File

@ -42,10 +42,11 @@ function contentHandler(metadata, response) {
response.setHeader("Cache-Control", "no-cache");
response.setHeader("ETag", "test-etag1");
let etag;
try {
var etag = metadata.getHeader("If-None-Match");
etag = metadata.getHeader("If-None-Match");
} catch (ex) {
var etag = "";
etag = "";
}
if (etag == "test-etag1" && shouldPassRevalidation) {

View File

@ -65,14 +65,6 @@ registerCleanupFunction(async () => {
await httpserv.stop();
});
function makeChan(url) {
let chan = NetUtil.newChannel({
uri: url,
loadUsingSystemPrincipal: true,
}).QueryInterface(Ci.nsIHttpChannel);
return chan;
}
function channelOpenPromise(chan) {
return new Promise(resolve => {
let topic = "http-on-transaction-suspended-authentication";

View File

@ -110,7 +110,7 @@ function run_test() {
let baseRoot = resProto.resolveURI(Services.io.newURI("resource:///"));
let greRoot = resProto.resolveURI(Services.io.newURI("resource://gre/"));
for (var spec of specs) {
for (let spec of specs) {
check_safe_resolution(spec, rootURI.spec);
check_safe_resolution(
spec.replace("res-test", "res-inexistent"),
@ -120,7 +120,7 @@ function run_test() {
check_safe_resolution(spec.replace("res-test", "gre"), greRoot);
}
for (var spec of error_specs) {
for (let spec of error_specs) {
check_resolution_error(spec);
}
}

View File

@ -42,7 +42,7 @@ function run_test() {
// Make sure our prefs are set such that this test actually means something
var prefs = Services.prefs;
for (var pref of prefData) {
for (let pref of prefData) {
prefs.setBoolPref(pref.name, pref.newVal);
}
@ -58,7 +58,7 @@ function run_test() {
Assert.equal(uri4.displayHost, uri5.displayHost);
Assert.equal(uri4.asciiHost, uri5.asciiHost);
} finally {
for (var pref of prefData) {
for (let pref of prefData) {
if (prefs.prefHasUserValue(pref.name)) {
prefs.clearUserPref(pref.name);
}

View File

@ -53,7 +53,7 @@ var invalid_URIs = [
];
function run_test() {
for (var i = 0; i < valid_URIs.length; i++) {
for (let i = 0; i < valid_URIs.length; i++) {
try {
Services.io.newURI(valid_URIs[i]);
} catch (e) {
@ -61,7 +61,7 @@ function run_test() {
}
}
for (var i = 0; i < invalid_URIs.length; i++) {
for (let i = 0; i < invalid_URIs.length; i++) {
try {
Services.io.newURI(invalid_URIs[i]);
do_throw("should throw: " + invalid_URIs[i]);

View File

@ -370,10 +370,11 @@ function run_next_test() {
function handler(httpStatus, metadata, response) {
gHitServer = true;
let etag;
try {
var etag = metadata.getHeader("If-None-Match");
etag = metadata.getHeader("If-None-Match");
} catch (ex) {
var etag = "";
etag = "";
}
if (etag == "testtag") {
// Allow using the cached data

View File

@ -4,8 +4,6 @@
"use strict";
/* globals NetUtil*/
/* globals HttpServer */
const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js");
let httpserver;

View File

@ -724,7 +724,7 @@ var altsvcClientListener = {
);
if (!isHttp2Connection) {
dump("/altsvc1 not over h2 yet - retry\n");
var chan = makeChan(
let chan = makeChan(
"http://foo.example.com:" + httpserv.identity.primaryPort + "/altsvc1"
).QueryInterface(Ci.nsIHttpChannel);
// we use this header to tell the server to issue a altsvc frame for the
@ -738,7 +738,7 @@ var altsvcClientListener = {
chan.asyncOpen(altsvcClientListener);
} else {
Assert.ok(isHttp2Connection);
var chan = makeChan(
let chan = makeChan(
"http://foo.example.com:" + httpserv2.identity.primaryPort + "/altsvc2"
).QueryInterface(Ci.nsIHttpChannel);
chan.loadFlags = Ci.nsIRequest.LOAD_BYPASS_CACHE;

View File

@ -63,16 +63,6 @@ function makeChan(url) {
return chan;
}
function makeChan(url) {
let chan = NetUtil.newChannel({
uri: url,
loadUsingSystemPrincipal: true,
contentPolicyType: Ci.nsIContentPolicy.TYPE_DOCUMENT,
}).QueryInterface(Ci.nsIHttpChannel);
chan.loadFlags = Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
return chan;
}
function channelOpenPromise(chan, flags) {
return new Promise(resolve => {
function finish(req, buffer) {

View File

@ -25,11 +25,11 @@ function run_test() {
chan.setRequestHeader("foopy", "baz", true);
check_request_header(chan, "foopy", "bar, baz");
for (var i = 0; i < 100; ++i) {
for (let i = 0; i < 100; ++i) {
chan.setRequestHeader("foopy" + i, i, false);
}
for (var i = 0; i < 100; ++i) {
for (let i = 0; i < 100; ++i) {
check_request_header(chan, "foopy" + i, i);
}

View File

@ -119,6 +119,8 @@ const PROXY_CHALLENGE =
// i.e. successful proxy auth and successful web server auth
//
function authHandler(metadata, response) {
let authorization;
let authPrefix;
switch (requestsMade) {
case 0:
// Proxy - First request to the Proxy resppond with a 407 to start auth
@ -127,8 +129,8 @@ function authHandler(metadata, response) {
break;
case 1:
// Proxy - Expecting a type 1 negotiate message from the client
var authorization = metadata.getHeader("Proxy-Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Proxy-Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE1_PREFIX, authPrefix, "Expecting a Type 1 message");
response.setStatusLine(metadata.httpVersion, 407, "Unauthorized");
response.setHeader("Proxy-Authenticate", PROXY_CHALLENGE, false);
@ -136,31 +138,31 @@ function authHandler(metadata, response) {
case 2:
// Proxy - Expecting a type 3 Authenticate message from the client
// Will respond with a 401 to start web server auth sequence
var authorization = metadata.getHeader("Proxy-Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Proxy-Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE3_PREFIX, authPrefix, "Expecting a Type 3 message");
response.setStatusLine(metadata.httpVersion, 401, "Unauthorized");
response.setHeader("WWW-Authenticate", "NTLM", false);
break;
case 3:
// Web Server - Expecting a type 1 negotiate message from the client
var authorization = metadata.getHeader("Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE1_PREFIX, authPrefix, "Expecting a Type 1 message");
response.setStatusLine(metadata.httpVersion, 401, "Unauthorized");
response.setHeader("WWW-Authenticate", NTLM_CHALLENGE, false);
break;
case 4:
// Web Server - Expecting a type 3 Authenticate message from the client
var authorization = metadata.getHeader("Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE3_PREFIX, authPrefix, "Expecting a Type 3 message");
response.setStatusLine(metadata.httpVersion, 200, "Successful");
break;
default:
// We should be authenticated and further requests are permitted
var authorization = metadata.getHeader("Authorization");
var authorization = metadata.getHeader("Proxy-Authorization");
authorization = metadata.getHeader("Authorization");
authorization = metadata.getHeader("Proxy-Authorization");
Assert.isnull(authorization);
response.setStatusLine(metadata.httpVersion, 200, "Successful");
}
@ -172,6 +174,8 @@ function authHandler(metadata, response) {
// proxy auth fails.
//
function authHandlerInvalidProxyPassword(metadata, response) {
let authorization;
let authPrefix;
switch (requestsMade) {
case 0:
// Proxy - First request respond with a 407 to initiate auth sequence
@ -180,8 +184,8 @@ function authHandlerInvalidProxyPassword(metadata, response) {
break;
case 1:
// Proxy - Expecting a type 1 negotiate message from the client
var authorization = metadata.getHeader("Proxy-Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Proxy-Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE1_PREFIX, authPrefix, "Expecting a Type 1 message");
response.setStatusLine(metadata.httpVersion, 407, "Unauthorized");
response.setHeader("Proxy-Authenticate", PROXY_CHALLENGE, false);
@ -190,8 +194,8 @@ function authHandlerInvalidProxyPassword(metadata, response) {
// Proxy - Expecting a type 3 Authenticate message from the client
// Respond with a 407 to indicate invalid credentials
//
var authorization = metadata.getHeader("Proxy-Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Proxy-Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE3_PREFIX, authPrefix, "Expecting a Type 3 message");
response.setStatusLine(metadata.httpVersion, 407, "Unauthorized");
response.setHeader("Proxy-Authenticate", "NTLM", false);
@ -211,6 +215,8 @@ function authHandlerInvalidProxyPassword(metadata, response) {
// Note: the connection should not be reused once the password failure is
// detected
function authHandlerInvalidWebPassword(metadata, response) {
let authorization;
let authPrefix;
switch (requestsMade) {
case 0:
// Proxy - First request return a 407 to start Proxy auth
@ -219,8 +225,8 @@ function authHandlerInvalidWebPassword(metadata, response) {
break;
case 1:
// Proxy - Expecting a type 1 negotiate message from the client
var authorization = metadata.getHeader("Proxy-Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Proxy-Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE1_PREFIX, authPrefix, "Expecting a Type 1 message");
response.setStatusLine(metadata.httpVersion, 407, "Unauthorized");
response.setHeader("Proxy-Authenticate", NTLM_CHALLENGE, false);
@ -228,16 +234,16 @@ function authHandlerInvalidWebPassword(metadata, response) {
case 2:
// Proxy - Expecting a type 3 Authenticate message from the client
// Responds with a 401 to start web server auth
var authorization = metadata.getHeader("Proxy-Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Proxy-Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE3_PREFIX, authPrefix, "Expecting a Type 3 message");
response.setStatusLine(metadata.httpVersion, 401, "Unauthorized");
response.setHeader("WWW-Authenticate", "NTLM", false);
break;
case 3:
// Web Server - Expecting a type 1 negotiate message from the client
var authorization = metadata.getHeader("Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE1_PREFIX, authPrefix, "Expecting a Type 1 message");
response.setStatusLine(metadata.httpVersion, 401, "Unauthorized");
response.setHeader("WWW-Authenticate", NTLM_CHALLENGE, false);
@ -245,8 +251,8 @@ function authHandlerInvalidWebPassword(metadata, response) {
case 4:
// Web Server - Expecting a type 3 Authenticate message from the client
// Respond with a 401 to restart the auth sequence.
var authorization = metadata.getHeader("Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE3_PREFIX, authPrefix, "Expecting a Type 1 message");
response.setStatusLine(metadata.httpVersion, 401, "Unauthorized");
break;

View File

@ -121,6 +121,8 @@ const PROXY_CHALLENGE =
// i.e. successful proxy auth
//
function successfulAuth(metadata, response) {
let authorization;
let authPrefix;
switch (requestsMade) {
case 0:
// Proxy - First request to the Proxy resppond with a 407 to start auth
@ -129,8 +131,8 @@ function successfulAuth(metadata, response) {
break;
case 1:
// Proxy - Expecting a type 1 negotiate message from the client
var authorization = metadata.getHeader("Proxy-Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Proxy-Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE1_PREFIX, authPrefix, "Expecting a Type 1 message");
response.setStatusLine(metadata.httpVersion, 407, "Unauthorized");
response.setHeader("Proxy-Authenticate", PROXY_CHALLENGE, false);
@ -138,14 +140,14 @@ function successfulAuth(metadata, response) {
case 2:
// Proxy - Expecting a type 3 Authenticate message from the client
// Will respond with a 401 to start web server auth sequence
var authorization = metadata.getHeader("Proxy-Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Proxy-Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE3_PREFIX, authPrefix, "Expecting a Type 3 message");
response.setStatusLine(metadata.httpVersion, 200, "Successful");
break;
default:
// We should be authenticated and further requests are permitted
var authorization = metadata.getHeader("Proxy-Authorization");
authorization = metadata.getHeader("Proxy-Authorization");
Assert.isnull(authorization);
response.setStatusLine(metadata.httpVersion, 200, "Successful");
}
@ -157,6 +159,8 @@ function successfulAuth(metadata, response) {
// proxy auth fails.
//
function failedAuth(metadata, response) {
let authorization;
let authPrefix;
switch (requestsMade) {
case 0:
// Proxy - First request respond with a 407 to initiate auth sequence
@ -165,8 +169,8 @@ function failedAuth(metadata, response) {
break;
case 1:
// Proxy - Expecting a type 1 negotiate message from the client
var authorization = metadata.getHeader("Proxy-Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Proxy-Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE1_PREFIX, authPrefix, "Expecting a Type 1 message");
response.setStatusLine(metadata.httpVersion, 407, "Unauthorized");
response.setHeader("Proxy-Authenticate", PROXY_CHALLENGE, false);
@ -175,8 +179,8 @@ function failedAuth(metadata, response) {
// Proxy - Expecting a type 3 Authenticate message from the client
// Respond with a 407 to indicate invalid credentials
//
var authorization = metadata.getHeader("Proxy-Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Proxy-Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE3_PREFIX, authPrefix, "Expecting a Type 3 message");
response.setStatusLine(metadata.httpVersion, 407, "Unauthorized");
response.setHeader("Proxy-Authenticate", "NTLM", false);
@ -195,6 +199,8 @@ function failedAuth(metadata, response) {
// Detects bug 486508
//
function connectionReset(metadata, response) {
let authorization;
let authPrefix;
switch (requestsMade) {
case 0:
// Proxy - First request to the Proxy resppond with a 407 to start auth
@ -203,16 +209,16 @@ function connectionReset(metadata, response) {
break;
case 1:
// Proxy - Expecting a type 1 negotiate message from the client
var authorization = metadata.getHeader("Proxy-Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Proxy-Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE1_PREFIX, authPrefix, "Expecting a Type 1 message");
ntlmTypeOneCount++;
response.setStatusLine(metadata.httpVersion, 407, "Unauthorized");
response.setHeader("Proxy-Authenticate", PROXY_CHALLENGE, false);
break;
case 2:
var authorization = metadata.getHeader("Proxy-Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Proxy-Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE3_PREFIX, authPrefix, "Expecting a Type 3 message");
ntlmTypeTwoCount++;
response.seizePower();

View File

@ -117,6 +117,8 @@ const NTLM_CHALLENGE =
// i.e. successful web server auth
//
function successfulAuth(metadata, response) {
let authorization;
let authPrefix;
switch (requestsMade) {
case 0:
// Web Server - Initial request
@ -126,22 +128,22 @@ function successfulAuth(metadata, response) {
break;
case 1:
// Web Server - Expecting a type 1 negotiate message from the client
var authorization = metadata.getHeader("Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE1_PREFIX, authPrefix, "Expecting a Type 1 message");
response.setStatusLine(metadata.httpVersion, 401, "Unauthorized");
response.setHeader("WWW-Authenticate", NTLM_CHALLENGE, false);
break;
case 2:
// Web Server - Expecting a type 3 Authenticate message from the client
var authorization = metadata.getHeader("Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE3_PREFIX, authPrefix, "Expecting a Type 3 message");
response.setStatusLine(metadata.httpVersion, 200, "Successful");
break;
default:
// We should be authenticated and further requests are permitted
var authorization = metadata.getHeader("Authorization");
authorization = metadata.getHeader("Authorization");
Assert.isnull(authorization);
response.setStatusLine(metadata.httpVersion, 200, "Successful");
}
@ -150,6 +152,8 @@ function successfulAuth(metadata, response) {
// web server responses simulating an unsuccessful web server auth
function failedAuth(metadata, response) {
let authorization;
let authPrefix;
switch (requestsMade) {
case 0:
// Web Server - First request return a 401 to start auth sequence
@ -158,8 +162,8 @@ function failedAuth(metadata, response) {
break;
case 1:
// Web Server - Expecting a type 1 negotiate message from the client
var authorization = metadata.getHeader("Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE1_PREFIX, authPrefix, "Expecting a Type 1 message");
response.setStatusLine(metadata.httpVersion, 401, "Unauthorized");
response.setHeader("WWW-Authenticate", NTLM_CHALLENGE, false);
@ -167,8 +171,8 @@ function failedAuth(metadata, response) {
case 2:
// Web Server - Expecting a type 3 Authenticate message from the client
// Respond with a 401 to restart the auth sequence.
var authorization = metadata.getHeader("Authorization");
var authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
authorization = metadata.getHeader("Authorization");
authPrefix = authorization.substring(0, NTLM_PREFIX_LEN);
Assert.equal(NTLM_TYPE3_PREFIX, authPrefix, "Expecting a Type 1 message");
response.setStatusLine(metadata.httpVersion, 401, "Unauthorized");
break;

View File

@ -90,10 +90,11 @@ function serverHandler(metadata, response) {
print("============== serverHandler: in");
}
let etag;
try {
var etag = metadata.getHeader("If-None-Match");
etag = metadata.getHeader("If-None-Match");
} catch (ex) {
var etag = "";
etag = "";
}
if (etag == "testtag") {
if (dbg) {

View File

@ -36,11 +36,11 @@ function contentHandler(metadata, response) {
if (!metadata.hasHeader("If-Range")) {
response.setHeader("Content-Length", responseBody.length + "");
response.processAsync();
var slice = responseBody.slice(0, 100);
let slice = responseBody.slice(0, 100);
response.bodyOutputStream.write(slice, slice.length);
response.finish();
} else {
var slice = responseBody.slice(100);
let slice = responseBody.slice(100);
response.setStatusLine(metadata.httpVersion, 206, "Partial Content");
response.setHeader(
"Content-Range",

View File

@ -45,7 +45,7 @@ function run_test() {
}
// put a few hosts in
for (var i = 0; i < hosts.length; ++i) {
for (let i = 0; i < hosts.length; ++i) {
let uri = ioService.newURI(hosts[i][0]);
let principal = secMan.createContentPrincipal(uri, {});
@ -53,7 +53,7 @@ function run_test() {
}
// test the result
for (var i = 0; i < results.length; ++i) {
for (let i = 0; i < results.length; ++i) {
let uri = ioService.newURI(results[i][0]);
let principal = secMan.createContentPrincipal(uri, {});
@ -72,13 +72,13 @@ function run_test() {
Assert.equal(perms.length, hosts.length);
// ... remove all the hosts ...
for (var j = 0; j < perms.length; ++j) {
for (let j = 0; j < perms.length; ++j) {
pm.removePermission(perms[j]);
}
// ... ensure each and every element is equal ...
for (var i = 0; i < hosts.length; ++i) {
for (var j = 0; j < perms.length; ++j) {
for (let i = 0; i < hosts.length; ++i) {
for (let j = 0; j < perms.length; ++j) {
if (
perms[j].matchesURI(ioService.newURI(hosts[i][0]), true) &&
hosts[i][1] == perms[j].type &&

View File

@ -752,7 +752,6 @@ function host_filter_cb(proxy) {
// Verify that hists in the host filter list are not proxied
// refers to "network.proxy.no_proxies_on"
var uriStrUseProxyList;
var uriStrUseProxyList;
var hostFilterList;
var uriStrFilterList;

View File

@ -25,10 +25,11 @@ function test_handler(metadata, response) {
response.setHeader("Cache-Control", "no-cache");
response.setHeader("ETag", "test-etag1");
let etag;
try {
var etag = metadata.getHeader("If-None-Match");
etag = metadata.getHeader("If-None-Match");
} catch (ex) {
var etag = "";
etag = "";
}
if (etag == "test-etag1") {
@ -105,7 +106,7 @@ function* testSteps() {
});
// Initial request. Stores the response in the cache.
var channel = make_channel("http://localhost:" + PORT + "/rcwn");
let channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel.asyncOpen(new ChannelListener(checkContent, null));
yield undefined;
equal(gResponseCounter, 1);
@ -113,7 +114,7 @@ function* testSteps() {
equal(g304Counter, 0, "check number of 304 responses");
// Checks that response is returned from the cache, after a 304 response.
var channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel.asyncOpen(new ChannelListener(checkContent, null));
yield undefined;
equal(gResponseCounter, 2);
@ -121,7 +122,7 @@ function* testSteps() {
equal(g304Counter, 1, "check number of 304 responses");
// Checks that delaying the response from the cache works.
var channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel
.QueryInterface(Ci.nsIRaceCacheWithNetwork)
.test_delayCacheEntryOpeningBy(200);
@ -138,7 +139,7 @@ function* testSteps() {
equal(g304Counter, 2, "check number of 304 responses");
// Checks that we can trigger the cache open immediately, even if the cache delay is set very high.
var channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel
.QueryInterface(Ci.nsIRaceCacheWithNetwork)
.test_delayCacheEntryOpeningBy(100000);
@ -154,7 +155,7 @@ function* testSteps() {
equal(g304Counter, 3, "check number of 304 responses");
// Sets a high delay for the cache fetch, and triggers the network activity.
var channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel
.QueryInterface(Ci.nsIRaceCacheWithNetwork)
.test_delayCacheEntryOpeningBy(100000);
@ -169,7 +170,7 @@ function* testSteps() {
// Sets a high delay for the cache fetch, and triggers the network activity.
// While the network response is produced, we trigger the cache fetch.
// Because the network response was the first, a non-conditional request is sent.
var channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel
.QueryInterface(Ci.nsIRaceCacheWithNetwork)
.test_delayCacheEntryOpeningBy(100000);
@ -188,7 +189,7 @@ function* testSteps() {
equal(g304Counter, 3, "check number of 304 responses");
// Triggers cache open before triggering network.
var channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel
.QueryInterface(Ci.nsIRaceCacheWithNetwork)
.test_delayCacheEntryOpeningBy(100000);
@ -205,7 +206,7 @@ function* testSteps() {
equal(g304Counter, 4, "check number of 304 responses");
// Load the cached handler so we don't need to revalidate
var channel = make_channel("http://localhost:" + PORT + "/rcwn_cached");
channel = make_channel("http://localhost:" + PORT + "/rcwn_cached");
channel.asyncOpen(new ChannelListener(checkContent, null));
yield undefined;
equal(gResponseCounter, 8);
@ -213,7 +214,7 @@ function* testSteps() {
equal(g304Counter, 4, "check number of 304 responses");
// Make sure response is loaded from the cache, not the network
var channel = make_channel("http://localhost:" + PORT + "/rcwn_cached");
channel = make_channel("http://localhost:" + PORT + "/rcwn_cached");
channel.asyncOpen(new ChannelListener(checkContent, null));
yield undefined;
equal(gResponseCounter, 9);
@ -222,7 +223,7 @@ function* testSteps() {
// Cache times out, so we trigger the network
gIsFromCache = 0;
var channel = make_channel("http://localhost:" + PORT + "/rcwn_cached");
channel = make_channel("http://localhost:" + PORT + "/rcwn_cached");
channel
.QueryInterface(Ci.nsIRaceCacheWithNetwork)
.test_delayCacheEntryOpeningBy(100000);
@ -236,7 +237,7 @@ function* testSteps() {
equal(g304Counter, 4, "check number of 304 responses");
// Cache callback comes back right after network is triggered.
var channel = make_channel("http://localhost:" + PORT + "/rcwn_cached");
channel = make_channel("http://localhost:" + PORT + "/rcwn_cached");
channel
.QueryInterface(Ci.nsIRaceCacheWithNetwork)
.test_delayCacheEntryOpeningBy(100000);
@ -258,7 +259,7 @@ function* testSteps() {
// and some we will get from the cache.
gIsFromCache = 0;
for (var i = 0; i < 50; i++) {
var channel = make_channel("http://localhost:" + PORT + "/rcwn_cached");
channel = make_channel("http://localhost:" + PORT + "/rcwn_cached");
channel
.QueryInterface(Ci.nsIRaceCacheWithNetwork)
.test_delayCacheEntryOpeningBy(100000);

View File

@ -492,35 +492,35 @@ function run_test() {
evict_cache_entries();
// Case 2: zero-length partial entry must not trigger range-request
var chan = make_channel("http://localhost:" + port + "/test_2");
let chan = make_channel("http://localhost:" + port + "/test_2");
chan.asyncOpen(new Canceler(received_partial_2));
// Case 3: no-store response must not trigger range-request
var chan = make_channel("http://localhost:" + port + "/test_3");
chan = make_channel("http://localhost:" + port + "/test_3");
chan.asyncOpen(new MyListener(received_partial_3));
// Case 4: response with content-encoding must not trigger range-request
var chan = make_channel("http://localhost:" + port + "/test_4");
chan = make_channel("http://localhost:" + port + "/test_4");
chan.asyncOpen(new MyListener(received_partial_4));
// Case 5: conditional request-header set by client
var chan = make_channel("http://localhost:" + port + "/test_5");
chan = make_channel("http://localhost:" + port + "/test_5");
chan.asyncOpen(new MyListener(received_partial_5));
// Case 6: response is not resumable (drop the Accept-Ranges header)
var chan = make_channel("http://localhost:" + port + "/test_6");
chan = make_channel("http://localhost:" + port + "/test_6");
chan.asyncOpen(new MyListener(received_partial_6));
// Case 7: a basic positive test
var chan = make_channel("http://localhost:" + port + "/test_7");
chan = make_channel("http://localhost:" + port + "/test_7");
chan.asyncOpen(new MyListener(received_partial_7));
// Case 8: check that mismatched 206 and 200 sizes throw error
var chan = make_channel("http://localhost:" + port + "/test_8");
chan = make_channel("http://localhost:" + port + "/test_8");
chan.asyncOpen(new MyListener(received_partial_8));
// Case 9: check that weak etag is not used for a range request
var chan = make_channel("http://localhost:" + port + "/test_9");
chan = make_channel("http://localhost:" + port + "/test_9");
chan.asyncOpen(new MyListener(received_partial_9));
do_test_pending();

View File

@ -87,14 +87,14 @@ function run_test() {
let testGenerator = testSteps();
function* testSteps() {
// Store first version of the content in the cache.
var channel = make_channel("http://localhost:" + PORT + "/rcwn");
let channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel.asyncOpen(new ChannelListener(checkContent, null));
yield undefined;
equal(gRequestCounter, 1);
// Simulate the network victory by setting high delay for the cache fetch and
// triggering the network.
var channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel
.QueryInterface(Ci.nsIRaceCacheWithNetwork)
.test_delayCacheEntryOpeningBy(100000);
@ -105,7 +105,7 @@ function* testSteps() {
equal(gRequestCounter, 2);
// Simulate navigation back by specifying VALIDATE_NEVER flag.
var channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel = make_channel("http://localhost:" + PORT + "/rcwn");
channel.loadFlags = Ci.nsIRequest.VALIDATE_NEVER;
channel.asyncOpen(new ChannelListener(checkContent, null));
yield undefined;

View File

@ -41,11 +41,11 @@ function runScriptSubprocess(script, args) {
do_throw("Can't find xpcshell binary");
}
var script = do_get_file(script);
var file = do_get_file(script);
var proc = new Process(bin);
var args = [script.path].concat(args);
var procArgs = [file.path].concat(args);
proc.run(false, args, args.length);
proc.run(false, procArgs, procArgs.length);
return proc;
}

View File

@ -604,7 +604,7 @@ add_test(function test_hugeStringThrows() {
});
add_test(function test_filterWhitespace() {
var url = stringToURL(
let url = stringToURL(
" \r\n\th\nt\rt\tp://ex\r\n\tample.com/path\r\n\t/\r\n\tto the/fil\r\n\te.e\r\n\txt?que\r\n\try#ha\r\n\tsh \r\n\t "
);
Assert.equal(
@ -613,7 +613,7 @@ add_test(function test_filterWhitespace() {
);
// These setters should escape \r\n\t, not filter them.
var url = stringToURL("http://test.com/path?query#hash");
url = stringToURL("http://test.com/path?query#hash");
url = url
.mutate()
.setFilePath("pa\r\n\tth")
@ -722,7 +722,7 @@ add_test(function test_encode_C0_and_space() {
) {
continue;
}
var url = stringToURL(
let url = stringToURL(
"http://example.com/pa" +
String.fromCharCode(i) +
"th?qu" +
@ -744,7 +744,7 @@ add_test(function test_encode_C0_and_space() {
}
// Additionally, we need to check the setters.
var url = stringToURL("http://example.com/path?query#hash");
let url = stringToURL("http://example.com/path?query#hash");
url = url
.mutate()
.setFilePath("pa\0th")
@ -790,7 +790,7 @@ add_test(function test_ipv4Normalize() {
"http://127.0.0.1.",
].map(stringToURL);
var url;
let url;
for (url of localIPv4s) {
Assert.equal(url.spec, "http://127.0.0.1/");
}
@ -821,7 +821,7 @@ add_test(function test_ipv4Normalize() {
Assert.equal(url.spec, spec);
}
var url = stringToURL("resource://path/to/resource/");
url = stringToURL("resource://path/to/resource/");
url = url
.mutate()
.setHost("123")

View File

@ -74,7 +74,7 @@ requestListenerObserver.prototype = {
subject instanceof Ci.nsIHttpChannel
) {
if (this.suspendOnBeforeConnect) {
var chan = subject.QueryInterface(Ci.nsIHttpChannel);
let chan = subject.QueryInterface(Ci.nsIHttpChannel);
executeSoon(() => {
this.resumeOnBeforeConnect = true;
chan.resume();
@ -87,7 +87,7 @@ requestListenerObserver.prototype = {
subject instanceof Ci.nsIHttpChannel
) {
if (this.suspendOnModifyRequest) {
var chan = subject.QueryInterface(Ci.nsIHttpChannel);
let chan = subject.QueryInterface(Ci.nsIHttpChannel);
executeSoon(() => {
this.resumeOnModifyRequest = true;
chan.resume();

View File

@ -4,7 +4,6 @@
"use strict";
/* globals HttpServer */
const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js");
let httpserver;