Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / netwerk / test / unit / test_bug369787.js
blob3254bdf568c56c9613784ebec5285e483d39c983
1 "use strict";
3 const { HttpServer } = ChromeUtils.importESModule(
4 "resource://testing-common/httpd.sys.mjs"
5 );
7 const BUGID = "369787";
8 var server = null;
9 var channel = null;
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) {
22 try {
23 // request might be different from channel
24 channel = request.QueryInterface(Ci.nsIChannel);
26 change_content_type();
27 } catch (ex) {
28 print(ex);
29 throw ex;
32 TestListener.prototype.onStopRequest = function () {
33 try {
34 change_content_type();
35 } catch (ex) {
36 print(ex);
37 // don't re-throw ex to avoid hanging the test
40 do_timeout(0, after_channel_closed);
43 function after_channel_closed() {
44 try {
45 change_content_type();
46 } finally {
47 server.stop(do_test_finished);
51 function run_test() {
52 // start server
53 server = new HttpServer();
55 server.registerPathHandler("/bug" + BUGID, bug369787);
57 server.start(-1);
59 // make request
60 channel = NetUtil.newChannel({
61 uri: "http://localhost:" + server.identity.primaryPort + "/bug" + BUGID,
62 loadUsingSystemPrincipal: true,
63 });
64 channel.QueryInterface(Ci.nsIHttpChannel);
65 channel.asyncOpen(new TestListener());
67 do_test_pending();
70 // PATH HANDLER FOR /bug369787
71 function bug369787() {
72 /* do nothing */