Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / netwerk / test / unit / test_bug369787.js
blob3bec08f58845ab1a4b0ccc75f381f655ad199a77
1 do_import_script("netwerk/test/httpserver/httpd.js");
3 const BUGID = "369787";
4 var server = null;
5 var channel = null;
7 function change_content_type() {
8 var origType = channel.contentType;
9 const newType = "x-foo/x-bar";
10 channel.contentType = newType;
11 do_check_eq(channel.contentType, newType);
12 channel.contentType = origType;
13 do_check_eq(channel.contentType, origType);
16 function TestListener() {
18 TestListener.prototype.onStartRequest = function(request, context) {
19 change_content_type();
21 TestListener.prototype.onStopRequest = function(request, context, status) {
22 change_content_type();
24 do_timeout(0, "after_channel_closed()");
27 function after_channel_closed() {
28 try {
29 change_content_type();
30 } finally {
31 server.stop();
32 do_test_finished();
36 function run_test() {
37 // start server
38 server = new nsHttpServer();
40 server.registerPathHandler("/bug" + BUGID, bug369787);
42 server.start(4444);
44 // make request
45 channel =
46 Components.classes["@mozilla.org/network/io-service;1"].
47 getService(Components.interfaces.nsIIOService).
48 newChannel("http://localhost:4444/bug" + BUGID, null, null);
50 channel.QueryInterface(Components.interfaces.nsIHttpChannel);
51 channel.asyncOpen(new TestListener(), null);
53 do_test_pending();
56 // PATH HANDLER FOR /bug369787
57 function bug369787(metadata, response) {
58 /* do nothing */