Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
1 //
2 // Simple HTTP test: fetches page
3 //
5 // Note: sets Cc and Ci variables
7 Cu.import("resource://testing-common/httpd.js");
9 var httpserver = new HttpServer();
10 var testpath = "/simple";
11 var httpbody = "0123456789";
12 var buffer = "";
14 var dbg=0
15 if (dbg) { print("============== START =========="); }
17 function run_test() {
18 setup_test();
19 do_test_pending();
20 }
22 function setup_test() {
23 if (dbg) { print("============== setup_test: in"); }
24 httpserver.registerPathHandler(testpath, serverHandler);
25 httpserver.start(-1);
26 var channel = setupChannel(testpath);
27 // ChannelListener defined in head_channels.js
28 channel.asyncOpen(new ChannelListener(checkRequest, channel), null);
29 if (dbg) { print("============== setup_test: out"); }
30 }
32 function setupChannel(path) {
33 var ios = Cc["@mozilla.org/network/io-service;1"].
34 getService(Ci.nsIIOService);
35 var chan = ios.newChannel("http://localhost:" +
36 httpserver.identity.primaryPort + path, "", null);
37 chan.QueryInterface(Ci.nsIHttpChannel);
38 chan.requestMethod = "GET";
39 return chan;
40 }
42 function serverHandler(metadata, response) {
43 if (dbg) { print("============== serverHandler: in"); }
44 response.setHeader("Content-Type", "text/plain", false);
45 response.bodyOutputStream.write(httpbody, httpbody.length);
46 if (dbg) { print("============== serverHandler: out"); }
47 }
49 function checkRequest(request, data, context) {
50 if (dbg) { print("============== checkRequest: in"); }
51 do_check_eq(data, httpbody);
52 httpserver.stop(do_test_finished);
53 if (dbg) { print("============== checkRequest: out"); }
54 }