michael@0: Cu.import("resource://testing-common/httpd.js"); michael@0: michael@0: var httpServer = null; michael@0: michael@0: function make_channel(url, callback, ctx) { michael@0: var ios = Cc["@mozilla.org/network/io-service;1"]. michael@0: getService(Ci.nsIIOService); michael@0: return ios.newChannel(url, "", null); michael@0: } michael@0: michael@0: const responseBody = "response body"; michael@0: michael@0: function contentHandler(metadata, response) michael@0: { michael@0: response.setHeader("Content-Type", "text/plain"); michael@0: response.bodyOutputStream.write(responseBody, responseBody.length); michael@0: } michael@0: michael@0: function finish_test(request, buffer) michael@0: { michael@0: do_check_eq(buffer, ""); michael@0: httpServer.stop(do_test_finished); michael@0: } michael@0: michael@0: function run_test() michael@0: { michael@0: httpServer = new HttpServer(); michael@0: httpServer.registerPathHandler("/content", contentHandler); michael@0: httpServer.start(-1); michael@0: michael@0: // we want to cancel the failover proxy engage, so, do not allow michael@0: // redirects from now. michael@0: michael@0: var nc = new ChannelEventSink(); michael@0: nc._flags = ES_ABORT_REDIRECT; michael@0: michael@0: var prefserv = Cc["@mozilla.org/preferences-service;1"]. michael@0: getService(Ci.nsIPrefService); michael@0: var prefs = prefserv.getBranch("network.proxy."); michael@0: prefs.setIntPref("type", 2); michael@0: prefs.setCharPref("autoconfig_url", "data:text/plain," + michael@0: "function FindProxyForURL(url, host) {return 'PROXY a_non_existent_domain_x7x6c572v:80; PROXY localhost:" + michael@0: httpServer.identity.primaryPort + "';}" michael@0: ); michael@0: michael@0: var chan = make_channel("http://localhost:" + michael@0: httpServer.identity.primaryPort + "/content"); michael@0: chan.notificationCallbacks = nc; michael@0: chan.asyncOpen(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE), null); michael@0: do_test_pending(); michael@0: }