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: 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 localhost:" + michael@0: httpServer.identity.primaryPort + "';}" michael@0: ); michael@0: michael@0: // this test assumed that a AsyncOnChannelRedirect query is made for michael@0: // each proxy failover or on the inital proxy only when PAC mode is used. michael@0: // Neither of those are documented anywhere that I can find and the latter michael@0: // hasn't been a useful property because it is PAC dependent and the type michael@0: // is generally unknown and OS driven. 769764 changed that to remove the michael@0: // internal redirect used to setup the initial proxy/channel as that isn't michael@0: // a redirect in any sense. michael@0: michael@0: var chan = make_channel("http://localhost:" + michael@0: httpServer.identity.primaryPort + "/content"); michael@0: chan.asyncOpen(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE), null); michael@0: chan.cancel(Cr.NS_BINDING_ABORTED); michael@0: do_test_pending(); michael@0: }