Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / netwerk / test / unit / test_proxy-failover_canceled.js
bloba40a0c331642436a551f64e3f03d5eca5a134eb7
1 "use strict";
3 const { HttpServer } = ChromeUtils.importESModule(
4 "resource://testing-common/httpd.sys.mjs"
5 );
7 var httpServer = null;
9 function make_channel(url) {
10 return NetUtil.newChannel({
11 uri: url,
12 loadUsingSystemPrincipal: true,
13 });
16 const responseBody = "response body";
18 function contentHandler(metadata, response) {
19 response.setHeader("Content-Type", "text/plain");
20 response.bodyOutputStream.write(responseBody, responseBody.length);
23 function finish_test(request, buffer) {
24 Assert.equal(buffer, "");
25 httpServer.stop(do_test_finished);
28 function run_test() {
29 httpServer = new HttpServer();
30 httpServer.registerPathHandler("/content", contentHandler);
31 httpServer.start(-1);
33 // we want to cancel the failover proxy engage, so, do not allow
34 // redirects from now.
36 var nc = new ChannelEventSink();
37 nc._flags = ES_ABORT_REDIRECT;
39 var prefs = Services.prefs.getBranch("network.proxy.");
40 prefs.setIntPref("type", 2);
41 prefs.setCharPref("no_proxies_on", "nothing");
42 prefs.setBoolPref("allow_hijacking_localhost", true);
43 prefs.setCharPref(
44 "autoconfig_url",
45 "data:text/plain," +
46 "function FindProxyForURL(url, host) {return 'PROXY a_non_existent_domain_x7x6c572v:80; PROXY localhost:" +
47 httpServer.identity.primaryPort +
48 "';}"
51 var chan = make_channel(
52 "http://localhost:" + httpServer.identity.primaryPort + "/content"
54 chan.notificationCallbacks = nc;
55 chan.asyncOpen(new ChannelListener(finish_test, null, CL_EXPECT_FAILURE));
56 do_test_pending();