Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- Manifest: netwerk/test/unit/xpcshell.toml
"use strict";
const { HttpServer } = ChromeUtils.importESModule(
);
/*
* Test whether we fail bad URIs in HTTP redirect as CORRUPTED_CONTENT.
*/
var httpServer = null;
var BadRedirectPath = "/BadRedirect";
ChromeUtils.defineLazyGetter(this, "BadRedirectURI", function () {
return (
);
});
function make_channel(url) {
return NetUtil.newChannel({ uri: url, loadUsingSystemPrincipal: true });
}
function BadRedirectHandler(metadata, response) {
response.setStatusLine(metadata.httpVersion, 301, "Moved");
// '>' in URI will fail to parse: we should not render response
}
function checkFailed(request) {
Assert.equal(request.status, Cr.NS_ERROR_CORRUPTED_CONTENT);
httpServer.stop(do_test_finished);
}
function run_test() {
httpServer = new HttpServer();
httpServer.registerPathHandler(BadRedirectPath, BadRedirectHandler);
httpServer.start(-1);
var chan = make_channel(BadRedirectURI);
chan.asyncOpen(new ChannelListener(checkFailed, null, CL_EXPECT_FAILURE));
do_test_pending();
}