2 // Private channel test
7 const { HttpServer
} = ChromeUtils
.importESModule(
8 "resource://testing-common/httpd.sys.mjs"
11 var httpserver
= new HttpServer();
12 var testpath
= "/simple";
13 var httpbody
= "0123456789";
16 // Simulate a profile dir for xpcshell
19 // Start off with an empty cache
20 evict_cache_entries();
22 httpserver
.registerPathHandler(testpath
, serverHandler
);
25 var channel
= setupChannel(testpath
);
26 channel
.loadGroup
= Cc
["@mozilla.org/network/load-group;1"].createInstance();
28 channel
.QueryInterface(Ci
.nsIPrivateBrowsingChannel
);
29 channel
.setPrivate(true);
31 channel
.asyncOpen(new ChannelListener(checkRequest
, channel
));
36 function setupChannel(path
) {
37 return NetUtil
.newChannel({
38 uri
: "http://localhost:" + httpserver
.identity
.primaryPort
+ path
,
39 loadUsingSystemPrincipal
: true,
40 }).QueryInterface(Ci
.nsIHttpChannel
);
43 function serverHandler(metadata
, response
) {
44 response
.setHeader("Content-Type", "text/plain", false);
45 response
.bodyOutputStream
.write(httpbody
, httpbody
.length
);
48 function checkRequest() {
49 get_device_entry_count("disk", null, function (count
) {
50 Assert
.equal(count
, 0);
51 get_device_entry_count(
53 Services
.loadContextInfo
.private,
55 Assert
.equal(count1
, 1);
56 httpserver
.stop(do_test_finished
);