michael@0: // michael@0: // Private channel test michael@0: // michael@0: michael@0: Cu.import("resource://testing-common/httpd.js"); michael@0: michael@0: var httpserver = new HttpServer(); michael@0: var testpath = "/simple"; michael@0: var httpbody = "0123456789"; michael@0: michael@0: function run_test() { michael@0: // Simulate a profile dir for xpcshell michael@0: do_get_profile(); michael@0: michael@0: // Start off with an empty cache michael@0: evict_cache_entries(); michael@0: michael@0: httpserver.registerPathHandler(testpath, serverHandler); michael@0: httpserver.start(-1); michael@0: michael@0: var channel = setupChannel(testpath); michael@0: channel.loadGroup = Cc["@mozilla.org/network/load-group;1"].createInstance(); michael@0: michael@0: channel.QueryInterface(Ci.nsIPrivateBrowsingChannel); michael@0: channel.setPrivate(true); michael@0: michael@0: channel.asyncOpen(new ChannelListener(checkRequest, channel), null); michael@0: michael@0: do_test_pending(); michael@0: } michael@0: michael@0: function setupChannel(path) { michael@0: var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); michael@0: return chan = ios.newChannel("http://localhost:" + michael@0: httpserver.identity.primaryPort + path, "", null) michael@0: .QueryInterface(Ci.nsIHttpChannel); michael@0: } michael@0: michael@0: function serverHandler(metadata, response) { michael@0: response.setHeader("Content-Type", "text/plain", false); michael@0: response.bodyOutputStream.write(httpbody, httpbody.length); michael@0: } michael@0: michael@0: function checkRequest(request, data, context) { michael@0: get_device_entry_count("disk", null, function(count) { michael@0: do_check_eq(count, 0) michael@0: get_device_entry_count("disk", LoadContextInfo.private, function(count) { michael@0: do_check_eq(count, 1); michael@0: httpserver.stop(do_test_finished); michael@0: }); michael@0: }); michael@0: }