3 const { HttpServer
} = ChromeUtils
.importESModule(
4 "resource://testing-common/httpd.sys.mjs"
7 const BUGID
= "369787";
11 function change_content_type() {
12 var origType
= channel
.contentType
;
13 const newType
= "x-foo/x-bar";
14 channel
.contentType
= newType
;
15 Assert
.equal(channel
.contentType
, newType
);
16 channel
.contentType
= origType
;
17 Assert
.equal(channel
.contentType
, origType
);
20 function TestListener() {}
21 TestListener
.prototype.onStartRequest = function (request
) {
23 // request might be different from channel
24 channel
= request
.QueryInterface(Ci
.nsIChannel
);
26 change_content_type();
32 TestListener
.prototype.onStopRequest = function () {
34 change_content_type();
37 // don't re-throw ex to avoid hanging the test
40 do_timeout(0, after_channel_closed
);
43 function after_channel_closed() {
45 change_content_type();
47 server
.stop(do_test_finished
);
53 server
= new HttpServer();
55 server
.registerPathHandler("/bug" + BUGID
, bug369787
);
60 channel
= NetUtil
.newChannel({
61 uri
: "http://localhost:" + server
.identity
.primaryPort
+ "/bug" + BUGID
,
62 loadUsingSystemPrincipal
: true,
64 channel
.QueryInterface(Ci
.nsIHttpChannel
);
65 channel
.asyncOpen(new TestListener());
70 // PATH HANDLER FOR /bug369787
71 function bug369787() {