netwerk/test/unit/test_bug412945.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 Cu.import("resource://testing-common/httpd.js");
michael@0 2
michael@0 3 var httpserv;
michael@0 4
michael@0 5 function TestListener() {
michael@0 6 }
michael@0 7
michael@0 8 TestListener.prototype.onStartRequest = function(request, context) {
michael@0 9 }
michael@0 10
michael@0 11 TestListener.prototype.onStopRequest = function(request, context, status) {
michael@0 12 httpserv.stop(do_test_finished);
michael@0 13 }
michael@0 14
michael@0 15 function run_test() {
michael@0 16 httpserv = new HttpServer();
michael@0 17
michael@0 18 httpserv.registerPathHandler("/bug412945", bug412945);
michael@0 19
michael@0 20 httpserv.start(-1);
michael@0 21
michael@0 22 // make request
michael@0 23 var channel =
michael@0 24 Components.classes["@mozilla.org/network/io-service;1"].
michael@0 25 getService(Components.interfaces.nsIIOService).
michael@0 26 newChannel("http://localhost:" + httpserv.identity.primaryPort +
michael@0 27 "/bug412945", null, null);
michael@0 28
michael@0 29 channel.QueryInterface(Components.interfaces.nsIHttpChannel);
michael@0 30 channel.requestMethod = "POST";
michael@0 31 channel.asyncOpen(new TestListener(), null);
michael@0 32
michael@0 33 do_test_pending();
michael@0 34 }
michael@0 35
michael@0 36 function bug412945(metadata, response) {
michael@0 37 if (!metadata.hasHeader("Content-Length") ||
michael@0 38 metadata.getHeader("Content-Length") != "0")
michael@0 39 {
michael@0 40 do_throw("Content-Length header not found!");
michael@0 41 }
michael@0 42 }

mercurial