Wed, 31 Dec 2014 06:55:46 +0100
Added tag TORBROWSER_REPLICA for changeset 6474c204b198
1 Cu.import("resource://testing-common/httpd.js");
3 var httpServer = null;
5 function make_channel(url, callback, ctx) {
6 var ios = Cc["@mozilla.org/network/io-service;1"].
7 getService(Ci.nsIIOService);
8 return ios.newChannel(url, "", null);
9 }
11 const responseBody = "response body";
13 function contentHandler(metadata, response)
14 {
15 response.setHeader("Content-Type", "text/plain");
16 response.bodyOutputStream.write(responseBody, responseBody.length);
17 }
19 function finish_test(request, buffer)
20 {
21 do_check_eq(buffer, "");
22 httpServer.stop(do_test_finished);
23 }
25 function run_test()
26 {
27 httpServer = new HttpServer();
28 httpServer.registerPathHandler("/content", contentHandler);
29 httpServer.start(-1);
31 // we want to cancel the failover proxy engage, so, do not allow
32 // redirects from now.
34 var nc = new ChannelEventSink();
35 nc._flags = ES_ABORT_REDIRECT;
37 var prefserv = Cc["@mozilla.org/preferences-service;1"].
38 getService(Ci.nsIPrefService);
39 var prefs = prefserv.getBranch("network.proxy.");
40 prefs.setIntPref("type", 2);
41 prefs.setCharPref("autoconfig_url", "data:text/plain," +
42 "function FindProxyForURL(url, host) {return 'PROXY a_non_existent_domain_x7x6c572v:80; PROXY localhost:" +
43 httpServer.identity.primaryPort + "';}"
44 );
46 var chan = make_channel("http://localhost:" +
47 httpServer.identity.primaryPort + "/content");
48 chan.notificationCallbacks = nc;
49 chan.asyncOpen(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE), null);
50 do_test_pending();
51 }