mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 817999 - remove DownloadMonitorPanel remnants.
r=dao
This commit is contained in:
parent
b9f544bb42
commit
d4380667c2
@ -16,7 +16,6 @@ var gPrevCharset = null;
|
||||
var gProxyFavIcon = null;
|
||||
var gLastValidURLStr = "";
|
||||
var gInPrintPreviewMode = false;
|
||||
var gDownloadMgr = null;
|
||||
var gContextMenu = null; // nsContextMenu instance
|
||||
var gStartupRan = false;
|
||||
|
||||
@ -1339,8 +1338,7 @@ var gBrowserInit = {
|
||||
// If the user manually opens the download manager before the timeout, the
|
||||
// downloads will start right away, and getting the service again won't hurt.
|
||||
setTimeout(function() {
|
||||
gDownloadMgr = Cc["@mozilla.org/download-manager;1"].
|
||||
getService(Ci.nsIDownloadManager);
|
||||
Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager);
|
||||
|
||||
#ifdef XP_WIN
|
||||
if (Win7Features) {
|
||||
@ -6871,140 +6869,6 @@ var gIdentityHandler = {
|
||||
}
|
||||
};
|
||||
|
||||
let DownloadMonitorPanel = {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// DownloadMonitorPanel Member Variables
|
||||
|
||||
_panel: null,
|
||||
_activeStr: null,
|
||||
_pausedStr: null,
|
||||
_lastTime: Infinity,
|
||||
_listening: false,
|
||||
|
||||
get DownloadUtils() {
|
||||
delete this.DownloadUtils;
|
||||
Cu.import("resource://gre/modules/DownloadUtils.jsm", this);
|
||||
return this.DownloadUtils;
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// DownloadMonitorPanel Public Methods
|
||||
|
||||
/**
|
||||
* Initialize the status panel and member variables
|
||||
*/
|
||||
init: function DMP_init() {
|
||||
// Initialize "private" member variables
|
||||
this._panel = document.getElementById("download-monitor");
|
||||
|
||||
// Cache the status strings
|
||||
this._activeStr = gNavigatorBundle.getString("activeDownloads1");
|
||||
this._pausedStr = gNavigatorBundle.getString("pausedDownloads1");
|
||||
|
||||
gDownloadMgr.addListener(this);
|
||||
this._listening = true;
|
||||
|
||||
this.updateStatus();
|
||||
},
|
||||
|
||||
uninit: function DMP_uninit() {
|
||||
if (this._listening)
|
||||
gDownloadMgr.removeListener(this);
|
||||
},
|
||||
|
||||
inited: function DMP_inited() {
|
||||
return this._panel != null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Update status based on the number of active and paused downloads
|
||||
*/
|
||||
updateStatus: function DMP_updateStatus() {
|
||||
if (!this.inited())
|
||||
return;
|
||||
|
||||
let numActive = gDownloadMgr.activeDownloadCount;
|
||||
|
||||
// Hide the panel and reset the "last time" if there's no downloads
|
||||
if (numActive == 0) {
|
||||
this._panel.hidden = true;
|
||||
this._lastTime = Infinity;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the download with the longest remaining time
|
||||
let numPaused = 0;
|
||||
let maxTime = -Infinity;
|
||||
let dls = gDownloadMgr.activeDownloads;
|
||||
while (dls.hasMoreElements()) {
|
||||
let dl = dls.getNext();
|
||||
if (dl.state == gDownloadMgr.DOWNLOAD_DOWNLOADING) {
|
||||
// Figure out if this download takes longer
|
||||
if (dl.speed > 0 && dl.size > 0)
|
||||
maxTime = Math.max(maxTime, (dl.size - dl.amountTransferred) / dl.speed);
|
||||
else
|
||||
maxTime = -1;
|
||||
}
|
||||
else if (dl.state == gDownloadMgr.DOWNLOAD_PAUSED)
|
||||
numPaused++;
|
||||
}
|
||||
|
||||
// Get the remaining time string and last sec for time estimation
|
||||
let timeLeft;
|
||||
[timeLeft, this._lastTime] =
|
||||
this.DownloadUtils.getTimeLeft(maxTime, this._lastTime);
|
||||
|
||||
// Figure out how many downloads are currently downloading
|
||||
let numDls = numActive - numPaused;
|
||||
let status = this._activeStr;
|
||||
|
||||
// If all downloads are paused, show the paused message instead
|
||||
if (numDls == 0) {
|
||||
numDls = numPaused;
|
||||
status = this._pausedStr;
|
||||
}
|
||||
|
||||
// Get the correct plural form and insert the number of downloads and time
|
||||
// left message if necessary
|
||||
status = PluralForm.get(numDls, status);
|
||||
status = status.replace("#1", numDls);
|
||||
status = status.replace("#2", timeLeft);
|
||||
|
||||
// Update the panel and show it
|
||||
this._panel.label = status;
|
||||
this._panel.hidden = false;
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// nsIDownloadProgressListener
|
||||
|
||||
/**
|
||||
* Update status for download progress changes
|
||||
*/
|
||||
onProgressChange: function() {
|
||||
this.updateStatus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Update status for download state changes
|
||||
*/
|
||||
onDownloadStateChange: function() {
|
||||
this.updateStatus();
|
||||
},
|
||||
|
||||
onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus, aDownload) {
|
||||
},
|
||||
|
||||
onSecurityChange: function(aWebProgress, aRequest, aState, aDownload) {
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// nsISupports
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIDownloadProgressListener]),
|
||||
};
|
||||
|
||||
function getNotificationBox(aWindow) {
|
||||
var foundBrowser = gBrowser.getBrowserForDocument(aWindow.document);
|
||||
if (foundBrowser)
|
||||
|
@ -24,10 +24,8 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_privatebrowsing_searchbar.js \
|
||||
browser_privatebrowsing_sslsite_transition.js \
|
||||
$(filter disabled-since-it-no-longer-makes-sense, browser_privatebrowsing_transition.js) \
|
||||
$(filter disabled--bug-564934, browser_privatebrowsing_downloadmonitor.js) \
|
||||
browser_privatebrowsing_urlbarundo.js \
|
||||
browser_privatebrowsing_viewsource.js \
|
||||
staller.sjs \
|
||||
$(NULL)
|
||||
|
||||
# Turn off private browsing tests that perma-timeout on Linux.
|
||||
|
@ -1,153 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// This test makes sure that the download monitor status bar panel is correctly
|
||||
// cleared when switching the private browsing mode on or off.
|
||||
|
||||
function test() {
|
||||
// initialization
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
let dm = Cc["@mozilla.org/download-manager;1"].
|
||||
getService(Ci.nsIDownloadManager);
|
||||
if (!gDownloadMgr)
|
||||
gDownloadMgr = dm;
|
||||
let panel = document.getElementById("download-monitor");
|
||||
waitForExplicitFinish();
|
||||
|
||||
let acceptDialog = 0;
|
||||
let confirmCalls = 0;
|
||||
function promptObserver(aSubject, aTopic, aData) {
|
||||
let dialogWin = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
confirmCalls++;
|
||||
if (acceptDialog-- > 0)
|
||||
dialogWin.document.documentElement.getButton("accept").click();
|
||||
}
|
||||
|
||||
Services.obs.addObserver(promptObserver, "common-dialog-loaded", false);
|
||||
|
||||
// Add a new download
|
||||
let [file, persist] = addDownload(dm, {
|
||||
isPrivate: PrivateBrowsingUtils.isWindowPrivate(window),
|
||||
resultFileName: "pbtest-1",
|
||||
downloadName: "PB Test 1"
|
||||
});
|
||||
|
||||
// Make sure that the download is being displayed in the monitor panel
|
||||
if (!DownloadMonitorPanel.inited())
|
||||
DownloadMonitorPanel.init();
|
||||
else
|
||||
DownloadMonitorPanel.updateStatus();
|
||||
ok(!panel.hidden, "The download panel should be successfully added initially");
|
||||
|
||||
// Enter the private browsing mode
|
||||
acceptDialog = 1;
|
||||
pb.privateBrowsingEnabled = true;
|
||||
is(confirmCalls, 1, "One prompt was accepted");
|
||||
ok(pb.privateBrowsingEnabled, "The private browsing transition was successful");
|
||||
|
||||
executeSoon(function () {
|
||||
ok(panel.hidden, "The download panel should be hidden when entering the private browsing mode");
|
||||
|
||||
// Add a new download
|
||||
let [file2, persist2] = addDownload(dm, {
|
||||
isPrivate: PrivateBrowsingUtils.isWindowPrivate(window),
|
||||
resultFileName: "pbtest-2",
|
||||
downloadName: "PB Test 2"
|
||||
});
|
||||
|
||||
// Update the panel
|
||||
DownloadMonitorPanel.updateStatus();
|
||||
|
||||
// Make sure that the panel is visible
|
||||
ok(!panel.hidden, "The download panel should show up when a new download is added");
|
||||
|
||||
// Exit the private browsing mode
|
||||
acceptDialog = 1;
|
||||
pb.privateBrowsingEnabled = false;
|
||||
is(confirmCalls, 2, "One prompt was accepted");
|
||||
ok(!pb.privateBrowsingEnabled, "The private browsing transition was successful");
|
||||
|
||||
executeSoon(function () {
|
||||
ok(panel.hidden, "The download panel should be hidden when leaving the private browsing mode");
|
||||
|
||||
// cleanup
|
||||
let dls = dm.activeDownloads;
|
||||
while (dls.hasMoreElements()) {
|
||||
let dl = dls.getNext().QueryInterface(Ci.nsIDownload);
|
||||
dm.removeDownload(dl.id);
|
||||
let file = dl.targetFile;
|
||||
if (file.exists())
|
||||
file.remove(false);
|
||||
}
|
||||
if (file.exists())
|
||||
file.remove(false);
|
||||
|
||||
Services.obs.removeObserver(promptObserver, "common-dialog-loaded", false);
|
||||
finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a download to the DM, and starts it.
|
||||
* (Copied from toolkit/componentns/downloads/test/unit/head_download_manager.js)
|
||||
* @param aParams (optional): an optional object which contains the function
|
||||
* parameters:
|
||||
* resultFileName: leaf node for the target file
|
||||
* targetFile: nsIFile for the target (overrides resultFileName)
|
||||
* sourceURI: the download source URI
|
||||
* downloadName: the display name of the download
|
||||
* runBeforeStart: a function to run before starting the download
|
||||
* isPrivate: whether the download is private
|
||||
*/
|
||||
function addDownload(dm, aParams)
|
||||
{
|
||||
if (!aParams)
|
||||
aParams = {};
|
||||
if (!("resultFileName" in aParams))
|
||||
aParams.resultFileName = "download.result";
|
||||
if (!("targetFile" in aParams)) {
|
||||
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
aParams.targetFile = dirSvc.get("ProfD", Ci.nsIFile);
|
||||
aParams.targetFile.append(aParams.resultFileName);
|
||||
}
|
||||
if (!("sourceURI" in aParams))
|
||||
aParams.sourceURI = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/staller.sjs";
|
||||
if (!("downloadName" in aParams))
|
||||
aParams.downloadName = null;
|
||||
if (!("runBeforeStart" in aParams))
|
||||
aParams.runBeforeStart = function () {};
|
||||
|
||||
const nsIWBP = Ci.nsIWebBrowserPersist;
|
||||
let persist = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
|
||||
.createInstance(Ci.nsIWebBrowserPersist);
|
||||
persist.persistFlags = nsIWBP.PERSIST_FLAGS_REPLACE_EXISTING_FILES |
|
||||
nsIWBP.PERSIST_FLAGS_BYPASS_CACHE |
|
||||
nsIWBP.PERSIST_FLAGS_AUTODETECT_APPLY_CONVERSION;
|
||||
|
||||
let dl = dm.addDownload(Ci.nsIDownloadManager.DOWNLOAD_TYPE_DOWNLOAD,
|
||||
createURI(aParams.sourceURI),
|
||||
createURI(aParams.targetFile), aParams.downloadName, null,
|
||||
Math.round(Date.now() * 1000), null, persist, aParams.isPrivate);
|
||||
|
||||
// This will throw if it isn't found, and that would mean test failure, so no
|
||||
// try catch block
|
||||
let test = dm.getDownload(dl.id);
|
||||
|
||||
aParams.runBeforeStart.call(undefined, dl);
|
||||
|
||||
persist.progressListener = dl.QueryInterface(Ci.nsIWebProgressListener);
|
||||
persist.savePrivacyAwareURI(dl.source, null, null, null, null, dl.targetFile,
|
||||
aParams.isPrivate);
|
||||
|
||||
return [dl.targetFile, persist];
|
||||
}
|
||||
|
||||
function createURI(aObj) {
|
||||
let ios = Services.io;
|
||||
return (aObj instanceof Ci.nsIFile) ? ios.newFileURI(aObj) :
|
||||
ios.newURI(aObj, null, null);
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// This provides the tests with a download URL which never finishes.
|
||||
|
||||
var timer;
|
||||
|
||||
function handleRequest(request, response) {
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
response.processAsync();
|
||||
|
||||
const nsITimer = Components.interfaces.nsITimer;
|
||||
|
||||
function stall() {
|
||||
timer = null;
|
||||
// This write will throw if the connection has been closed by the browser.
|
||||
response.write("stalling...\n");
|
||||
timer = Components.classes["@mozilla.org/timer;1"]
|
||||
.createInstance(nsITimer);
|
||||
timer.initWithCallback(stall, 500, nsITimer.TYPE_ONE_SHOT);
|
||||
}
|
||||
|
||||
response.setHeader("Content-Type", "text/plain", false);
|
||||
response.setHeader("Accept-Ranges", "none", false);
|
||||
stall();
|
||||
}
|
@ -586,8 +586,6 @@ just addresses the organization to follow, e.g. "This site is run by " -->
|
||||
|
||||
<!ENTITY identity.moreInfoLinkText "More Information…">
|
||||
|
||||
<!ENTITY downloadMonitor2.tooltip "Click to open downloads window">
|
||||
|
||||
<!ENTITY allTabs.filter.emptyText "Search Tabs">
|
||||
<!-- Name for the tabs toolbar as spoken by screen readers.
|
||||
The word "toolbar" is appended automatically and should not be contained below! -->
|
||||
|
@ -232,14 +232,6 @@ identity.unknown.tooltip=This website does not supply identity information.
|
||||
|
||||
identity.ownerUnknown2=(unknown)
|
||||
|
||||
# Downloads Monitor Panel
|
||||
# LOCALIZATION NOTE (activeDownloads1, pausedDownloads1): Semi-colon list of plural
|
||||
# forms. See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# #1 number of downloads; #2 time left
|
||||
# examples: 1 active download (2 minutes remaining); 11 paused downloads
|
||||
activeDownloads1=1 active download (#2);#1 active downloads (#2)
|
||||
pausedDownloads1=1 paused download;#1 paused downloads
|
||||
|
||||
# Edit Bookmark UI
|
||||
editBookmarkPanel.pageBookmarkedTitle=Page Bookmarked
|
||||
editBookmarkPanel.pageBookmarkedDescription=%S will always remember this page for you.
|
||||
|
@ -1790,12 +1790,6 @@ toolbar[mode="text"] toolbarbutton.chevron > .toolbarbutton-icon {
|
||||
display: -moz-box; /* display chevron icon in text mode */
|
||||
}
|
||||
|
||||
#download-monitor {
|
||||
list-style-image: url("chrome://browser/skin/Toolbar-small.png");
|
||||
-moz-image-region: rect(0px 16px 16px 0px);
|
||||
}
|
||||
|
||||
|
||||
/* ::::: Keyboard UI Panel ::::: */
|
||||
|
||||
.KUI-panel-closebutton {
|
||||
|
@ -3130,10 +3130,6 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker {
|
||||
@hudButtonPressed@
|
||||
}
|
||||
|
||||
#download-monitor {
|
||||
list-style-image: url("chrome://mozapps/skin/downloads/downloadStatusIcon.png");
|
||||
}
|
||||
|
||||
/* ::::: Keyboard UI Panel ::::: */
|
||||
|
||||
.KUI-panel {
|
||||
|
@ -2407,11 +2407,6 @@ toolbarbutton.bookmark-item[dragover="true"][open="true"] {
|
||||
min-width: 280px;
|
||||
}
|
||||
|
||||
#download-monitor {
|
||||
list-style-image: url("chrome://browser/skin/Toolbar.png");
|
||||
-moz-image-region: rect(0, 108px, 18px, 90px);
|
||||
}
|
||||
|
||||
/* Bookmarks roots menu-items */
|
||||
#appmenu_subscribeToPage:not([disabled]),
|
||||
#appmenu_subscribeToPageMenu,
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 544 B |
@ -6,7 +6,6 @@ toolkit.jar:
|
||||
% skin mozapps classic/1.0 %skin/classic/mozapps/
|
||||
skin/classic/mozapps/downloads/buttons.png (downloads/buttons.png)
|
||||
skin/classic/mozapps/downloads/downloadIcon.png (downloads/downloadIcon.png)
|
||||
skin/classic/mozapps/downloads/downloadStatusIcon.png (downloads/downloadStatusIcon.png)
|
||||
* skin/classic/mozapps/downloads/downloads.css (downloads/downloads.css)
|
||||
skin/classic/mozapps/downloads/unknownContentType.css (downloads/unknownContentType.css)
|
||||
skin/classic/mozapps/extensions/category-search.png (extensions/category-search.png)
|
||||
|
Loading…
Reference in New Issue
Block a user