2020-04-07 19:00:03 +03:00
|
|
|
"use strict";
|
|
|
|
|
2019-01-17 21:18:31 +03:00
|
|
|
const { HttpServer } = ChromeUtils.import("resource://testing-common/httpd.js");
|
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) {
|
|
|
|
Assert.equal(buffer, responseBody);
|
|
|
|
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"
|
|
|
|
);
|
2019-02-12 19:08:25 +03:00
|
|
|
chan.asyncOpen(new ChannelListener(finish_test, null));
|
2010-07-28 22:33:06 +04:00
|
|
|
do_test_pending();
|
|
|
|
}
|