2018-01-30 02:20:18 +03:00
|
|
|
ChromeUtils.import("resource://testing-common/httpd.js");
|
|
|
|
ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
2010-07-28 22:33:06 +04:00
|
|
|
|
|
|
|
var httpServer = null;
|
|
|
|
|
|
|
|
function make_channel(url, callback, ctx) {
|
2015-12-23 07:57:57 +03:00
|
|
|
return NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
|
2010-07-28 22:33:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
const responseBody = "response body";
|
|
|
|
|
|
|
|
function contentHandler(metadata, response)
|
|
|
|
{
|
|
|
|
response.setHeader("Content-Type", "text/plain");
|
|
|
|
response.bodyOutputStream.write(responseBody, responseBody.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
function finish_test(request, buffer)
|
|
|
|
{
|
2017-12-21 13:08:17 +03:00
|
|
|
Assert.equal(buffer, responseBody);
|
2010-07-28 22:33:06 +04:00
|
|
|
httpServer.stop(do_test_finished);
|
|
|
|
}
|
|
|
|
|
|
|
|
function run_test()
|
|
|
|
{
|
2012-08-14 18:06:04 +04:00
|
|
|
httpServer = new HttpServer();
|
2010-07-28 22:33:06 +04:00
|
|
|
httpServer.registerPathHandler("/content", contentHandler);
|
2013-07-19 21:19:28 +04:00
|
|
|
httpServer.start(-1);
|
2010-07-28 22:33:06 +04:00
|
|
|
|
|
|
|
var prefserv = Cc["@mozilla.org/preferences-service;1"].
|
|
|
|
getService(Ci.nsIPrefService);
|
|
|
|
var prefs = prefserv.getBranch("network.proxy.");
|
|
|
|
prefs.setIntPref("type", 2);
|
|
|
|
prefs.setCharPref("autoconfig_url", "data:text/plain," +
|
2013-07-19 21:19:28 +04:00
|
|
|
"function FindProxyForURL(url, host) {return 'PROXY localhost:" +
|
|
|
|
httpServer.identity.primaryPort + "';}"
|
2010-07-28 22:33:06 +04:00
|
|
|
);
|
|
|
|
|
2013-07-19 21:19:28 +04:00
|
|
|
var chan = make_channel("http://localhost:" +
|
|
|
|
httpServer.identity.primaryPort + "/content");
|
2015-12-23 07:57:57 +03:00
|
|
|
chan.asyncOpen2(new ChannelListener(finish_test, null));
|
2010-07-28 22:33:06 +04:00
|
|
|
do_test_pending();
|
|
|
|
}
|