netwerk/test/unit/test_proxy-replace_canceled.js

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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   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 localhost:" +
    37     httpServer.identity.primaryPort + "';}"
    38   );
    40   // this test assumed that a AsyncOnChannelRedirect query is made for
    41   // each proxy failover or on the inital proxy only when PAC mode is used.
    42   // Neither of those are documented anywhere that I can find and the latter
    43   // hasn't been a useful property because it is PAC dependent and the type
    44   // is generally unknown and OS driven. 769764 changed that to remove the
    45   // internal redirect used to setup the initial proxy/channel as that isn't
    46   // a redirect in any sense.
    48   var chan = make_channel("http://localhost:" +
    49                           httpServer.identity.primaryPort + "/content");
    50   chan.asyncOpen(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE), null);
    51   chan.cancel(Cr.NS_BINDING_ABORTED);
    52   do_test_pending();
    53 }

mercurial