netwerk/test/unit/test_proxy-failover_passing.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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, responseBody);
    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   var prefserv = Cc["@mozilla.org/preferences-service;1"].
    32                  getService(Ci.nsIPrefService);
    33   var prefs = prefserv.getBranch("network.proxy.");
    34   prefs.setIntPref("type", 2);
    35   prefs.setCharPref("autoconfig_url", "data:text/plain," +
    36     "function FindProxyForURL(url, host) {return 'PROXY a_non_existent_domain_x7x6c572v:80; PROXY localhost:" +
    37     httpServer.identity.primaryPort + "';}"
    38   );
    40   var chan = make_channel("http://localhost:" +
    41                           httpServer.identity.primaryPort + "/content");
    42   chan.asyncOpen(new ChannelListener(finish_test, null), null);
    43   do_test_pending();
    44 }

mercurial