Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
1 //
2 // Private channel test
3 //
5 Cu.import("resource://testing-common/httpd.js");
7 var httpserver = new HttpServer();
8 var testpath = "/simple";
9 var httpbody = "0123456789";
11 function run_test() {
12 // Simulate a profile dir for xpcshell
13 do_get_profile();
15 // Start off with an empty cache
16 evict_cache_entries();
18 httpserver.registerPathHandler(testpath, serverHandler);
19 httpserver.start(-1);
21 var channel = setupChannel(testpath);
22 channel.loadGroup = Cc["@mozilla.org/network/load-group;1"].createInstance();
24 channel.QueryInterface(Ci.nsIPrivateBrowsingChannel);
25 channel.setPrivate(true);
27 channel.asyncOpen(new ChannelListener(checkRequest, channel), null);
29 do_test_pending();
30 }
32 function setupChannel(path) {
33 var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
34 return chan = ios.newChannel("http://localhost:" +
35 httpserver.identity.primaryPort + path, "", null)
36 .QueryInterface(Ci.nsIHttpChannel);
37 }
39 function serverHandler(metadata, response) {
40 response.setHeader("Content-Type", "text/plain", false);
41 response.bodyOutputStream.write(httpbody, httpbody.length);
42 }
44 function checkRequest(request, data, context) {
45 get_device_entry_count("disk", null, function(count) {
46 do_check_eq(count, 0)
47 get_device_entry_count("disk", LoadContextInfo.private, function(count) {
48 do_check_eq(count, 1);
49 httpserver.stop(do_test_finished);
50 });
51 });
52 }