Go to the source code of this file.
Functions | |
do_load_httpd_js () | |
function | createServer () |
function | makeChannel (url) |
function | makeBIS (stream) |
function | fileContents (file) |
function | LineIterator (data) |
function | expectLines (iter, expectedLines) |
function | writeDetails (request, response) |
function | skipHeaders (iter) |
function | isException (e, code) |
function | callLater (msecs, callback) |
function | testComplete (srv) |
function | Test (path, initChannel, onStartRequest, onStopRequest) |
function | runHttpTests (testArray, done) |
function | RawTest (host, port, data, responseCheck) |
function | runRawTests (testArray, done) |
Variables | |
DEBUG = true | |
const | Timer = CC("@mozilla.org/timer;1", "nsITimer", "initWithCallback") |
var | __pendingTimers = [] |
const | __timerFuzz = 15 |
function callLater | ( | msecs, | |
callback | |||
) |
Calls the given function at least the specified number of milliseconds later. The callback will not undershoot the given time, but it might overshoot – don't expect precision!
milliseconds | : uint the number of milliseconds to delay |
callback | : function() : void the function to call |
Definition at line 237 of file head_utils.js.
function createServer | ( | ) |
Constructs a new nsHttpServer instance. This function is intended to encapsulate construction of a server so that at some point in the future it is possible to run these tests (with at most slight modifications) against the server when used as an XPCOM component (not as an inline script).
Definition at line 53 of file head_utils.js.
do_load_httpd_js | ( | ) |
function expectLines | ( | iter, | |
expectedLines | |||
) |
Throws if iter does not contain exactly the CRLF-separated lines in the array expectedLines.
iter | : Iterator an Iterator which returns lines of text |
expectedLines | : [string] an array of the expected lines of text |
string | an error message if iter doesn't agree with expectedLines |
Definition at line 142 of file head_utils.js.
function fileContents | ( | file | ) |
Returns the contents of the file as a string.
file | : nsILocalFile the file whose contents are to be read |
Definition at line 94 of file head_utils.js.
function isException | ( | e, | |
code | |||
) |
Checks that the exception e (which may be an XPConnect-created exception object or a raw nsresult number) is the given nsresult.
e | : Exception or nsresult the actual exception |
code | : nsresult the expected exception |
Definition at line 207 of file head_utils.js.
function LineIterator | ( | data | ) |
Iterates over the lines, delimited by CRLF, in data, returning each line without the trailing line separator.
data | : string a string consisting of lines of data separated by CRLFs |
Definition at line 115 of file head_utils.js.
function makeBIS | ( | stream | ) |
Make a binary input stream wrapper for the given stream.
stream | the nsIInputStream to wrap |
Definition at line 80 of file head_utils.js.
function makeChannel | ( | url | ) |
Creates a new HTTP channel.
url | the URL of the channel to create |
Definition at line 64 of file head_utils.js.
function RawTest | ( | host, | |
port, | |||
data, | |||
responseCheck | |||
) |
Sends a raw string of bytes to the given host and port and checks that the response is acceptable.
host | : string the host to which a connection should be made |
port | : PRUint16 the port to use for the connection |
data | : string or [string...] either:
|
responseCheck | : function(string) : void a function which is provided with the data sent by the remote host which conducts whatever tests it wants on that data; useful for tweaking the test environment between tests |
Definition at line 476 of file head_utils.js.
function runHttpTests | ( | testArray, | |
done | |||
) |
Runs all the tests in testArray.
testArray | a non-empty array of Tests to run, in order |
done | function to call when all tests have run (e.g. to shut down the server) |
Kicks off running the next test in the array.
Index of the test being run.
Stream listener for the channels.
Array of bytes of data in body of response.
Definition at line 340 of file head_utils.js.
function runRawTests | ( | testArray, | |
done | |||
) |
Runs all the tests in testArray, an array of RawTests.
testArray | : [RawTest] an array of RawTests to run, in order |
done | function to call when all tests have run (e.g. to shut down the server) |
Kicks off running the next test in the array.
Index of the test being run.
Index of remaining data strings to be written to the socket in current test.
Data received so far from the server.
Reads data from the socket.
Writes data to the socket.
Definition at line 501 of file head_utils.js.
function skipHeaders | ( | iter | ) |
Advances iter past all non-blank lines and a single blank line, after which point the body of the response will be returned next from the iterator.
iter | : Iterator an iterator over the CRLF-delimited lines in an HTTP response, currently just after the Request-Line |
Definition at line 191 of file head_utils.js.
function Test | ( | path, | |
initChannel, | |||
onStartRequest, | |||
onStopRequest | |||
) |
Represents a path to load from the tested HTTP server, along with actions to take before, during, and after loading the associated page.
path | the URL to load from the server |
initChannel | a function which takes as a single parameter a channel created for path and initializes its state, or null if no additional initialization is needed |
onStartRequest | called during onStartRequest for the load of the URL, with the same parameters; the request parameter has been QI'd to nsIHttpChannel and nsIHttpChannelInternal for convenience; may be null if nothing needs to be done |
onStopRequest | called during onStopRequest for the channel, with the same parameters plus a trailing parameter containing an array of the bytes of data downloaded in the body of the channel response; the request parameter has been QI'd to nsIHttpChannel and nsIHttpChannelInternal for convenience; may be null if nothing needs to be done |
Definition at line 322 of file head_utils.js.
function testComplete | ( | srv | ) |
Create a completion callback which will stop the given server and end the test, assuming nothing else remains to be done at that point.
Definition at line 292 of file head_utils.js.
function writeDetails | ( | request, | |
response | |||
) |
Spew a bunch of HTTP metadata from request into the body of response.
request | : nsIHttpRequestMetadata the request whose metadata should be output |
response | : nsIHttpResponse the response to which the metadata is written |
Definition at line 172 of file head_utils.js.
var __pendingTimers = [] |
Pending timers used by callLater, which must store them to avoid the timer being canceled and destroyed. Stupid API...
Definition at line 217 of file head_utils.js.
const __timerFuzz = 15 |
Date.now() is not necessarily monotonically increasing (insert sob story about times not being the right tool to use for measuring intervals of time, robarnold can tell all), so be wary of error by erring by at least __timerFuzz ms.
Definition at line 225 of file head_utils.js.
DEBUG = true |
Definition at line 42 of file head_utils.js.
const Timer = CC("@mozilla.org/timer;1", "nsITimer", "initWithCallback") |
Definition at line 44 of file head_utils.js.