3 const { HttpServer
} = ChromeUtils
.importESModule(
4 "resource://testing-common/httpd.sys.mjs"
8 var simplePath
= "/simple";
9 var normalPath
= "/normal";
10 var httpbody
= "<html></html>";
12 ChromeUtils
.defineLazyGetter(this, "uri1", function () {
13 return "http://localhost:" + httpserver
.identity
.primaryPort
+ simplePath
;
16 ChromeUtils
.defineLazyGetter(this, "uri2", function () {
17 return "http://localhost:" + httpserver
.identity
.primaryPort
+ normalPath
;
20 function make_channel(url
) {
21 return NetUtil
.newChannel({ uri
: url
, loadUsingSystemPrincipal
: true });
24 var listener_proto
= {
25 QueryInterface
: ChromeUtils
.generateQI([
30 onStartRequest(request
) {
32 request
.QueryInterface(Ci
.nsIChannel
).contentType
,
35 request
.cancel(Cr
.NS_BINDING_ABORTED
);
39 do_throw("Unexpected onDataAvailable");
42 onStopRequest(request
, status
) {
43 Assert
.equal(status
, Cr
.NS_BINDING_ABORTED
);
44 this.termination_func();
48 function listener(contentType
, termination_func
) {
49 this.contentType
= contentType
;
50 this.termination_func
= termination_func
;
52 listener
.prototype = listener_proto
;
55 httpserver
= new HttpServer();
56 httpserver
.registerPathHandler(simplePath
, simpleHandler
);
57 httpserver
.registerPathHandler(normalPath
, normalHandler
);
60 var channel
= make_channel(uri1
);
62 new listener("text/plain", function () {
70 function run_test2() {
71 var channel
= make_channel(uri2
);
73 new listener("text/html", function () {
74 httpserver
.stop(do_test_finished
);
79 function simpleHandler(metadata
, response
) {
80 response
.seizePower();
81 response
.bodyOutputStream
.write(httpbody
, httpbody
.length
);
85 function normalHandler(metadata
, response
) {
86 response
.bodyOutputStream
.write(httpbody
, httpbody
.length
);