netwerk/test/unit/test_proxy-failover_passing.js

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

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, responseBody);
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 a_non_existent_domain_x7x6c572v:80; PROXY localhost:" +
michael@0 37 httpServer.identity.primaryPort + "';}"
michael@0 38 );
michael@0 39
michael@0 40 var chan = make_channel("http://localhost:" +
michael@0 41 httpServer.identity.primaryPort + "/content");
michael@0 42 chan.asyncOpen(new ChannelListener(finish_test, null), null);
michael@0 43 do_test_pending();
michael@0 44 }

mercurial