зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1504323 - P2 Enable ESLint for netwerk/test/httpserver/ (manual changes) r=Standard8,dragana
Differential Revision: https://phabricator.services.mozilla.com/D10986 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
964925b6fe
Коммит
1dbcaab155
|
@ -30,7 +30,6 @@ memory/replace/dmd/test/**
|
|||
modules/**
|
||||
netwerk/cookie/test/browser/**
|
||||
netwerk/test/browser/**
|
||||
netwerk/test/httpserver/**
|
||||
netwerk/test/mochitests/**
|
||||
netwerk/test/unit*/**
|
||||
parser/**
|
||||
|
|
|
@ -50,6 +50,8 @@ var DEBUG_TIMESTAMP = false; // non-const so tweakable in server tests
|
|||
|
||||
var gGlobalObject = Cu.getGlobalForObject(this);
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
/**
|
||||
* Asserts that the given condition holds. If it doesn't, the given message is
|
||||
* dumped, a stack trace is printed, and an exception is thrown to attempt to
|
||||
|
@ -185,16 +187,6 @@ function dumpStack() {
|
|||
/** The XPCOM thread manager. */
|
||||
var gThreadManager = null;
|
||||
|
||||
/** The XPCOM prefs service. */
|
||||
var gRootPrefBranch = null;
|
||||
function getRootPrefBranch() {
|
||||
if (!gRootPrefBranch) {
|
||||
gRootPrefBranch = Cc["@mozilla.org/preferences-service;1"]
|
||||
.getService(Ci.nsIPrefBranch);
|
||||
}
|
||||
return gRootPrefBranch;
|
||||
}
|
||||
|
||||
/**
|
||||
* JavaScript constructors for commonly-used classes; precreating these is a
|
||||
* speedup over doing the same from base principles. See the docs at
|
||||
|
@ -487,15 +479,14 @@ nsHttpServer.prototype =
|
|||
// network.http.max-persistent-connections-per-proxy concurrent
|
||||
// connections, plus a safety margin in case some other process is
|
||||
// talking to the server as well.
|
||||
var prefs = getRootPrefBranch();
|
||||
var maxConnections = 5 + Math.max(
|
||||
prefs.getIntPref("network.http.max-persistent-connections-per-server"),
|
||||
prefs.getIntPref("network.http.max-persistent-connections-per-proxy"));
|
||||
Services.prefs.getIntPref("network.http.max-persistent-connections-per-server"),
|
||||
Services.prefs.getIntPref("network.http.max-persistent-connections-per-proxy"));
|
||||
|
||||
try {
|
||||
var loopback = true;
|
||||
if (this._host != "127.0.0.1" && this._host != "localhost") {
|
||||
var loopback = false;
|
||||
loopback = false;
|
||||
}
|
||||
|
||||
// When automatically selecting a port, sometimes the chosen port is
|
||||
|
@ -503,15 +494,13 @@ nsHttpServer.prototype =
|
|||
// tests will intermittently fail. So, we simply keep trying to to
|
||||
// get a server socket until a valid port is obtained. We limit
|
||||
// ourselves to finite attempts just so we don't loop forever.
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService);
|
||||
var socket;
|
||||
for (var i = 100; i; i--) {
|
||||
var temp = new ServerSocket(this._port,
|
||||
loopback, // true = localhost, false = everybody
|
||||
maxConnections);
|
||||
|
||||
var allowed = ios.allowPort(temp.port, "http");
|
||||
var allowed = Services.io.allowPort(temp.port, "http");
|
||||
if (!allowed) {
|
||||
dumpn(">>>Warning: obtained ServerSocket listens on a blocked " +
|
||||
"port: " + temp.port);
|
||||
|
@ -1601,9 +1590,7 @@ RequestReader.prototype =
|
|||
}
|
||||
|
||||
try {
|
||||
var uri = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService)
|
||||
.newURI(fullPath);
|
||||
var uri = Services.io.newURI(fullPath);
|
||||
fullPath = uri.pathQueryRef;
|
||||
scheme = uri.scheme;
|
||||
host = metadata._host = uri.asciiHost;
|
||||
|
@ -1899,7 +1886,7 @@ function defaultIndexHandler(metadata, response) {
|
|||
var files = directory.directoryEntries;
|
||||
while (files.hasMoreElements()) {
|
||||
var f = files.nextFile;
|
||||
var name = f.leafName;
|
||||
let name = f.leafName;
|
||||
if (!f.isHidden() &&
|
||||
(name.charAt(name.length - 1) != HIDDEN_CHAR ||
|
||||
name.charAt(name.length - 2) == HIDDEN_CHAR))
|
||||
|
@ -1911,7 +1898,7 @@ function defaultIndexHandler(metadata, response) {
|
|||
for (var i = 0; i < fileList.length; i++) {
|
||||
var file = fileList[i];
|
||||
try {
|
||||
var name = file.leafName;
|
||||
let name = file.leafName;
|
||||
if (name.charAt(name.length - 1) == HIDDEN_CHAR)
|
||||
name = name.substring(0, name.length - 1);
|
||||
var sep = file.isDirectory() ? "/" : "";
|
||||
|
@ -2477,11 +2464,10 @@ ServerHandler.prototype =
|
|||
|
||||
var type = this._getTypeFromFile(file);
|
||||
if (type === SJS_TYPE) {
|
||||
var fis = new FileInputStream(file, PR_RDONLY, PERMS_READONLY,
|
||||
let fis = new FileInputStream(file, PR_RDONLY, PERMS_READONLY,
|
||||
Ci.nsIFileInputStream.CLOSE_ON_EOF);
|
||||
|
||||
try {
|
||||
var sis = new ScriptableInputStream(fis);
|
||||
var s = Cu.Sandbox(gGlobalObject);
|
||||
s.importFunction(dump, "dump");
|
||||
s.importFunction(atob, "atob");
|
||||
|
@ -2523,12 +2509,8 @@ ServerHandler.prototype =
|
|||
// getting the line number where we evaluate the SJS file. Don't
|
||||
// separate these two lines!
|
||||
var line = new Error().lineNumber;
|
||||
let uri = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService)
|
||||
.newFileURI(file);
|
||||
let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader);
|
||||
scriptLoader.loadSubScript(uri.spec, s);
|
||||
let uri = Services.io.newFileURI(file);
|
||||
Services.scriptloader.loadSubScript(uri.spec, s);
|
||||
} catch (e) {
|
||||
dumpn("*** syntax error in SJS at " + file.path + ": " + e);
|
||||
throw HTTP_500;
|
||||
|
@ -2558,7 +2540,7 @@ ServerHandler.prototype =
|
|||
maybeAddHeaders(file, metadata, response);
|
||||
response.setHeader("Content-Length", "" + count, false);
|
||||
|
||||
var fis = new FileInputStream(file, PR_RDONLY, PERMS_READONLY,
|
||||
let fis = new FileInputStream(file, PR_RDONLY, PERMS_READONLY,
|
||||
Ci.nsIFileInputStream.CLOSE_ON_EOF);
|
||||
|
||||
offset = offset || 0;
|
||||
|
@ -3726,7 +3708,7 @@ Response.prototype =
|
|||
QueryInterface: ChromeUtils.generateQI(["nsIRequestObserver"]),
|
||||
};
|
||||
|
||||
var headerCopier = this._asyncCopier =
|
||||
this._asyncCopier =
|
||||
new WriteThroughCopier(responseHeadPipe.inputStream,
|
||||
this._connection.output,
|
||||
copyObserver, null);
|
||||
|
@ -3943,15 +3925,16 @@ WriteThroughCopier.prototype =
|
|||
if (bytesWanted === 0)
|
||||
throw Components.Exception("", Cr.NS_BASE_STREAM_CLOSED);
|
||||
} catch (e) {
|
||||
let rv;
|
||||
if (streamClosed(e)) {
|
||||
dumpn("*** input stream closed");
|
||||
e = bytesWanted === 0 ? Cr.NS_OK : Cr.NS_ERROR_UNEXPECTED;
|
||||
rv = bytesWanted === 0 ? Cr.NS_OK : Cr.NS_ERROR_UNEXPECTED;
|
||||
} else {
|
||||
dumpn("!!! unexpected error reading from input, canceling: " + e);
|
||||
e = Cr.NS_ERROR_UNEXPECTED;
|
||||
rv = Cr.NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
this._doneReadingSource(e);
|
||||
this._doneReadingSource(rv);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4524,9 +4507,9 @@ nsHttpHeaders.prototype =
|
|||
var name = headerUtils.normalizeFieldName(fieldName);
|
||||
var value = headerUtils.normalizeFieldValue(fieldValue);
|
||||
if (name in this._headers) {
|
||||
this._headers[name].push(fieldValue);
|
||||
this._headers[name].push(value);
|
||||
} else {
|
||||
this._headers[name] = [fieldValue];
|
||||
this._headers[name] = [value];
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -3,13 +3,15 @@
|
|||
/* 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/. */
|
||||
/* global __LOCATION__ */
|
||||
/* import-globals-from ../httpd.js */
|
||||
|
||||
var _HTTPD_JS_PATH = __LOCATION__.parent;
|
||||
_HTTPD_JS_PATH.append("httpd.js");
|
||||
load(_HTTPD_JS_PATH.path);
|
||||
|
||||
// if these tests fail, we'll want the debug output
|
||||
DEBUG = true;
|
||||
var linDEBUG = true;
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
@ -75,7 +77,7 @@ function fileContents(file) {
|
|||
* includes a final empty line if data ended with a CRLF
|
||||
*/
|
||||
function* LineIterator(data) {
|
||||
var start = 0, index = 0;
|
||||
var index = 0;
|
||||
do {
|
||||
index = data.indexOf("\r\n");
|
||||
if (index >= 0)
|
||||
|
@ -253,7 +255,7 @@ function runHttpTests(testArray, done) {
|
|||
} catch (e) {
|
||||
try {
|
||||
do_report_unexpected_exception(e, "testArray[" + testIndex + "].initChannel(ch)");
|
||||
} catch (e) {
|
||||
} catch (x) {
|
||||
/* swallow and let tests continue */
|
||||
}
|
||||
}
|
||||
|
@ -354,6 +356,8 @@ function RawTest(host, port, data, responseCheck) {
|
|||
data = [data];
|
||||
if (data.length <= 0)
|
||||
throw "bad data length";
|
||||
|
||||
// eslint-disable-next-line no-control-regex
|
||||
if (!data.every(function(v) { return /^[\x00-\xff]*$/.test(v); }))
|
||||
throw "bad data contained non-byte-valued character";
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* 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/. */
|
||||
|
||||
|
||||
/*
|
||||
* Ensures that data a request handler writes out in response is sent only as
|
||||
* quickly as the client can receive it, without racing ahead and being forced
|
||||
|
@ -323,10 +324,10 @@ function sinkAndSourceClosedWithPendingData(next) {
|
|||
|
||||
/** Returns the sum of the elements in arr. */
|
||||
function sum(arr) {
|
||||
var sum = 0;
|
||||
var s = 0;
|
||||
for (var i = 0, sz = arr.length; i < sz; i++)
|
||||
sum += arr[i];
|
||||
return sum;
|
||||
s += arr[i];
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1447,7 +1448,6 @@ CopyTest.prototype =
|
|||
}
|
||||
|
||||
var task = this._tasks[this._currentTask++];
|
||||
var self = this;
|
||||
var event =
|
||||
{
|
||||
run: function run() {
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
* Basic functionality test, from the client programmer's POV.
|
||||
*/
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "port", function() {
|
||||
return srv.identity.primaryPort;
|
||||
});
|
||||
|
@ -32,9 +34,7 @@ function run_test() {
|
|||
|
||||
// base path
|
||||
// XXX should actually test this works with a file by comparing streams!
|
||||
var dirServ = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties);
|
||||
var path = dirServ.get("CurWorkD", Ci.nsIFile);
|
||||
var path = Services.dirsvc.get("CurWorkD", Ci.nsIFile);
|
||||
srv.registerDirectory("/", path);
|
||||
|
||||
// register a few test paths
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
// escaping checks -- highly dependent on the default index handler output
|
||||
// format
|
||||
|
||||
var srv, dir, dirEntries;
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var srv, dir, gDirEntries;
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "BASE_URL", function() {
|
||||
return "http://localhost:" + srv.identity.primaryPort + "/";
|
||||
|
@ -37,9 +39,7 @@ function run_test() {
|
|||
}
|
||||
|
||||
function createTestDirectory() {
|
||||
dir = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties)
|
||||
.get("TmpD", Ci.nsIFile);
|
||||
dir = Services.dirsvc.get("TmpD", Ci.nsIFile);
|
||||
dir.append("index_handler_test_" + Math.random());
|
||||
dir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o744);
|
||||
|
||||
|
@ -62,7 +62,7 @@ function createTestDirectory() {
|
|||
makeFile("zf%200h", false, dir, files);
|
||||
makeFile("zg>m", false, dir, files);
|
||||
|
||||
dirEntries = [files];
|
||||
gDirEntries = [files];
|
||||
|
||||
var subdir = dir.clone();
|
||||
subdir.append("foo");
|
||||
|
@ -74,7 +74,7 @@ function createTestDirectory() {
|
|||
makeFile("AA_file.txt", false, subdir, files);
|
||||
makeFile("test.txt", false, subdir, files);
|
||||
|
||||
dirEntries.push(files);
|
||||
gDirEntries.push(files);
|
||||
}
|
||||
|
||||
function destroyTestDirectory() {
|
||||
|
@ -116,10 +116,7 @@ function hiddenDataCheck(bytes, uri, path) {
|
|||
Assert.equal(lst.length, 1);
|
||||
var items = lst[0].getElementsByTagName("li");
|
||||
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService);
|
||||
|
||||
var top = ios.newURI(uri);
|
||||
var top = Services.io.newURI(uri);
|
||||
|
||||
// N.B. No ERROR_IF_SEE_THIS.txt^ file!
|
||||
var dirEntries = [{name: "file.txt", isDirectory: false},
|
||||
|
@ -133,7 +130,7 @@ function hiddenDataCheck(bytes, uri, path) {
|
|||
|
||||
Assert.equal(link.textContent, f.name + sep);
|
||||
|
||||
uri = ios.newURI(link.getAttribute("href"), null, top);
|
||||
uri = Services.io.newURI(link.getAttribute("href"), null, top);
|
||||
Assert.equal(decodeURIComponent(uri.pathQueryRef), path + f.name + sep);
|
||||
}
|
||||
}
|
||||
|
@ -184,11 +181,6 @@ function dataCheck(bytes, uri, path, dirEntries) {
|
|||
Assert.equal(lst.length, 1);
|
||||
var items = lst[0].getElementsByTagName("li");
|
||||
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService);
|
||||
|
||||
var dirURI = ios.newURI(uri);
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var link = items[i].childNodes[0];
|
||||
var f = dirEntries[i];
|
||||
|
@ -197,7 +189,7 @@ function dataCheck(bytes, uri, path, dirEntries) {
|
|||
|
||||
Assert.equal(link.textContent, f.name + sep);
|
||||
|
||||
uri = ios.newURI(link.getAttribute("href"), null, top);
|
||||
uri = Services.io.newURI(link.getAttribute("href"), null, top);
|
||||
Assert.equal(decodeURIComponent(uri.pathQueryRef), path + f.name + sep);
|
||||
}
|
||||
}
|
||||
|
@ -235,12 +227,12 @@ function start(ch) {
|
|||
Assert.equal(ch.getResponseHeader("Content-Type"), "text/html;charset=utf-8");
|
||||
}
|
||||
function stopRootDirectory(ch, cx, status, data) {
|
||||
dataCheck(data, BASE_URL, "/", dirEntries[0]);
|
||||
dataCheck(data, BASE_URL, "/", gDirEntries[0]);
|
||||
}
|
||||
|
||||
// check non-top-level, too
|
||||
function stopFooDirectory(ch, cx, status, data) {
|
||||
dataCheck(data, BASE_URL + "foo/", "/foo/", dirEntries[1]);
|
||||
dataCheck(data, BASE_URL + "foo/", "/foo/", gDirEntries[1]);
|
||||
}
|
||||
|
||||
// trailing-caret leaf with hidden files
|
||||
|
|
|
@ -72,5 +72,5 @@ function register400Handler(ch) {
|
|||
// /throws/exception (and also a 404 and 400 error handler)
|
||||
function throwsException(metadata, response) {
|
||||
throw "this shouldn't cause an exit...";
|
||||
do_throw("Not reached!");
|
||||
do_throw("Not reached!"); // eslint-disable-line no-unreachable
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ function testGetHeader() {
|
|||
Assert.equal(c, "text/html");
|
||||
|
||||
headers.setHeader("test", "FOO", false);
|
||||
var c = headers.getHeader("test");
|
||||
c = headers.getHeader("test");
|
||||
Assert.equal(c, "FOO");
|
||||
|
||||
try {
|
||||
|
@ -140,9 +140,9 @@ function testHeaderEnumerator() {
|
|||
delete heads[it.toLowerCase()];
|
||||
}
|
||||
|
||||
for (var i in heads)
|
||||
if (Object.keys(heads).length != 0) {
|
||||
do_throw("still have properties in heads!?!?");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function testHasHeader() {
|
||||
|
|
|
@ -209,13 +209,13 @@ function run_test_3() {
|
|||
* Verifies that all .primary* getters on a server identity correctly throw
|
||||
* NS_ERROR_NOT_INITIALIZED.
|
||||
*
|
||||
* @param id : nsIHttpServerIdentity
|
||||
* @param aId : nsIHttpServerIdentity
|
||||
* the server identity to test
|
||||
*/
|
||||
function checkPrimariesThrow(id) {
|
||||
function checkPrimariesThrow(aId) {
|
||||
var threw = false;
|
||||
try {
|
||||
id.primaryScheme;
|
||||
aId.primaryScheme;
|
||||
} catch (e) {
|
||||
threw = e.result === Cr.NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ function checkPrimariesThrow(id) {
|
|||
|
||||
threw = false;
|
||||
try {
|
||||
id.primaryHost;
|
||||
aId.primaryHost;
|
||||
} catch (e) {
|
||||
threw = e.result === Cr.NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ function checkPrimariesThrow(id) {
|
|||
|
||||
threw = false;
|
||||
try {
|
||||
id.primaryPort;
|
||||
aId.primaryPort;
|
||||
} catch (e) {
|
||||
threw = e.result === Cr.NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
@ -241,8 +241,8 @@ function checkPrimariesThrow(id) {
|
|||
/**
|
||||
* Utility function to check for a 400 response.
|
||||
*/
|
||||
function check400(data) {
|
||||
var iter = LineIterator(data);
|
||||
function check400(aData) {
|
||||
var iter = LineIterator(aData);
|
||||
|
||||
// Status-Line
|
||||
var { value: firstLine } = iter.next();
|
||||
|
@ -268,8 +268,8 @@ function http10Request(request, response) {
|
|||
}
|
||||
data = "GET /http/1.0-request HTTP/1.0\r\n" +
|
||||
"\r\n";
|
||||
function check10(data) {
|
||||
var iter = LineIterator(data);
|
||||
function check10(aData) {
|
||||
var iter = LineIterator(aData);
|
||||
|
||||
// Status-Line
|
||||
Assert.equal(iter.next().value, "HTTP/1.0 200 TEST PASSED");
|
||||
|
@ -290,7 +290,7 @@ function check10(data) {
|
|||
|
||||
expectLines(iter, body);
|
||||
}
|
||||
test = new RawTest("localhost", PORT, data, check10),
|
||||
test = new RawTest("localhost", PORT, data, check10);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -298,7 +298,7 @@ tests.push(test);
|
|||
|
||||
data = "GET /http/1.1-request HTTP/1.1\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check400),
|
||||
test = new RawTest("localhost", PORT, data, check400);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -307,7 +307,7 @@ tests.push(test);
|
|||
data = "GET /http/1.1-request HTTP/1.1\r\n" +
|
||||
"Host: not-localhost\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check400),
|
||||
test = new RawTest("localhost", PORT, data, check400);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -316,7 +316,7 @@ tests.push(test);
|
|||
data = "GET /http/1.1-request HTTP/1.1\r\n" +
|
||||
"Host: not-localhost:4444\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check400),
|
||||
test = new RawTest("localhost", PORT, data, check400);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -325,7 +325,7 @@ tests.push(test);
|
|||
data = "GET /http/1.1-request HTTP/1.1\r\n" +
|
||||
"Host: 127.0.0.1\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check400),
|
||||
test = new RawTest("localhost", PORT, data, check400);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -334,7 +334,7 @@ tests.push(test);
|
|||
data = "GET http://127.0.0.1/http/1.1-request HTTP/1.1\r\n" +
|
||||
"Host: 127.0.0.1\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check400),
|
||||
test = new RawTest("localhost", PORT, data, check400);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -343,7 +343,7 @@ tests.push(test);
|
|||
data = "GET http://localhost:31337/http/1.1-request HTTP/1.1\r\n" +
|
||||
"Host: localhost:31337\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check400),
|
||||
test = new RawTest("localhost", PORT, data, check400);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -352,7 +352,7 @@ tests.push(test);
|
|||
data = "GET https://localhost:4444/http/1.1-request HTTP/1.1\r\n" +
|
||||
"Host: localhost:4444\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check400),
|
||||
test = new RawTest("localhost", PORT, data, check400);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -365,8 +365,8 @@ function http11goodHost(request, response) {
|
|||
data = "GET /http/1.1-good-host HTTP/1.1\r\n" +
|
||||
"Host: localhost:4444\r\n" +
|
||||
"\r\n";
|
||||
function check11goodHost(data) {
|
||||
var iter = LineIterator(data);
|
||||
function check11goodHost(aData) {
|
||||
var iter = LineIterator(aData);
|
||||
|
||||
// Status-Line
|
||||
Assert.equal(iter.next().value, "HTTP/1.1 200 TEST PASSED");
|
||||
|
@ -387,7 +387,7 @@ function check11goodHost(data) {
|
|||
|
||||
expectLines(iter, body);
|
||||
}
|
||||
test = new RawTest("localhost", PORT, data, check11goodHost),
|
||||
test = new RawTest("localhost", PORT, data, check11goodHost);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -400,8 +400,8 @@ function http11ipHost(request, response) {
|
|||
data = "GET /http/1.1-ip-host HTTP/1.1\r\n" +
|
||||
"Host: 127.0.0.1:4444\r\n" +
|
||||
"\r\n";
|
||||
function check11ipHost(data) {
|
||||
var iter = LineIterator(data);
|
||||
function check11ipHost(aData) {
|
||||
var iter = LineIterator(aData);
|
||||
|
||||
// Status-Line
|
||||
Assert.equal(iter.next().value, "HTTP/1.1 200 TEST PASSED");
|
||||
|
@ -422,7 +422,7 @@ function check11ipHost(data) {
|
|||
|
||||
expectLines(iter, body);
|
||||
}
|
||||
test = new RawTest("localhost", PORT, data, check11ipHost),
|
||||
test = new RawTest("localhost", PORT, data, check11ipHost);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -433,7 +433,7 @@ tests.push(test);
|
|||
data = "GET http://localhost:4444/http/1.1-good-host HTTP/1.1\r\n" +
|
||||
"Host: localhost:4444\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check11goodHost),
|
||||
test = new RawTest("localhost", PORT, data, check11goodHost);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -444,7 +444,7 @@ tests.push(test);
|
|||
data = "GET http://localhost:4444/http/1.1-good-host HTTP/1.1\r\n" +
|
||||
"Host: localhost:1234\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check11goodHost),
|
||||
test = new RawTest("localhost", PORT, data, check11goodHost);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -455,7 +455,7 @@ tests.push(test);
|
|||
data = "GET http://localhost:4444/http/1.1-good-host HTTP/1.1\r\n" +
|
||||
"Host: not-localhost:4444\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check11goodHost),
|
||||
test = new RawTest("localhost", PORT, data, check11goodHost);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -466,13 +466,13 @@ tests.push(test);
|
|||
data = "GET http://localhost:4444/http/1.1-good-host HTTP/1.1\r\n" +
|
||||
"Host: yippity-skippity\r\n" +
|
||||
"\r\n";
|
||||
function checkInaccurate(data) {
|
||||
check11goodHost(data);
|
||||
function checkInaccurate(aData) {
|
||||
check11goodHost(aData);
|
||||
|
||||
// dynamism setup
|
||||
srv.identity.setPrimary("http", "127.0.0.1", 4444);
|
||||
}
|
||||
test = new RawTest("localhost", PORT, data, checkInaccurate),
|
||||
test = new RawTest("localhost", PORT, data, checkInaccurate);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -483,8 +483,8 @@ tests.push(test);
|
|||
data = "GET /http/1.0-request HTTP/1.0\r\n" +
|
||||
"Host: not-localhost:4444\r\n" +
|
||||
"\r\n";
|
||||
function check10ip(data) {
|
||||
var iter = LineIterator(data);
|
||||
function check10ip(aData) {
|
||||
var iter = LineIterator(aData);
|
||||
|
||||
// Status-Line
|
||||
Assert.equal(iter.next().value, "HTTP/1.0 200 TEST PASSED");
|
||||
|
@ -505,7 +505,7 @@ function check10ip(data) {
|
|||
|
||||
expectLines(iter, body);
|
||||
}
|
||||
test = new RawTest("localhost", PORT, data, check10ip),
|
||||
test = new RawTest("localhost", PORT, data, check10ip);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -518,8 +518,8 @@ function http11goodHostWackyPort(request, response) {
|
|||
data = "GET /http/1.1-good-host-wacky-port HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"\r\n";
|
||||
function check11goodHostWackyPort(data) {
|
||||
var iter = LineIterator(data);
|
||||
function check11goodHostWackyPort(aData) {
|
||||
var iter = LineIterator(aData);
|
||||
|
||||
// Status-Line
|
||||
Assert.equal(iter.next().value, "HTTP/1.1 200 TEST PASSED");
|
||||
|
@ -540,7 +540,7 @@ function check11goodHostWackyPort(data) {
|
|||
|
||||
expectLines(iter, body);
|
||||
}
|
||||
test = new RawTest("localhost", PORT, data, check11goodHostWackyPort),
|
||||
test = new RawTest("localhost", PORT, data, check11goodHostWackyPort);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -549,7 +549,7 @@ tests.push(test);
|
|||
data = "GET /http/1.1-good-host-wacky-port HTTP/1.1\r\n" +
|
||||
"Host: localhost:\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check11goodHostWackyPort),
|
||||
test = new RawTest("localhost", PORT, data, check11goodHostWackyPort);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -558,7 +558,7 @@ tests.push(test);
|
|||
data = "GET http://localhost/http/1.1-good-host-wacky-port HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check11goodHostWackyPort),
|
||||
test = new RawTest("localhost", PORT, data, check11goodHostWackyPort);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -567,7 +567,7 @@ tests.push(test);
|
|||
data = "GET http://localhost:/http/1.1-good-host-wacky-port HTTP/1.1\r\n" +
|
||||
"Host: localhost\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check11goodHostWackyPort),
|
||||
test = new RawTest("localhost", PORT, data, check11goodHostWackyPort);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -576,7 +576,7 @@ tests.push(test);
|
|||
data = "GET http://localhost:80/http/1.1-good-host-wacky-port HTTP/1.1\r\n" +
|
||||
"Host: who-cares\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check11goodHostWackyPort),
|
||||
test = new RawTest("localhost", PORT, data, check11goodHostWackyPort);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -585,7 +585,7 @@ tests.push(test);
|
|||
data = "GET is-this-the-real-life-is-this-just-fantasy HTTP/1.1\r\n" +
|
||||
"Host: localhost:4444\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check400),
|
||||
test = new RawTest("localhost", PORT, data, check400);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -594,7 +594,7 @@ tests.push(test);
|
|||
data = "GET /http/1.1-request HTTP/1.1\r\n" +
|
||||
"Host: la la la\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check400),
|
||||
test = new RawTest("localhost", PORT, data, check400);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -603,7 +603,7 @@ tests.push(test);
|
|||
data = "GET http://localhost:4444/http/1.1-good-host HTTP/1.1\r\n" +
|
||||
"Host: la la la\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check11goodHost),
|
||||
test = new RawTest("localhost", PORT, data, check11goodHost);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -612,7 +612,7 @@ tests.push(test);
|
|||
data = "GET http://localhost:4444/http/1.1-request HTTP/1.0\r\n" +
|
||||
"Host: localhost:4444\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check400),
|
||||
test = new RawTest("localhost", PORT, data, check400);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -621,7 +621,7 @@ tests.push(test);
|
|||
data = "GET http://not-localhost:4444/http/1.1-request HTTP/1.1\r\n" +
|
||||
"Host: not-localhost:4444\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check400),
|
||||
test = new RawTest("localhost", PORT, data, check400);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -630,5 +630,5 @@ tests.push(test);
|
|||
data = "GET http://not-localhost:4444/http/1.1-request HTTP/1.1\r\n" +
|
||||
"Host: localhost:4444\r\n" +
|
||||
"\r\n";
|
||||
test = new RawTest("localhost", PORT, data, check400),
|
||||
test = new RawTest("localhost", PORT, data, check400);
|
||||
tests.push(test);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* 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/. */
|
||||
|
||||
|
||||
/*
|
||||
* Tests for correct behavior of asynchronous responses.
|
||||
*/
|
||||
|
@ -122,8 +123,8 @@ function handleAsync2(request, response) {
|
|||
response.setHeader("X-Custom-Header", "value", false);
|
||||
|
||||
callLater(startToHeaderDelay, function() {
|
||||
var body = "BO";
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
var preBody = "BO";
|
||||
response.bodyOutputStream.write(preBody, preBody.length);
|
||||
|
||||
try {
|
||||
response.setStatusLine(request.httpVersion, 500, "after body write");
|
||||
|
@ -139,8 +140,8 @@ function handleAsync2(request, response) {
|
|||
}
|
||||
|
||||
callLater(startToFinishedDelay - startToHeaderDelay, function() {
|
||||
var body = "DY";
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
var postBody = "DY";
|
||||
response.bodyOutputStream.write(postBody, postBody.length);
|
||||
|
||||
response.finish();
|
||||
response.finish(); // idempotency
|
||||
|
|
|
@ -3,6 +3,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/. */
|
||||
/* eslint-disable no-control-regex */
|
||||
|
||||
/*
|
||||
* Verify the presence of explicit QueryInterface methods on XPCOM objects
|
||||
|
@ -24,9 +25,8 @@ var srv;
|
|||
function run_test() {
|
||||
srv = createServer();
|
||||
|
||||
var qi;
|
||||
try {
|
||||
qi = srv.identity.QueryInterface(Ci.nsIHttpServerIdentity);
|
||||
srv.identity.QueryInterface(Ci.nsIHttpServerIdentity);
|
||||
} catch (e) {
|
||||
var exstr = ("" + e).split(/[\x09\x20-\x7f\x81-\xff]+/)[0];
|
||||
do_throw("server identity didn't QI: " + exstr);
|
||||
|
|
|
@ -28,7 +28,7 @@ function run_test() {
|
|||
* BEGIN TESTS *
|
||||
***************/
|
||||
|
||||
var test, data, str;
|
||||
var test, gData, str;
|
||||
var tests = [];
|
||||
|
||||
|
||||
|
@ -51,9 +51,9 @@ if (reallyLong.length !== 524288)
|
|||
str = "GET /very-long-request-line?" + reallyLong + " HTTP/1.1\r\n" +
|
||||
"Host: localhost:" + PORT + "\r\n" +
|
||||
"\r\n";
|
||||
data = [];
|
||||
for (var i = 0; i < str.length; i += 16384)
|
||||
data.push(str.substr(i, 16384));
|
||||
gData = [];
|
||||
for (let i = 0; i < str.length; i += 16384)
|
||||
gData.push(str.substr(i, 16384));
|
||||
|
||||
function checkVeryLongRequestLine(data) {
|
||||
var iter = LineIterator(data);
|
||||
|
@ -80,7 +80,7 @@ function checkVeryLongRequestLine(data) {
|
|||
|
||||
expectLines(iter, body);
|
||||
}
|
||||
test = new RawTest("localhost", PORT, data, checkVeryLongRequestLine),
|
||||
test = new RawTest("localhost", PORT, gData, checkVeryLongRequestLine);
|
||||
tests.push(test);
|
||||
|
||||
|
||||
|
@ -90,15 +90,15 @@ function lotsOfLeadingBlankLines(request, response) {
|
|||
}
|
||||
|
||||
var blankLines = "\r\n";
|
||||
for (var i = 0; i < 14; i++)
|
||||
for (let i = 0; i < 14; i++)
|
||||
blankLines += blankLines;
|
||||
str = blankLines +
|
||||
"GET /lots-of-leading-blank-lines HTTP/1.1\r\n" +
|
||||
"Host: localhost:" + PORT + "\r\n" +
|
||||
"\r\n";
|
||||
data = [];
|
||||
for (var i = 0; i < str.length; i += 100)
|
||||
data.push(str.substr(i, 100));
|
||||
gData = [];
|
||||
for (let i = 0; i < str.length; i += 100)
|
||||
gData.push(str.substr(i, 100));
|
||||
|
||||
function checkLotsOfLeadingBlankLines(data) {
|
||||
var iter = LineIterator(data);
|
||||
|
@ -126,5 +126,5 @@ function checkLotsOfLeadingBlankLines(data) {
|
|||
expectLines(iter, body);
|
||||
}
|
||||
|
||||
test = new RawTest("localhost", PORT, data, checkLotsOfLeadingBlankLines),
|
||||
test = new RawTest("localhost", PORT, gData, checkLotsOfLeadingBlankLines);
|
||||
tests.push(test);
|
||||
|
|
|
@ -173,6 +173,7 @@ function checkForFinish() {
|
|||
try {
|
||||
do_throw("uh-oh, how are we being finished twice?!?!");
|
||||
} finally {
|
||||
// eslint-disable-next-line no-undef
|
||||
quit(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ module.exports = {
|
|||
"do_load_child_test_harness": false,
|
||||
"do_load_manifest": false,
|
||||
"do_load_module": false,
|
||||
"do_note_exception": false,
|
||||
"do_parse_document": false,
|
||||
"do_report_unexpected_exception": false,
|
||||
"do_send_remote_message": false,
|
||||
|
|
Загрузка…
Ссылка в новой задаче