Wed, 31 Dec 2014 06:55:46 +0100
Added tag TORBROWSER_REPLICA for changeset 6474c204b198
michael@0 | 1 | Cu.import("resource://testing-common/httpd.js"); |
michael@0 | 2 | |
michael@0 | 3 | var httpServer = null; |
michael@0 | 4 | |
michael@0 | 5 | function make_channel(url, callback, ctx) { |
michael@0 | 6 | var ios = Cc["@mozilla.org/network/io-service;1"]. |
michael@0 | 7 | getService(Ci.nsIIOService); |
michael@0 | 8 | return ios.newChannel(url, "", null); |
michael@0 | 9 | } |
michael@0 | 10 | |
michael@0 | 11 | const responseBody = "response body"; |
michael@0 | 12 | |
michael@0 | 13 | function contentHandler(metadata, response) |
michael@0 | 14 | { |
michael@0 | 15 | response.setHeader("Content-Type", "text/plain"); |
michael@0 | 16 | response.bodyOutputStream.write(responseBody, responseBody.length); |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | function finish_test(request, buffer) |
michael@0 | 20 | { |
michael@0 | 21 | do_check_eq(buffer, ""); |
michael@0 | 22 | httpServer.stop(do_test_finished); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | function run_test() |
michael@0 | 26 | { |
michael@0 | 27 | httpServer = new HttpServer(); |
michael@0 | 28 | httpServer.registerPathHandler("/content", contentHandler); |
michael@0 | 29 | httpServer.start(-1); |
michael@0 | 30 | |
michael@0 | 31 | var prefserv = Cc["@mozilla.org/preferences-service;1"]. |
michael@0 | 32 | getService(Ci.nsIPrefService); |
michael@0 | 33 | var prefs = prefserv.getBranch("network.proxy."); |
michael@0 | 34 | prefs.setIntPref("type", 2); |
michael@0 | 35 | prefs.setCharPref("autoconfig_url", "data:text/plain," + |
michael@0 | 36 | "function FindProxyForURL(url, host) {return 'PROXY localhost:" + |
michael@0 | 37 | httpServer.identity.primaryPort + "';}" |
michael@0 | 38 | ); |
michael@0 | 39 | |
michael@0 | 40 | // this test assumed that a AsyncOnChannelRedirect query is made for |
michael@0 | 41 | // each proxy failover or on the inital proxy only when PAC mode is used. |
michael@0 | 42 | // Neither of those are documented anywhere that I can find and the latter |
michael@0 | 43 | // hasn't been a useful property because it is PAC dependent and the type |
michael@0 | 44 | // is generally unknown and OS driven. 769764 changed that to remove the |
michael@0 | 45 | // internal redirect used to setup the initial proxy/channel as that isn't |
michael@0 | 46 | // a redirect in any sense. |
michael@0 | 47 | |
michael@0 | 48 | var chan = make_channel("http://localhost:" + |
michael@0 | 49 | httpServer.identity.primaryPort + "/content"); |
michael@0 | 50 | chan.asyncOpen(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE), null); |
michael@0 | 51 | chan.cancel(Cr.NS_BINDING_ABORTED); |
michael@0 | 52 | do_test_pending(); |
michael@0 | 53 | } |