tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug412945.js (960B)


      1 "use strict";
      2 
      3 const { HttpServer } = ChromeUtils.importESModule(
      4  "resource://testing-common/httpd.sys.mjs"
      5 );
      6 
      7 var httpserv;
      8 
      9 function TestListener() {}
     10 
     11 TestListener.prototype.onStartRequest = function () {};
     12 
     13 TestListener.prototype.onStopRequest = function () {
     14  httpserv.stop(do_test_finished);
     15 };
     16 
     17 function run_test() {
     18  httpserv = new HttpServer();
     19 
     20  httpserv.registerPathHandler("/bug412945", bug412945);
     21 
     22  httpserv.start(-1);
     23 
     24  // make request
     25  var channel = NetUtil.newChannel({
     26    uri: "http://localhost:" + httpserv.identity.primaryPort + "/bug412945",
     27    loadUsingSystemPrincipal: true,
     28  });
     29 
     30  channel.QueryInterface(Ci.nsIHttpChannel);
     31  channel.requestMethod = "POST";
     32  channel.asyncOpen(new TestListener(), null);
     33 
     34  do_test_pending();
     35 }
     36 
     37 function bug412945(metadata) {
     38  if (
     39    !metadata.hasHeader("Content-Length") ||
     40    metadata.getHeader("Content-Length") != "0"
     41  ) {
     42    do_throw("Content-Length header not found!");
     43  }
     44 }