netwerk/test/unit/test_bug412945.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 httpserv;
     5 function TestListener() {
     6 }
     8 TestListener.prototype.onStartRequest = function(request, context) {
     9 }
    11 TestListener.prototype.onStopRequest = function(request, context, status) {
    12   httpserv.stop(do_test_finished);
    13 }
    15 function run_test() {
    16   httpserv = new HttpServer();
    18   httpserv.registerPathHandler("/bug412945", bug412945);
    20   httpserv.start(-1);
    22   // make request
    23   var channel =
    24       Components.classes["@mozilla.org/network/io-service;1"].
    25       getService(Components.interfaces.nsIIOService).
    26       newChannel("http://localhost:" + httpserv.identity.primaryPort +
    27                  "/bug412945", null, null);
    29   channel.QueryInterface(Components.interfaces.nsIHttpChannel);
    30   channel.requestMethod = "POST";
    31   channel.asyncOpen(new TestListener(), null);
    33   do_test_pending();
    34 }
    36 function bug412945(metadata, response) {
    37   if (!metadata.hasHeader("Content-Length") ||
    38       metadata.getHeader("Content-Length") != "0")
    39   {
    40     do_throw("Content-Length header not found!");
    41   }
    42 }

mercurial