1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/test/unit/test_proxy-failover_passing.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +Cu.import("resource://testing-common/httpd.js"); 1.5 + 1.6 +var httpServer = null; 1.7 + 1.8 +function make_channel(url, callback, ctx) { 1.9 + var ios = Cc["@mozilla.org/network/io-service;1"]. 1.10 + getService(Ci.nsIIOService); 1.11 + return ios.newChannel(url, "", null); 1.12 +} 1.13 + 1.14 +const responseBody = "response body"; 1.15 + 1.16 +function contentHandler(metadata, response) 1.17 +{ 1.18 + response.setHeader("Content-Type", "text/plain"); 1.19 + response.bodyOutputStream.write(responseBody, responseBody.length); 1.20 +} 1.21 + 1.22 +function finish_test(request, buffer) 1.23 +{ 1.24 + do_check_eq(buffer, responseBody); 1.25 + httpServer.stop(do_test_finished); 1.26 +} 1.27 + 1.28 +function run_test() 1.29 +{ 1.30 + httpServer = new HttpServer(); 1.31 + httpServer.registerPathHandler("/content", contentHandler); 1.32 + httpServer.start(-1); 1.33 + 1.34 + var prefserv = Cc["@mozilla.org/preferences-service;1"]. 1.35 + getService(Ci.nsIPrefService); 1.36 + var prefs = prefserv.getBranch("network.proxy."); 1.37 + prefs.setIntPref("type", 2); 1.38 + prefs.setCharPref("autoconfig_url", "data:text/plain," + 1.39 + "function FindProxyForURL(url, host) {return 'PROXY a_non_existent_domain_x7x6c572v:80; PROXY localhost:" + 1.40 + httpServer.identity.primaryPort + "';}" 1.41 + ); 1.42 + 1.43 + var chan = make_channel("http://localhost:" + 1.44 + httpServer.identity.primaryPort + "/content"); 1.45 + chan.asyncOpen(new ChannelListener(finish_test, null), null); 1.46 + do_test_pending(); 1.47 +}