Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / netwerk / test / unit / test_proxy-failover_passing.js
blobdc0cba58b1a1540e29f6cb7efc0bed4e29569005
1 "use strict";
3 const { HttpServer } = ChromeUtils.importESModule(
4 "resource://testing-common/httpd.sys.mjs"
5 );
7 var httpServer = null;
9 function make_channel(url) {
10 return NetUtil.newChannel({ uri: url, loadUsingSystemPrincipal: true });
13 const responseBody = "response body";
15 function contentHandler(metadata, response) {
16 response.setHeader("Content-Type", "text/plain");
17 response.bodyOutputStream.write(responseBody, responseBody.length);
20 function finish_test(request, buffer) {
21 Assert.equal(buffer, responseBody);
22 httpServer.stop(do_test_finished);
25 function run_test() {
26 httpServer = new HttpServer();
27 httpServer.registerPathHandler("/content", contentHandler);
28 httpServer.start(-1);
30 var prefs = Services.prefs.getBranch("network.proxy.");
31 prefs.setIntPref("type", 2);
32 prefs.setCharPref(
33 "autoconfig_url",
34 "data:text/plain," +
35 "function FindProxyForURL(url, host) {return 'PROXY a_non_existent_domain_x7x6c572v:80; PROXY localhost:" +
36 httpServer.identity.primaryPort +
37 "';}"
40 var chan = make_channel(
41 "http://localhost:" + httpServer.identity.primaryPort + "/content"
43 chan.asyncOpen(new ChannelListener(finish_test, null));
44 do_test_pending();