43 let
pb =
Cc[
"@mozilla.org/privatebrowsing;1"].
45 let
dm =
Cc[
"@mozilla.org/download-manager;1"].
49 let
iosvc =
Cc[
"@mozilla.org/network/io-service;1"].
51 let panel = document.getElementById(
"download-monitor");
56 resultFileName:
"pbtest-1",
57 downloadName:
"PB Test 1"
65 ok(!panel.hidden,
"The download panel should be successfully added initially");
68 pb.privateBrowsingEnabled =
true;
71 ok(panel.hidden,
"The download panel should be hidden when entering the private browsing mode");
75 resultFileName:
"pbtest-2",
76 downloadName:
"PB Test 2"
83 ok(!panel.hidden,
"The download panel should show up when a new download is added");
86 pb.privateBrowsingEnabled =
false;
89 ok(panel.hidden,
"The download panel should be hidden when leaving the private browsing mode");
92 let dls = dm.activeDownloads;
93 while (dls.hasMoreElements()) {
94 let dl = dls.getNext().QueryInterface(
Ci.nsIDownload);
95 dm.removeDownload(dl.id);
96 let file = dl.targetFile;
123 if (!(
"resultFileName" in aParams))
124 aParams.resultFileName =
"download.result";
125 if (!(
"targetFile" in aParams)) {
126 let
dirSvc =
Cc[
"@mozilla.org/file/directory_service;1"].
128 aParams.targetFile = dirSvc.get(
"ProfD",
Ci.nsIFile);
129 aParams.targetFile.append(aParams.resultFileName);
131 if (!(
"sourceURI" in aParams))
132 aParams.sourceURI =
"http://localhost:8888/browser/browser/components/privatebrowsing/test/browser/staller.sjs";
133 if (!(
"downloadName" in aParams))
134 aParams.downloadName =
null;
135 if (!(
"runBeforeStart" in aParams))
136 aParams.runBeforeStart =
function () {};
138 const nsIWBP =
Ci.nsIWebBrowserPersist;
139 let persist =
Cc[
"@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
140 .createInstance(
Ci.nsIWebBrowserPersist);
141 persist.persistFlags = nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES |
142 nsIWBP.PERSIST_FLAGS_BYPASS_CACHE |
143 nsIWBP.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
145 let dl =
dm.addDownload(
Ci.nsIDownloadManager.DOWNLOAD_TYPE_DOWNLOAD,
148 Math.round(Date.now() * 1000),
null, persist);
152 let
test =
dm.getDownload(dl.id);
154 aParams.runBeforeStart.call(undefined, dl);
156 persist.progressListener = dl.QueryInterface(
Ci.nsIWebProgressListener);
164 let
ios =
Cc[
"@mozilla.org/network/io-service;1"].
166 return (aObj instanceof
Ci.nsIFile) ? ios.newFileURI(aObj) :
getService(Ci.sbIFaceplateManager)
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
function addDownload(dm, aParams)