Bug 1264206 - Enable ESLint for browser/components/downloads and fix the existing issues. r=Standard8

MozReview-Commit-ID: HDjTxdFCnRp
This commit is contained in:
Yiren Wang 2017-04-03 10:25:05 +01:00
parent 63bf3cc260
commit 5f88f7294a
18 changed files with 129 additions and 192 deletions

View file

@ -58,7 +58,6 @@ browser/branding/**/firefox-branding.js
browser/base/content/test/general/file_csp_block_all_mixedcontent.html browser/base/content/test/general/file_csp_block_all_mixedcontent.html
browser/base/content/test/urlbar/file_blank_but_not_blank.html browser/base/content/test/urlbar/file_blank_but_not_blank.html
browser/base/content/newtab/** browser/base/content/newtab/**
browser/components/downloads/**
# Test files that are really json not js, and don't need to be linted. # Test files that are really json not js, and don't need to be linted.
browser/components/sessionstore/test/unit/data/sessionstore_valid.js browser/components/sessionstore/test/unit/data/sessionstore_valid.js
browser/components/sessionstore/test/unit/data/sessionstore_invalid.js browser/components/sessionstore/test/unit/data/sessionstore_invalid.js

View file

@ -30,8 +30,7 @@ this.EXPORTED_SYMBOLS = [
* the registered download status indicators. * the registered download status indicators.
*/ */
//////////////////////////////////////////////////////////////////////////////// // Globals
//// Globals
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components; const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
@ -111,7 +110,7 @@ var PrefObserver = {
observe(aSubject, aTopic, aData) { observe(aSubject, aTopic, aData) {
if (this.prefs.hasOwnProperty(aData)) { if (this.prefs.hasOwnProperty(aData)) {
delete this[aData]; delete this[aData];
return this[aData] = this.getPref(aData); this[aData] = this.getPref(aData);
} }
}, },
register(prefs) { register(prefs) {
@ -119,7 +118,7 @@ var PrefObserver = {
kPrefBranch.addObserver("", this, true); kPrefBranch.addObserver("", this, true);
for (let key in prefs) { for (let key in prefs) {
let name = key; let name = key;
XPCOMUtils.defineLazyGetter(this, name, function () { XPCOMUtils.defineLazyGetter(this, name, function() {
return PrefObserver.getPref(name); return PrefObserver.getPref(name);
}); });
} }
@ -133,8 +132,7 @@ PrefObserver.register({
}); });
//////////////////////////////////////////////////////////////////////////////// // DownloadsCommon
//// DownloadsCommon
/** /**
* This object is exposed directly to the consumers of this JavaScript module, * This object is exposed directly to the consumers of this JavaScript module,
@ -166,14 +164,14 @@ this.DownloadsCommon = {
let string = enumerator.getNext().QueryInterface(Ci.nsIPropertyElement); let string = enumerator.getNext().QueryInterface(Ci.nsIPropertyElement);
let stringName = string.key; let stringName = string.key;
if (stringName in kDownloadsStringsRequiringFormatting) { if (stringName in kDownloadsStringsRequiringFormatting) {
strings[stringName] = function () { strings[stringName] = function() {
// Convert "arguments" to a real array before calling into XPCOM. // Convert "arguments" to a real array before calling into XPCOM.
return sb.formatStringFromName(stringName, return sb.formatStringFromName(stringName,
Array.slice(arguments, 0), Array.slice(arguments, 0),
arguments.length); arguments.length);
}; };
} else if (stringName in kDownloadsStringsRequiringPluralForm) { } else if (stringName in kDownloadsStringsRequiringPluralForm) {
strings[stringName] = function (aCount) { strings[stringName] = function(aCount) {
// Convert "arguments" to a real array before calling into XPCOM. // Convert "arguments" to a real array before calling into XPCOM.
let formattedString = sb.formatStringFromName(stringName, let formattedString = sb.formatStringFromName(stringName,
Array.slice(arguments, 0), Array.slice(arguments, 0),
@ -243,9 +241,8 @@ this.DownloadsCommon = {
getData(aWindow) { getData(aWindow) {
if (PrivateBrowsingUtils.isContentWindowPrivate(aWindow)) { if (PrivateBrowsingUtils.isContentWindowPrivate(aWindow)) {
return PrivateDownloadsData; return PrivateDownloadsData;
} else {
return DownloadsData;
} }
return DownloadsData;
}, },
/** /**
@ -265,9 +262,8 @@ this.DownloadsCommon = {
getIndicatorData(aWindow) { getIndicatorData(aWindow) {
if (PrivateBrowsingUtils.isContentWindowPrivate(aWindow)) { if (PrivateBrowsingUtils.isContentWindowPrivate(aWindow)) {
return PrivateDownloadsIndicatorData; return PrivateDownloadsIndicatorData;
} else {
return DownloadsIndicatorData;
} }
return DownloadsIndicatorData;
}, },
/** /**
@ -286,12 +282,11 @@ this.DownloadsCommon = {
return this._privateSummary; return this._privateSummary;
} }
return this._privateSummary = new DownloadsSummaryData(true, aNumToExclude); return this._privateSummary = new DownloadsSummaryData(true, aNumToExclude);
} else {
if (this._summary) {
return this._summary;
}
return this._summary = new DownloadsSummaryData(false, aNumToExclude);
} }
if (this._summary) {
return this._summary;
}
return this._summary = new DownloadsSummaryData(false, aNumToExclude);
}, },
_summary: null, _summary: null,
_privateSummary: null, _privateSummary: null,
@ -666,7 +661,7 @@ XPCOMUtils.defineLazyGetter(this.DownloadsCommon, "error", () => {
/** /**
* Returns true if we are executing on Windows Vista or a later version. * Returns true if we are executing on Windows Vista or a later version.
*/ */
XPCOMUtils.defineLazyGetter(DownloadsCommon, "isWinVistaOrHigher", function () { XPCOMUtils.defineLazyGetter(DownloadsCommon, "isWinVistaOrHigher", function() {
let os = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS; let os = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS;
if (os != "WINNT") { if (os != "WINNT") {
return false; return false;
@ -675,8 +670,7 @@ XPCOMUtils.defineLazyGetter(DownloadsCommon, "isWinVistaOrHigher", function () {
return parseFloat(sysInfo.getProperty("version")) >= 6; return parseFloat(sysInfo.getProperty("version")) >= 6;
}); });
//////////////////////////////////////////////////////////////////////////////// // DownloadsData
//// DownloadsData
/** /**
* Retrieves the list of past and completed downloads from the underlying * Retrieves the list of past and completed downloads from the underlying
@ -756,8 +750,7 @@ DownloadsDataCtor.prototype = {
indicatorData.attention = DownloadsCommon.ATTENTION_NONE; indicatorData.attention = DownloadsCommon.ATTENTION_NONE;
}, },
////////////////////////////////////////////////////////////////////////////// // Integration with the asynchronous Downloads back-end
//// Integration with the asynchronous Downloads back-end
onDownloadAdded(download) { onDownloadAdded(download) {
// Download objects do not store the end time of downloads, as the Downloads // Download objects do not store the end time of downloads, as the Downloads
@ -847,8 +840,7 @@ DownloadsDataCtor.prototype = {
} }
}, },
////////////////////////////////////////////////////////////////////////////// // Registration of views
//// Registration of views
/** /**
* Adds an object to be notified when the available download data changes. * Adds an object to be notified when the available download data changes.
@ -896,8 +888,7 @@ DownloadsDataCtor.prototype = {
aView.onDataLoadCompleted(); aView.onDataLoadCompleted();
}, },
////////////////////////////////////////////////////////////////////////////// // Notifications sent to the most recent browser window only
//// Notifications sent to the most recent browser window only
/** /**
* Set to true after the first download causes the downloads panel to be * Set to true after the first download causes the downloads panel to be
@ -952,16 +943,14 @@ XPCOMUtils.defineLazyGetter(this, "DownloadsData", function() {
return new DownloadsDataCtor(false); return new DownloadsDataCtor(false);
}); });
//////////////////////////////////////////////////////////////////////////////// // DownloadsViewPrototype
//// DownloadsViewPrototype
/** /**
* A prototype for an object that registers itself with DownloadsData as soon * A prototype for an object that registers itself with DownloadsData as soon
* as a view is registered with it. * as a view is registered with it.
*/ */
const DownloadsViewPrototype = { const DownloadsViewPrototype = {
////////////////////////////////////////////////////////////////////////////// // Registration of views
//// Registration of views
/** /**
* Array of view objects that should be notified when the available status * Array of view objects that should be notified when the available status
@ -1036,8 +1025,7 @@ const DownloadsViewPrototype = {
} }
}, },
////////////////////////////////////////////////////////////////////////////// // Callback functions from DownloadsData
//// Callback functions from DownloadsData
/** /**
* Indicates whether we are still loading downloads data asynchronously. * Indicates whether we are still loading downloads data asynchronously.
@ -1136,8 +1124,7 @@ const DownloadsViewPrototype = {
}, },
}; };
//////////////////////////////////////////////////////////////////////////////// // DownloadsIndicatorData
//// DownloadsIndicatorData
/** /**
* This object registers itself with DownloadsData as a view, and transforms the * This object registers itself with DownloadsData as a view, and transforms the
@ -1170,8 +1157,7 @@ DownloadsIndicatorDataCtor.prototype = {
} }
}, },
////////////////////////////////////////////////////////////////////////////// // Callback functions from DownloadsData
//// Callback functions from DownloadsData
onDataLoadCompleted() { onDataLoadCompleted() {
DownloadsViewPrototype.onDataLoadCompleted.call(this); DownloadsViewPrototype.onDataLoadCompleted.call(this);
@ -1228,8 +1214,7 @@ DownloadsIndicatorDataCtor.prototype = {
this._updateViews(); this._updateViews();
}, },
////////////////////////////////////////////////////////////////////////////// // Propagation of properties to our views
//// Propagation of properties to our views
// The following properties are updated by _refreshProperties and are then // The following properties are updated by _refreshProperties and are then
// propagated to the views. See _refreshProperties for details. // propagated to the views. See _refreshProperties for details.
@ -1288,8 +1273,7 @@ DownloadsIndicatorDataCtor.prototype = {
: this._attention; : this._attention;
}, },
////////////////////////////////////////////////////////////////////////////// // Property updating based on current download status
//// Property updating based on current download status
/** /**
* Number of download items that are available to be displayed. * Number of download items that are available to be displayed.
@ -1370,8 +1354,7 @@ XPCOMUtils.defineLazyGetter(this, "DownloadsIndicatorData", function() {
return new DownloadsIndicatorDataCtor(false); return new DownloadsIndicatorDataCtor(false);
}); });
//////////////////////////////////////////////////////////////////////////////// // DownloadsSummaryData
//// DownloadsSummaryData
/** /**
* DownloadsSummaryData is a view for DownloadsData that produces a summary * DownloadsSummaryData is a view for DownloadsData that produces a summary
@ -1439,10 +1422,9 @@ DownloadsSummaryData.prototype = {
} }
}, },
////////////////////////////////////////////////////////////////////////////// // Callback functions from DownloadsData - see the documentation in
//// Callback functions from DownloadsData - see the documentation in // DownloadsViewPrototype for more information on what these functions
//// DownloadsViewPrototype for more information on what these functions // are used for.
//// are used for.
onDataLoadCompleted() { onDataLoadCompleted() {
DownloadsViewPrototype.onDataLoadCompleted.call(this); DownloadsViewPrototype.onDataLoadCompleted.call(this);
@ -1475,8 +1457,7 @@ DownloadsSummaryData.prototype = {
this._updateViews(); this._updateViews();
}, },
////////////////////////////////////////////////////////////////////////////// // Propagation of properties to our views
//// Propagation of properties to our views
/** /**
* Computes aggregate values and propagates the changes to our views. * Computes aggregate values and propagates the changes to our views.
@ -1504,8 +1485,7 @@ DownloadsSummaryData.prototype = {
aView.details = this._details; aView.details = this._details;
}, },
////////////////////////////////////////////////////////////////////////////// // Property updating based on current download status
//// Property updating based on current download status
/** /**
* A generator function for the Download objects this summary is currently * A generator function for the Download objects this summary is currently

View file

@ -14,8 +14,7 @@ this.EXPORTED_SYMBOLS = [
"DownloadsTaskbar", "DownloadsTaskbar",
]; ];
//////////////////////////////////////////////////////////////////////////////// // Globals
//// Globals
const Cc = Components.classes; const Cc = Components.classes;
const Ci = Components.interfaces; const Ci = Components.interfaces;
@ -31,7 +30,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
XPCOMUtils.defineLazyModuleGetter(this, "Services", XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm"); "resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGetter(this, "gWinTaskbar", function () { XPCOMUtils.defineLazyGetter(this, "gWinTaskbar", function() {
if (!("@mozilla.org/windows-taskbar;1" in Cc)) { if (!("@mozilla.org/windows-taskbar;1" in Cc)) {
return null; return null;
} }
@ -40,14 +39,13 @@ XPCOMUtils.defineLazyGetter(this, "gWinTaskbar", function () {
return winTaskbar.available && winTaskbar; return winTaskbar.available && winTaskbar;
}); });
XPCOMUtils.defineLazyGetter(this, "gMacTaskbarProgress", function () { XPCOMUtils.defineLazyGetter(this, "gMacTaskbarProgress", function() {
return ("@mozilla.org/widget/macdocksupport;1" in Cc) && return ("@mozilla.org/widget/macdocksupport;1" in Cc) &&
Cc["@mozilla.org/widget/macdocksupport;1"] Cc["@mozilla.org/widget/macdocksupport;1"]
.getService(Ci.nsITaskbarProgress); .getService(Ci.nsITaskbarProgress);
}); });
//////////////////////////////////////////////////////////////////////////////// // DownloadsTaskbar
//// DownloadsTaskbar
/** /**
* Handles the download progress indicator in the taskbar. * Handles the download progress indicator in the taskbar.
@ -111,7 +109,6 @@ this.DownloadsTaskbar = {
return; return;
} }
this._summary = summary; this._summary = summary;
return this._summary.addView(this);
}).then(null, Cu.reportError); }).then(null, Cu.reportError);
} }
}, },
@ -150,8 +147,7 @@ this.DownloadsTaskbar = {
}); });
}, },
////////////////////////////////////////////////////////////////////////////// // DownloadSummary view
//// DownloadSummary view
onSummaryChanged() { onSummaryChanged() {
// If the last browser window has been closed, we have no indicator any more. // If the last browser window has been closed, we have no indicator any more.

View file

@ -49,7 +49,7 @@ this.DownloadsViewUI = {
* HistoryDownloadElementShell and the DownloadsViewItem for the panel. The * HistoryDownloadElementShell and the DownloadsViewItem for the panel. The
* history view may use a HistoryDownload object in place of a Download object. * history view may use a HistoryDownload object in place of a Download object.
*/ */
this.DownloadsViewUI.DownloadElementShell = function () {} this.DownloadsViewUI.DownloadElementShell = function() {}
this.DownloadsViewUI.DownloadElementShell.prototype = { this.DownloadsViewUI.DownloadElementShell.prototype = {
/** /**
@ -242,10 +242,10 @@ this.DownloadsViewUI.DownloadElementShell.prototype = {
} }
let referrer = this.download.source.referrer || this.download.source.url; let referrer = this.download.source.referrer || this.download.source.url;
let [displayHost, fullHost] = DownloadUtils.getURIHost(referrer); let [displayHost /* ,fullHost */] = DownloadUtils.getURIHost(referrer);
let date = new Date(this.download.endTime); let date = new Date(this.download.endTime);
let [displayDate, fullDate] = DownloadUtils.getReadableDates(date); let [displayDate /* ,fullDate */] = DownloadUtils.getReadableDates(date);
let firstPart = s.statusSeparator(stateLabel, displayHost); let firstPart = s.statusSeparator(stateLabel, displayHost);
fullStatus = s.statusSeparator(firstPart, displayDate); fullStatus = s.statusSeparator(firstPart, displayDate);
@ -279,8 +279,6 @@ this.DownloadsViewUI.DownloadElementShell.prototype = {
} }
throw new Error("Unexpected reputationCheckVerdict: " + throw new Error("Unexpected reputationCheckVerdict: " +
this.download.error.reputationCheckVerdict); this.download.error.reputationCheckVerdict);
// return anyway to avoid a JS strict warning.
return [null, null];
}, },
/** /**
@ -306,6 +304,7 @@ this.DownloadsViewUI.DownloadElementShell.prototype = {
} else if (action == "confirmBlock") { } else if (action == "confirmBlock") {
return this.download.confirmBlock(); return this.download.confirmBlock();
} }
return Promise.resolve();
}).catch(Cu.reportError); }).catch(Cu.reportError);
}, },

View file

@ -1,6 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* 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, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-env mozilla/browser-window */
var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components; var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
@ -943,9 +944,7 @@ DownloadsPlacesView.prototype = {
}, },
get selectedNodes() { get selectedNodes() {
return [for (element of this._richlistbox.selectedItems) return this._richlistbox.selectedItems.filter(element => element._placesNode);
if (element._placesNode)
element._placesNode];
}, },
get selectedNode() { get selectedNode() {
@ -1178,8 +1177,7 @@ DownloadsPlacesView.prototype = {
}, },
_copySelectedDownloadsToClipboard() { _copySelectedDownloadsToClipboard() {
let urls = [for (element of this._richlistbox.selectedItems) let urls = this._richlistbox.selectedItems.map(element => element._shell.download.source.url);
element._shell.download.source.url];
Cc["@mozilla.org/widget/clipboardhelper;1"] Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(Ci.nsIClipboardHelper) .getService(Ci.nsIClipboardHelper)
@ -1211,7 +1209,7 @@ DownloadsPlacesView.prototype = {
}, },
_canDownloadClipboardURL() { _canDownloadClipboardURL() {
let [url, name] = this._getURLFromClipboardData(); let [url /* ,name */] = this._getURLFromClipboardData();
return url != ""; return url != "";
}, },
@ -1308,8 +1306,7 @@ DownloadsPlacesView.prototype = {
element._shell.doDefaultCommand(); element._shell.doDefaultCommand();
} }
} }
} } else if (aEvent.charCode == " ".charCodeAt(0)) {
else if (aEvent.charCode == " ".charCodeAt(0)) {
// Pause/Resume every selected download // Pause/Resume every selected download
for (let element of selectedElements) { for (let element of selectedElements) {
if (element._shell.isCommandEnabled("downloadsCmd_pauseResume")) { if (element._shell.isCommandEnabled("downloadsCmd_pauseResume")) {
@ -1409,7 +1406,7 @@ DownloadsPlacesView.prototype = {
}; };
for (let methodName of ["load", "applyFilter", "selectNode", "selectItems"]) { for (let methodName of ["load", "applyFilter", "selectNode", "selectItems"]) {
DownloadsPlacesView.prototype[methodName] = function () { DownloadsPlacesView.prototype[methodName] = function() {
throw new Error("|" + methodName + throw new Error("|" + methodName +
"| is not implemented by the downloads view."); "| is not implemented by the downloads view.");
} }

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
/* import-globals-from allDownloadsViewOverlay.js */
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm"); Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
var ContentAreaDownloadsView = { var ContentAreaDownloadsView = {

View file

@ -3,6 +3,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* 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, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-env mozilla/browser-window */
/** /**
* Handles the Downloads panel user interface for each browser window. * Handles the Downloads panel user interface for each browser window.
@ -78,15 +79,13 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
XPCOMUtils.defineLazyModuleGetter(this, "Services", XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm"); "resource://gre/modules/Services.jsm");
//////////////////////////////////////////////////////////////////////////////// // DownloadsPanel
//// DownloadsPanel
/** /**
* Main entry point for the downloads panel interface. * Main entry point for the downloads panel interface.
*/ */
const DownloadsPanel = { const DownloadsPanel = {
////////////////////////////////////////////////////////////////////////////// // Initialization and termination
//// Initialization and termination
/** /**
* Internal state of the downloads panel, based on one of the kState * Internal state of the downloads panel, based on one of the kState
@ -192,8 +191,7 @@ const DownloadsPanel = {
DownloadsCommon.log("DownloadsPanel terminated."); DownloadsCommon.log("DownloadsPanel terminated.");
}, },
////////////////////////////////////////////////////////////////////////////// // Panel interface
//// Panel interface
/** /**
* Main panel element in the browser window, or null if the panel overlay * Main panel element in the browser window, or null if the panel overlay
@ -308,9 +306,11 @@ const DownloadsPanel = {
this.keyFocusing = false; this.keyFocusing = false;
break; break;
case "keydown": case "keydown":
return this._onKeyDown(aEvent); this._onKeyDown(aEvent);
break;
case "keypress": case "keypress":
return this._onKeyPress(aEvent); this._onKeyPress(aEvent);
break;
case "popupshown": case "popupshown":
if (this.setHeightToFitOnShow) { if (this.setHeightToFitOnShow) {
this.setHeightToFitOnShow = false; this.setHeightToFitOnShow = false;
@ -328,8 +328,7 @@ const DownloadsPanel = {
} }
}, },
////////////////////////////////////////////////////////////////////////////// // Callback functions from DownloadsView
//// Callback functions from DownloadsView
/** /**
* Called after data loading finished. * Called after data loading finished.
@ -338,8 +337,7 @@ const DownloadsPanel = {
this._openPopupIfDataReady(); this._openPopupIfDataReady();
}, },
////////////////////////////////////////////////////////////////////////////// // User interface event functions
//// User interface event functions
onWindowUnload() { onWindowUnload() {
// This function is registered as an event listener, we can't use "this". // This function is registered as an event listener, we can't use "this".
@ -407,8 +405,7 @@ const DownloadsPanel = {
.removeAttribute("showingdropdown"); .removeAttribute("showingdropdown");
}, },
////////////////////////////////////////////////////////////////////////////// // Related operations
//// Related operations
/** /**
* Shows or focuses the user interface dedicated to downloads history. * Shows or focuses the user interface dedicated to downloads history.
@ -429,8 +426,7 @@ const DownloadsPanel = {
this.hidePanel(); this.hidePanel();
}, },
////////////////////////////////////////////////////////////////////////////// // Internal functions
//// Internal functions
/** /**
* Attach event listeners to a panel element. These listeners should be * Attach event listeners to a panel element. These listeners should be
@ -625,8 +621,7 @@ const DownloadsPanel = {
XPCOMUtils.defineConstant(this, "DownloadsPanel", DownloadsPanel); XPCOMUtils.defineConstant(this, "DownloadsPanel", DownloadsPanel);
//////////////////////////////////////////////////////////////////////////////// // DownloadsOverlayLoader
//// DownloadsOverlayLoader
/** /**
* Allows loading the downloads panel and the status indicator interfaces on * Allows loading the downloads panel and the status indicator interfaces on
@ -705,8 +700,7 @@ const DownloadsOverlayLoader = {
XPCOMUtils.defineConstant(this, "DownloadsOverlayLoader", DownloadsOverlayLoader); XPCOMUtils.defineConstant(this, "DownloadsOverlayLoader", DownloadsOverlayLoader);
//////////////////////////////////////////////////////////////////////////////// // DownloadsView
//// DownloadsView
/** /**
* Builds and updates the downloads list widget, responding to changes in the * Builds and updates the downloads list widget, responding to changes in the
@ -714,8 +708,7 @@ XPCOMUtils.defineConstant(this, "DownloadsOverlayLoader", DownloadsOverlayLoader
* interaction events raised by the downloads list widget. * interaction events raised by the downloads list widget.
*/ */
const DownloadsView = { const DownloadsView = {
////////////////////////////////////////////////////////////////////////////// // Functions handling download items in the list
//// Functions handling download items in the list
/** /**
* Maximum number of items shown by the list at any given time. * Maximum number of items shown by the list at any given time.
@ -791,8 +784,7 @@ const DownloadsView = {
return this.downloadsHistory = document.getElementById("downloadsHistory"); return this.downloadsHistory = document.getElementById("downloadsHistory");
}, },
////////////////////////////////////////////////////////////////////////////// // Callback functions from DownloadsData
//// Callback functions from DownloadsData
/** /**
* Called before multiple downloads are about to be loaded. * Called before multiple downloads are about to be loaded.
@ -918,8 +910,7 @@ const DownloadsView = {
* Creates a new view item associated with the specified data item, and adds * Creates a new view item associated with the specified data item, and adds
* it to the top or the bottom of the list. * it to the top or the bottom of the list.
*/ */
_addViewItem(download, aNewest) _addViewItem(download, aNewest) {
{
DownloadsCommon.log("Adding a new DownloadsViewItem to the downloads list.", DownloadsCommon.log("Adding a new DownloadsViewItem to the downloads list.",
"aNewest =", aNewest); "aNewest =", aNewest);
@ -950,8 +941,7 @@ const DownloadsView = {
this._itemsForElements.delete(element); this._itemsForElements.delete(element);
}, },
////////////////////////////////////////////////////////////////////////////// // User interface event functions
//// User interface event functions
/** /**
* Helper function to do commands on a specific download item. * Helper function to do commands on a specific download item.
@ -1118,8 +1108,7 @@ const DownloadsView = {
XPCOMUtils.defineConstant(this, "DownloadsView", DownloadsView); XPCOMUtils.defineConstant(this, "DownloadsView", DownloadsView);
//////////////////////////////////////////////////////////////////////////////// // DownloadsViewItem
//// DownloadsViewItem
/** /**
* Builds and updates a single item in the downloads list widget, responding to * Builds and updates a single item in the downloads list widget, responding to
@ -1199,8 +1188,7 @@ DownloadsViewItem.prototype = {
} }
}, },
////////////////////////////////////////////////////////////////////////////// // Item commands
//// Item commands
cmd_delete() { cmd_delete() {
DownloadsCommon.removeAndFinalizeDownload(this.download); DownloadsCommon.removeAndFinalizeDownload(this.download);
@ -1268,8 +1256,7 @@ DownloadsViewItem.prototype = {
}, },
}; };
//////////////////////////////////////////////////////////////////////////////// // DownloadsViewController
//// DownloadsViewController
/** /**
* Handles part of the user interaction events raised by the downloads list * Handles part of the user interaction events raised by the downloads list
@ -1277,8 +1264,7 @@ DownloadsViewItem.prototype = {
* dispatches the commands that apply to individual items. * dispatches the commands that apply to individual items.
*/ */
const DownloadsViewController = { const DownloadsViewController = {
////////////////////////////////////////////////////////////////////////////// // Initialization and termination
//// Initialization and termination
initialize() { initialize() {
window.controllers.insertControllerAt(0, this); window.controllers.insertControllerAt(0, this);
@ -1288,8 +1274,7 @@ const DownloadsViewController = {
window.controllers.removeController(this); window.controllers.removeController(this);
}, },
////////////////////////////////////////////////////////////////////////////// // nsIController
//// nsIController
supportsCommand(aCommand) { supportsCommand(aCommand) {
if (aCommand === "downloadsCmd_clearList") { if (aCommand === "downloadsCmd_clearList") {
@ -1352,8 +1337,7 @@ const DownloadsViewController = {
onEvent() {}, onEvent() {},
////////////////////////////////////////////////////////////////////////////// // Other functions
//// Other functions
updateCommands() { updateCommands() {
function updateCommandsForObject(object) { function updateCommandsForObject(object) {
@ -1367,8 +1351,7 @@ const DownloadsViewController = {
updateCommandsForObject(DownloadsViewItem.prototype); updateCommandsForObject(DownloadsViewItem.prototype);
}, },
////////////////////////////////////////////////////////////////////////////// // Selection-independent commands
//// Selection-independent commands
downloadsCmd_clearList() { downloadsCmd_clearList() {
DownloadsCommon.getData(window).removeFinished(); DownloadsCommon.getData(window).removeFinished();
@ -1377,8 +1360,7 @@ const DownloadsViewController = {
XPCOMUtils.defineConstant(this, "DownloadsViewController", DownloadsViewController); XPCOMUtils.defineConstant(this, "DownloadsViewController", DownloadsViewController);
//////////////////////////////////////////////////////////////////////////////// // DownloadsSummary
//// DownloadsSummary
/** /**
* Manages the summary at the bottom of the downloads panel list if the number * Manages the summary at the bottom of the downloads panel list if the number
@ -1562,8 +1544,7 @@ const DownloadsSummary = {
XPCOMUtils.defineConstant(this, "DownloadsSummary", DownloadsSummary); XPCOMUtils.defineConstant(this, "DownloadsSummary", DownloadsSummary);
//////////////////////////////////////////////////////////////////////////////// // DownloadsFooter
//// DownloadsFooter
/** /**
* Manages events sent to to the footer vbox, which contains both the * Manages events sent to to the footer vbox, which contains both the
@ -1622,8 +1603,7 @@ const DownloadsFooter = {
XPCOMUtils.defineConstant(this, "DownloadsFooter", DownloadsFooter); XPCOMUtils.defineConstant(this, "DownloadsFooter", DownloadsFooter);
//////////////////////////////////////////////////////////////////////////////// // DownloadsBlockedSubview
//// DownloadsBlockedSubview
/** /**
* Manages the blocked subview that slides in when you click a blocked download. * Manages the blocked subview that slides in when you click a blocked download.

View file

@ -3,6 +3,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public /* 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, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
/* eslint-env mozilla/browser-window */
/** /**
* Handles the indicator that displays the progress of ongoing downloads, which * Handles the indicator that displays the progress of ongoing downloads, which
@ -26,8 +27,7 @@
"use strict"; "use strict";
//////////////////////////////////////////////////////////////////////////////// // DownloadsButton
//// DownloadsButton
/** /**
* Main entry point for the downloads indicator. Depending on how the toolbars * Main entry point for the downloads indicator. Depending on how the toolbars
@ -187,8 +187,7 @@ Object.defineProperty(this, "DownloadsButton", {
writable: false writable: false
}); });
//////////////////////////////////////////////////////////////////////////////// // DownloadsIndicatorView
//// DownloadsIndicatorView
/** /**
* Builds and updates the actual downloads status widget, responding to changes * Builds and updates the actual downloads status widget, responding to changes
@ -287,8 +286,7 @@ const DownloadsIndicatorView = {
}); });
}, },
////////////////////////////////////////////////////////////////////////////// // Direct control functions
//// Direct control functions
/** /**
* Set while we are waiting for a notification to fade out. * Set while we are waiting for a notification to fade out.
@ -357,7 +355,7 @@ const DownloadsIndicatorView = {
// the notification isn't clipped by overflow properties of the anchor's // the notification isn't clipped by overflow properties of the anchor's
// container. // container.
let notifier = this.notifier; let notifier = this.notifier;
if (notifier.style.transform == '') { if (notifier.style.transform == "") {
let anchorRect = anchor.getBoundingClientRect(); let anchorRect = anchor.getBoundingClientRect();
let notifierRect = notifier.getBoundingClientRect(); let notifierRect = notifier.getBoundingClientRect();
let topDiff = anchorRect.top - notifierRect.top; let topDiff = anchorRect.top - notifierRect.top;
@ -366,20 +364,19 @@ const DownloadsIndicatorView = {
let widthDiff = anchorRect.width - notifierRect.width; let widthDiff = anchorRect.width - notifierRect.width;
let translateX = (leftDiff + .5 * widthDiff) + "px"; let translateX = (leftDiff + .5 * widthDiff) + "px";
let translateY = (topDiff + .5 * heightDiff) + "px"; let translateY = (topDiff + .5 * heightDiff) + "px";
notifier.style.transform = "translate(" + translateX + ", " + translateY + ")"; notifier.style.transform = "translate(" + translateX + ", " + translateY + ")";
} }
notifier.setAttribute("notification", aType); notifier.setAttribute("notification", aType);
anchor.setAttribute("notification", aType); anchor.setAttribute("notification", aType);
this._notificationTimeout = setTimeout(() => { this._notificationTimeout = setTimeout(() => {
anchor.removeAttribute("notification"); anchor.removeAttribute("notification");
notifier.removeAttribute("notification"); notifier.removeAttribute("notification");
notifier.style.transform = ''; notifier.style.transform = "";
// This value is determined by the overall duration of animation in CSS. // This value is determined by the overall duration of animation in CSS.
}, 2000); }, 2000);
}, },
////////////////////////////////////////////////////////////////////////////// // Callback functions from DownloadsIndicatorData
//// Callback functions from DownloadsIndicatorData
/** /**
* Indicates whether the indicator should be shown because there are some * Indicates whether the indicator should be shown because there are some
@ -524,8 +521,7 @@ const DownloadsIndicatorView = {
}, },
_attention: DownloadsCommon.ATTENTION_NONE, _attention: DownloadsCommon.ATTENTION_NONE,
////////////////////////////////////////////////////////////////////////////// // User interface event functions
//// User interface event functions
onWindowUnload() { onWindowUnload() {
// This function is registered as an event listener, we can't use "this". // This function is registered as an event listener, we can't use "this".

View file

@ -30,7 +30,7 @@ add_task(function* test_basic_functionality() {
// For testing purposes, show all the download items at once. // For testing purposes, show all the download items at once.
var originalCountLimit = DownloadsView.kItemCountLimit; var originalCountLimit = DownloadsView.kItemCountLimit;
DownloadsView.kItemCountLimit = DownloadData.length; DownloadsView.kItemCountLimit = DownloadData.length;
registerCleanupFunction(function () { registerCleanupFunction(function() {
DownloadsView.kItemCountLimit = originalCountLimit; DownloadsView.kItemCountLimit = originalCountLimit;
}); });

View file

@ -108,20 +108,18 @@ function* openPanel() {
clearInterval(interval); clearInterval(interval);
resolve(); resolve();
} }
} else { } else if (iBackoff < backoff) {
if (iBackoff < backoff) {
// Keep backing off before trying again. // Keep backing off before trying again.
iBackoff++; iBackoff++;
} else { } else {
// Try (or retry) opening the panel. // Try (or retry) opening the panel.
verifyCount = 5; verifyCount = 5;
backoff = Math.max(1, 2 * backoff); backoff = Math.max(1, 2 * backoff);
iBackoff = 0; iBackoff = 0;
if (DownloadsPanel._state != DownloadsPanel.kStateUninitialized) { if (DownloadsPanel._state != DownloadsPanel.kStateUninitialized) {
DownloadsPanel._state = DownloadsPanel.kStateHidden; DownloadsPanel._state = DownloadsPanel.kStateHidden;
} }
DownloadsPanel.showPanel(); DownloadsPanel.showPanel();
}
} }
}, 100); }, 100);
}); });
@ -162,7 +160,6 @@ function promiseSubviewShown(shown) {
!DownloadsBlockedSubview.view._transitioning) { !DownloadsBlockedSubview.view._transitioning) {
clearInterval(interval); clearInterval(interval);
setTimeout(resolve, 1000); setTimeout(resolve, 1000);
return;
} }
}, 0); }, 0);
}); });

View file

@ -41,7 +41,7 @@ add_task(function* test_clearList() {
], ],
expectClearListShown: true, expectClearListShown: true,
expectedItemNumber: 0, expectedItemNumber: 0,
},{ }, {
downloads: [ downloads: [
{ state: nsIDM.DOWNLOAD_NOTSTARTED }, { state: nsIDM.DOWNLOAD_NOTSTARTED },
{ state: nsIDM.DOWNLOAD_FINISHED }, { state: nsIDM.DOWNLOAD_FINISHED },
@ -51,7 +51,7 @@ add_task(function* test_clearList() {
], ],
expectClearListShown: true, expectClearListShown: true,
expectedItemNumber: 1, expectedItemNumber: 1,
},{ }, {
downloads: [ downloads: [
{ state: nsIDM.DOWNLOAD_PAUSED }, { state: nsIDM.DOWNLOAD_PAUSED },
], ],

View file

@ -44,7 +44,7 @@ add_task(function* test_first_download_panel() {
// Next, make sure that if we start another download, we don't open the // Next, make sure that if we start another download, we don't open the
// panel automatically. // panel automatically.
let originalOnPopupShown = DownloadsPanel.onPopupShown; let originalOnPopupShown = DownloadsPanel.onPopupShown;
DownloadsPanel.onPopupShown = function () { DownloadsPanel.onPopupShown = function() {
originalOnPopupShown.apply(this, arguments); originalOnPopupShown.apply(this, arguments);
ok(false, "Should not have opened the downloads panel."); ok(false, "Should not have opened the downloads panel.");
}; };

View file

@ -1,6 +1,6 @@
const SAVE_PER_SITE_PREF = "browser.download.lastDir.savePerSite"; const SAVE_PER_SITE_PREF = "browser.download.lastDir.savePerSite";
function test_deleted_iframe(perSitePref, windowOptions={}) { function test_deleted_iframe(perSitePref, windowOptions = {}) {
return function*() { return function*() {
Services.prefs.setBoolPref(SAVE_PER_SITE_PREF, perSitePref); Services.prefs.setBoolPref(SAVE_PER_SITE_PREF, perSitePref);
let {DownloadLastDir} = Cu.import("resource://gre/modules/DownloadLastDir.jsm", {}); let {DownloadLastDir} = Cu.import("resource://gre/modules/DownloadLastDir.jsm", {});

View file

@ -29,10 +29,10 @@ add_task(function* test_indicatorDrop() {
let succeeded = new Set(); let succeeded = new Set();
yield new Promise(function(resolve) { yield new Promise(function(resolve) {
let view = { let view = {
onDownloadAdded: function(download) { onDownloadAdded(download) {
added.add(download.source.url); added.add(download.source.url);
}, },
onDownloadChanged: function(download) { onDownloadChanged(download) {
if (!added.has(download.source.url)) if (!added.has(download.source.url))
return; return;
if (!download.succeeded) if (!download.succeeded)

View file

@ -29,10 +29,10 @@ add_task(function* test_indicatorDrop() {
let succeeded = new Set(); let succeeded = new Set();
await new Promise(resolve => { await new Promise(resolve => {
let view = { let view = {
onDownloadAdded: function(download) { onDownloadAdded(download) {
added.add(download.source.url); added.add(download.source.url);
}, },
onDownloadChanged: function(download) { onDownloadChanged(download) {
if (!added.has(download.source.url)) if (!added.has(download.source.url))
return; return;
if (!download.succeeded) if (!download.succeeded)

View file

@ -7,8 +7,7 @@
* Provides infrastructure for automated download components tests. * Provides infrastructure for automated download components tests.
*/ */
//////////////////////////////////////////////////////////////////////////////// // Globals
//// Globals
XPCOMUtils.defineLazyModuleGetter(this, "Downloads", XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
"resource://gre/modules/Downloads.jsm"); "resource://gre/modules/Downloads.jsm");
@ -22,6 +21,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm"); "resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm"); "resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "HttpServer",
"resource://testing-common/httpd.js");
const nsIDM = Ci.nsIDownloadManager; const nsIDM = Ci.nsIDownloadManager;
var gTestTargetFile = FileUtils.getFile("TmpD", ["dm-ui-test.file"]); var gTestTargetFile = FileUtils.getFile("TmpD", ["dm-ui-test.file"]);
@ -29,9 +31,10 @@ gTestTargetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
// Load mocking/stubbing library, sinon // Load mocking/stubbing library, sinon
// docs: http://sinonjs.org/docs/ // docs: http://sinonjs.org/docs/
/* global sinon:false */
Services.scriptloader.loadSubScript("resource://testing-common/sinon-1.16.1.js"); Services.scriptloader.loadSubScript("resource://testing-common/sinon-1.16.1.js");
registerCleanupFunction(function () { registerCleanupFunction(function() {
gTestTargetFile.remove(false); gTestTargetFile.remove(false);
delete window.sinon; delete window.sinon;
@ -39,11 +42,9 @@ registerCleanupFunction(function () {
delete window.clearImmediate; delete window.clearImmediate;
}); });
//////////////////////////////////////////////////////////////////////////////// // Asynchronous support subroutines
//// Asynchronous support subroutines
function promiseOpenAndLoadWindow(aOptions) function promiseOpenAndLoadWindow(aOptions) {
{
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let win = OpenBrowserWindow(aOptions); let win = OpenBrowserWindow(aOptions);
win.addEventListener("load", function() { win.addEventListener("load", function() {
@ -66,8 +67,7 @@ function promiseOpenAndLoadWindow(aOptions)
* @resolves to the received event * @resolves to the received event
* @rejects if a valid load event is not received within a meaningful interval * @rejects if a valid load event is not received within a meaningful interval
*/ */
function promiseTabLoadEvent(tab, url, eventType="load") function promiseTabLoadEvent(tab, url, eventType = "load") {
{
let deferred = Promise.defer(); let deferred = Promise.defer();
info("Wait tab event: " + eventType); info("Wait tab event: " + eventType);
@ -96,8 +96,7 @@ function promiseTabLoadEvent(tab, url, eventType="load")
return deferred.promise; return deferred.promise;
} }
function promiseWindowClosed(win) function promiseWindowClosed(win) {
{
let promise = new Promise((resolve, reject) => { let promise = new Promise((resolve, reject) => {
Services.obs.addObserver(function obs(subject, topic) { Services.obs.addObserver(function obs(subject, topic) {
if (subject == win) { if (subject == win) {
@ -111,15 +110,13 @@ function promiseWindowClosed(win)
} }
function promiseFocus() function promiseFocus() {
{
let deferred = Promise.defer(); let deferred = Promise.defer();
waitForFocus(deferred.resolve); waitForFocus(deferred.resolve);
return deferred.promise; return deferred.promise;
} }
function promisePanelOpened() function promisePanelOpened() {
{
let deferred = Promise.defer(); let deferred = Promise.defer();
if (DownloadsPanel.panel && DownloadsPanel.panel.state == "open") { if (DownloadsPanel.panel && DownloadsPanel.panel.state == "open") {
@ -128,7 +125,7 @@ function promisePanelOpened()
// Hook to wait until the panel is shown. // Hook to wait until the panel is shown.
let originalOnPopupShown = DownloadsPanel.onPopupShown; let originalOnPopupShown = DownloadsPanel.onPopupShown;
DownloadsPanel.onPopupShown = function () { DownloadsPanel.onPopupShown = function() {
DownloadsPanel.onPopupShown = originalOnPopupShown; DownloadsPanel.onPopupShown = originalOnPopupShown;
originalOnPopupShown.apply(this, arguments); originalOnPopupShown.apply(this, arguments);
@ -140,8 +137,7 @@ function promisePanelOpened()
return deferred.promise; return deferred.promise;
} }
function* task_resetState() function* task_resetState() {
{
// Remove all downloads. // Remove all downloads.
let publicList = yield Downloads.getList(Downloads.PUBLIC); let publicList = yield Downloads.getList(Downloads.PUBLIC);
let downloads = yield publicList.getAll(); let downloads = yield publicList.getAll();
@ -155,8 +151,7 @@ function* task_resetState()
yield promiseFocus(); yield promiseFocus();
} }
function* task_addDownloads(aItems) function* task_addDownloads(aItems) {
{
let startTimeMs = Date.now(); let startTimeMs = Date.now();
let publicList = yield Downloads.getList(Downloads.PUBLIC); let publicList = yield Downloads.getList(Downloads.PUBLIC);
@ -184,8 +179,7 @@ function* task_addDownloads(aItems)
} }
} }
function* task_openPanel() function* task_openPanel() {
{
yield promiseFocus(); yield promiseFocus();
let promise = promisePanelOpened(); let promise = promisePanelOpened();
@ -198,7 +192,7 @@ function* setDownloadDir() {
tmpDir.append("testsavedir"); tmpDir.append("testsavedir");
if (!tmpDir.exists()) { if (!tmpDir.exists()) {
tmpDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755); tmpDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
registerCleanupFunction(function () { registerCleanupFunction(function() {
try { try {
tmpDir.remove(true); tmpDir.remove(true);
} catch (e) { } catch (e) {

View file

@ -7,8 +7,7 @@
* Provides infrastructure for automated download components tests. * Provides infrastructure for automated download components tests.
*/ */
//////////////////////////////////////////////////////////////////////////////// // Globals
//// Globals
var Cc = Components.classes; var Cc = Components.classes;
var Ci = Components.interfaces; var Ci = Components.interfaces;

View file

@ -7,8 +7,7 @@
* Tests for the functions located directly in the "DownloadsCommon" object. * Tests for the functions located directly in the "DownloadsCommon" object.
*/ */
function testFormatTimeLeft(aSeconds, aExpectedValue, aExpectedUnitString) function testFormatTimeLeft(aSeconds, aExpectedValue, aExpectedUnitString) {
{
let expected = ""; let expected = "";
if (aExpectedValue) { if (aExpectedValue) {
// Format the expected result based on the current language. // Format the expected result based on the current language.
@ -17,21 +16,20 @@ function testFormatTimeLeft(aSeconds, aExpectedValue, aExpectedUnitString)
do_check_eq(DownloadsCommon.formatTimeLeft(aSeconds), expected); do_check_eq(DownloadsCommon.formatTimeLeft(aSeconds), expected);
} }
function run_test() function run_test() {
{ testFormatTimeLeft(0, "", "");
testFormatTimeLeft( 0, "", ""); testFormatTimeLeft(1, "1", "shortTimeLeftSeconds");
testFormatTimeLeft( 1, "1", "shortTimeLeftSeconds"); testFormatTimeLeft(29, "29", "shortTimeLeftSeconds");
testFormatTimeLeft( 29, "29", "shortTimeLeftSeconds"); testFormatTimeLeft(30, "30", "shortTimeLeftSeconds");
testFormatTimeLeft( 30, "30", "shortTimeLeftSeconds"); testFormatTimeLeft(31, "1", "shortTimeLeftMinutes");
testFormatTimeLeft( 31, "1", "shortTimeLeftMinutes"); testFormatTimeLeft(60, "1", "shortTimeLeftMinutes");
testFormatTimeLeft( 60, "1", "shortTimeLeftMinutes"); testFormatTimeLeft(89, "1", "shortTimeLeftMinutes");
testFormatTimeLeft( 89, "1", "shortTimeLeftMinutes"); testFormatTimeLeft(90, "2", "shortTimeLeftMinutes");
testFormatTimeLeft( 90, "2", "shortTimeLeftMinutes"); testFormatTimeLeft(91, "2", "shortTimeLeftMinutes");
testFormatTimeLeft( 91, "2", "shortTimeLeftMinutes"); testFormatTimeLeft(3600, "1", "shortTimeLeftHours");
testFormatTimeLeft( 3600, "1", "shortTimeLeftHours"); testFormatTimeLeft(86400, "24", "shortTimeLeftHours");
testFormatTimeLeft( 86400, "24", "shortTimeLeftHours"); testFormatTimeLeft(169200, "47", "shortTimeLeftHours");
testFormatTimeLeft( 169200, "47", "shortTimeLeftHours"); testFormatTimeLeft(172800, "2", "shortTimeLeftDays");
testFormatTimeLeft( 172800, "2", "shortTimeLeftDays");
testFormatTimeLeft(8553600, "99", "shortTimeLeftDays"); testFormatTimeLeft(8553600, "99", "shortTimeLeftDays");
testFormatTimeLeft(8640000, "99", "shortTimeLeftDays"); testFormatTimeLeft(8640000, "99", "shortTimeLeftDays");
} }