зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1822864 - Remove browser.download.improvements_to_download_panel pref r=Gijs,settings-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D179300
This commit is contained in:
Родитель
2e8db5969a
Коммит
941d7766f8
|
@ -35,21 +35,15 @@
|
|||
}
|
||||
|
||||
function getDownloadStartedPromise() {
|
||||
if (Services.prefs.getBoolPref("browser.download.improvements_to_download_panel", false)) {
|
||||
return Downloads.getList(Downloads.PUBLIC).then(list => {
|
||||
return new Promise(resolve => {
|
||||
list.addView({
|
||||
onDownloadAdded(download) {
|
||||
resolve(download);
|
||||
}
|
||||
})
|
||||
});
|
||||
return Downloads.getList(Downloads.PUBLIC).then(list => {
|
||||
return new Promise(resolve => {
|
||||
list.addView({
|
||||
onDownloadAdded(download) {
|
||||
resolve(download);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
return BrowserTestUtils.domWindowOpenedAndLoaded(
|
||||
null,
|
||||
win => win.location?.href == "chrome://mozapps/content/downloads/unknownContentType.xhtml"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
async function downloadHandled(downloadResult) {
|
||||
|
|
|
@ -192,7 +192,6 @@ add_task(async function () {
|
|||
);
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", false],
|
||||
["browser.download.always_ask_before_handling_new_types", true],
|
||||
["browser.download.useDownloadDir", true],
|
||||
],
|
||||
|
@ -210,7 +209,6 @@ add_task(async function () {
|
|||
);
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.useDownloadDir", false],
|
||||
],
|
||||
|
|
|
@ -977,9 +977,6 @@ DownloadsDataCtor.prototype = {
|
|||
|
||||
let shouldOpenDownloadsPanel =
|
||||
aType == "start" &&
|
||||
Services.prefs.getBoolPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
) &&
|
||||
DownloadsCommon.summarizeDownloads(this._downloads).numDownloading <= 1 &&
|
||||
lazy.gAlwaysOpenPanel;
|
||||
|
||||
|
|
|
@ -298,7 +298,6 @@ export var DownloadsViewUI = {
|
|||
// If non default mime-type or cannot be opened internally, display
|
||||
// "always open similar files" item instead so that users can add a new
|
||||
// mimetype to about:preferences table and set to open with system default.
|
||||
// Only appear if browser.download.improvements_to_download_panel is enabled.
|
||||
let alwaysOpenSimilarFilesItem = contextMenu.querySelector(
|
||||
".downloadAlwaysOpenSimilarFilesMenuItem"
|
||||
);
|
||||
|
@ -336,12 +335,10 @@ export var DownloadsViewUI = {
|
|||
(mimeInfo.type === "text/plain" &&
|
||||
lazy.gReputationService.isBinary(download.target.path));
|
||||
|
||||
if (DownloadsViewUI.improvementsIsOn && !canViewInternally) {
|
||||
alwaysOpenSimilarFilesItem.hidden =
|
||||
state !== DOWNLOAD_FINISHED || shouldNotRememberChoice;
|
||||
} else {
|
||||
alwaysOpenSimilarFilesItem.hidden = true;
|
||||
}
|
||||
alwaysOpenSimilarFilesItem.hidden =
|
||||
canViewInternally ||
|
||||
state !== DOWNLOAD_FINISHED ||
|
||||
shouldNotRememberChoice;
|
||||
|
||||
// Update checkbox for "always open..." options.
|
||||
if (preferredAction === useSystemDefault) {
|
||||
|
@ -354,13 +351,6 @@ export var DownloadsViewUI = {
|
|||
},
|
||||
};
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
DownloadsViewUI,
|
||||
"improvementsIsOn",
|
||||
"browser.download.improvements_to_download_panel",
|
||||
false
|
||||
);
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
DownloadsViewUI,
|
||||
"clearHistoryOnDelete",
|
||||
|
@ -696,10 +686,7 @@ DownloadsViewUI.DownloadElementShell.prototype = {
|
|||
_updateStateInner() {
|
||||
let progressPaused = false;
|
||||
|
||||
this.element.classList.toggle(
|
||||
"openWhenFinished",
|
||||
DownloadsViewUI.improvementsIsOn && !this.download.stopped
|
||||
);
|
||||
this.element.classList.toggle("openWhenFinished", !this.download.stopped);
|
||||
|
||||
if (!this.download.stopped) {
|
||||
// The download is in progress, so we don't change the button state
|
||||
|
@ -717,19 +704,14 @@ DownloadsViewUI.DownloadElementShell.prototype = {
|
|||
);
|
||||
this.lastEstimatedSecondsLeft = newEstimatedSecondsLeft;
|
||||
|
||||
if (
|
||||
DownloadsViewUI.improvementsIsOn &&
|
||||
this.download.launchWhenSucceeded
|
||||
) {
|
||||
if (this.download.launchWhenSucceeded) {
|
||||
status = lazy.DownloadUtils.getFormattedTimeStatus(
|
||||
newEstimatedSecondsLeft
|
||||
);
|
||||
}
|
||||
let hoverStatus = DownloadsViewUI.improvementsIsOn
|
||||
? {
|
||||
l10n: { id: "downloading-file-click-to-open" },
|
||||
}
|
||||
: undefined;
|
||||
let hoverStatus = {
|
||||
l10n: { id: "downloading-file-click-to-open" },
|
||||
};
|
||||
this.showStatus(status, hoverStatus);
|
||||
} else {
|
||||
let verdict = "";
|
||||
|
|
|
@ -901,13 +901,7 @@ var DownloadsView = {
|
|||
}
|
||||
}
|
||||
// Toggle opening the file after the download has completed
|
||||
if (
|
||||
!download.stopped &&
|
||||
command.startsWith("downloadsCmd_open") &&
|
||||
Services.prefs.getBoolPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
)
|
||||
) {
|
||||
if (!download.stopped && command.startsWith("downloadsCmd_open")) {
|
||||
download.launchWhenSucceeded = !download.launchWhenSucceeded;
|
||||
download._launchedFromPanel = download.launchWhenSucceeded;
|
||||
}
|
||||
|
|
|
@ -12,9 +12,6 @@ const { TelemetryTestUtils } = ChromeUtils.importESModule(
|
|||
);
|
||||
|
||||
add_task(async function test_download_clickable() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.download.improvements_to_download_panel", true]],
|
||||
});
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
startServer();
|
||||
|
|
|
@ -12,9 +12,6 @@ const { TelemetryTestUtils } = ChromeUtils.importESModule(
|
|||
);
|
||||
|
||||
add_task(async function test_download_opens_on_click() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.download.improvements_to_download_panel", true]],
|
||||
});
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
startServer();
|
||||
|
|
|
@ -16,9 +16,6 @@ const { TelemetryTestUtils } = ChromeUtils.importESModule(
|
|||
);
|
||||
|
||||
add_task(async function test_download_opens_on_click() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.download.improvements_to_download_panel", true]],
|
||||
});
|
||||
Services.telemetry.clearScalars();
|
||||
|
||||
await EnterprisePolicyTesting.setupPolicyEngineWithJson({
|
||||
|
|
|
@ -23,7 +23,6 @@ add_setup(async function () {
|
|||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.useDownloadDir", false],
|
||||
],
|
||||
|
|
|
@ -36,7 +36,6 @@ add_setup(async function () {
|
|||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.download.enable_spam_prevention", true]],
|
||||
clear: [
|
||||
["browser.download.improvements_to_download_panel"],
|
||||
["browser.download.alwaysOpenPanel"],
|
||||
["browser.download.always_ask_before_handling_new_types"],
|
||||
],
|
||||
|
|
|
@ -55,10 +55,7 @@ async function prepareDownloadFiles(downloadList) {
|
|||
|
||||
add_setup(async function () {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", false]],
|
||||
});
|
||||
const originalOpenDownload = DownloadsCommon.openDownload;
|
||||
// overwrite DownloadsCommon.openDownload to prevent file from opening during tests
|
||||
|
|
|
@ -43,7 +43,6 @@ registerCleanupFunction(async function () {
|
|||
add_task(async function test_download_deleteFile() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.alwaysOpenPanel", false],
|
||||
["browser.download.clearHistoryOnDelete", 2],
|
||||
|
|
|
@ -36,140 +36,9 @@ const MENU_ITEMS = {
|
|||
clearDownloads: '[command="downloadsCmd_clearDownloads"]',
|
||||
};
|
||||
|
||||
const TestCasesDefaultMimetypes = [
|
||||
const TestCasesNewMimetypes = [
|
||||
{
|
||||
name: "Completed PDF download with improvements pref disabled",
|
||||
prefEnabled: false,
|
||||
downloads: [
|
||||
{
|
||||
state: DownloadsCommon.DOWNLOAD_FINISHED,
|
||||
contentType: "application/pdf",
|
||||
target: {},
|
||||
source: {
|
||||
referrerInfo: exampleRefInfo,
|
||||
},
|
||||
},
|
||||
],
|
||||
expected: {
|
||||
menu: [
|
||||
MENU_ITEMS.openInSystemViewer,
|
||||
MENU_ITEMS.alwaysOpenInSystemViewer,
|
||||
MENU_ITEMS.show,
|
||||
MENU_ITEMS.commandsSeparator,
|
||||
MENU_ITEMS.openReferrer,
|
||||
MENU_ITEMS.copyLocation,
|
||||
MENU_ITEMS.separator,
|
||||
MENU_ITEMS.deleteFile,
|
||||
MENU_ITEMS.delete,
|
||||
MENU_ITEMS.clearList,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Completed PDF download with improvements pref disabled and referrer info missing",
|
||||
prefEnabled: false,
|
||||
downloads: [
|
||||
{
|
||||
state: DownloadsCommon.DOWNLOAD_FINISHED,
|
||||
contentType: "application/pdf",
|
||||
target: {},
|
||||
},
|
||||
],
|
||||
expected: {
|
||||
menu: [
|
||||
MENU_ITEMS.openInSystemViewer,
|
||||
MENU_ITEMS.alwaysOpenInSystemViewer,
|
||||
MENU_ITEMS.show,
|
||||
MENU_ITEMS.commandsSeparator,
|
||||
MENU_ITEMS.copyLocation,
|
||||
MENU_ITEMS.separator,
|
||||
MENU_ITEMS.deleteFile,
|
||||
MENU_ITEMS.delete,
|
||||
MENU_ITEMS.clearList,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Canceled PDF download with improvements pref disabled",
|
||||
prefEnabled: false,
|
||||
downloads: [
|
||||
{
|
||||
state: DownloadsCommon.DOWNLOAD_CANCELED,
|
||||
contentType: "application/pdf",
|
||||
target: {},
|
||||
source: {
|
||||
referrerInfo: exampleRefInfo,
|
||||
},
|
||||
},
|
||||
],
|
||||
expected: {
|
||||
menu: [
|
||||
MENU_ITEMS.openReferrer,
|
||||
MENU_ITEMS.copyLocation,
|
||||
MENU_ITEMS.separator,
|
||||
MENU_ITEMS.delete,
|
||||
MENU_ITEMS.clearList,
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const TestCasesNewMimetypesPrefDisabled = [
|
||||
{
|
||||
name: "Completed txt download with improvements pref disabled",
|
||||
prefEnabled: false,
|
||||
downloads: [
|
||||
{
|
||||
state: DownloadsCommon.DOWNLOAD_FINISHED,
|
||||
contentType: "text/plain",
|
||||
target: {},
|
||||
source: {
|
||||
referrerInfo: exampleRefInfo,
|
||||
},
|
||||
},
|
||||
],
|
||||
expected: {
|
||||
menu: [
|
||||
MENU_ITEMS.show,
|
||||
MENU_ITEMS.commandsSeparator,
|
||||
MENU_ITEMS.openReferrer,
|
||||
MENU_ITEMS.copyLocation,
|
||||
MENU_ITEMS.separator,
|
||||
MENU_ITEMS.deleteFile,
|
||||
MENU_ITEMS.delete,
|
||||
MENU_ITEMS.clearList,
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Canceled txt download with improvements pref disabled",
|
||||
prefEnabled: false,
|
||||
downloads: [
|
||||
{
|
||||
state: DownloadsCommon.DOWNLOAD_CANCELED,
|
||||
contentType: "text/plain",
|
||||
target: {},
|
||||
source: {
|
||||
referrerInfo: exampleRefInfo,
|
||||
},
|
||||
},
|
||||
],
|
||||
expected: {
|
||||
menu: [
|
||||
MENU_ITEMS.openReferrer,
|
||||
MENU_ITEMS.copyLocation,
|
||||
MENU_ITEMS.separator,
|
||||
MENU_ITEMS.delete,
|
||||
MENU_ITEMS.clearList,
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const TestCasesNewMimetypesPrefEnabled = [
|
||||
{
|
||||
name: "Completed txt download with improvements pref enabled",
|
||||
prefEnabled: true,
|
||||
name: "Completed txt download",
|
||||
downloads: [
|
||||
{
|
||||
state: DownloadsCommon.DOWNLOAD_FINISHED,
|
||||
|
@ -195,8 +64,7 @@ const TestCasesNewMimetypesPrefEnabled = [
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "Canceled txt download with improvements pref enabled",
|
||||
prefEnabled: true,
|
||||
name: "Canceled txt download",
|
||||
downloads: [
|
||||
{
|
||||
state: DownloadsCommon.DOWNLOAD_CANCELED,
|
||||
|
@ -218,8 +86,7 @@ const TestCasesNewMimetypesPrefEnabled = [
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "Completed unknown ext download with application/octet-stream and improvements pref enabled",
|
||||
prefEnabled: true,
|
||||
name: "Completed unknown ext download with application/octet-stream",
|
||||
overrideExtension: "unknownExtension",
|
||||
downloads: [
|
||||
{
|
||||
|
@ -245,8 +112,7 @@ const TestCasesNewMimetypesPrefEnabled = [
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "Completed txt download with application/octet-stream and improvements pref enabled",
|
||||
prefEnabled: true,
|
||||
name: "Completed txt download with application/octet-stream",
|
||||
overrideExtension: "txt",
|
||||
downloads: [
|
||||
{
|
||||
|
@ -279,8 +145,7 @@ const TestCasesNewMimetypesPrefEnabled = [
|
|||
|
||||
const TestCasesDeletedFile = [
|
||||
{
|
||||
name: "Download with file deleted and improvements pref enabled",
|
||||
prefEnabled: true,
|
||||
name: "Download with file deleted",
|
||||
downloads: [
|
||||
{
|
||||
state: DownloadsCommon.DOWNLOAD_FINISHED,
|
||||
|
@ -308,7 +173,6 @@ const TestCasesDeletedFile = [
|
|||
const TestCasesMultipleFiles = [
|
||||
{
|
||||
name: "Multiple files",
|
||||
prefEnabled: true,
|
||||
downloads: [
|
||||
{
|
||||
state: DownloadsCommon.DOWNLOAD_FINISHED,
|
||||
|
@ -381,40 +245,8 @@ add_setup(async function () {
|
|||
);
|
||||
});
|
||||
|
||||
// register the tests
|
||||
for (let testData of TestCasesDefaultMimetypes) {
|
||||
if (testData.skip) {
|
||||
info("Skipping test:" + testData.name);
|
||||
continue;
|
||||
}
|
||||
// use the 'name' property of each test case as the test function name
|
||||
// so we get useful logs
|
||||
let tmp = {
|
||||
async [testData.name]() {
|
||||
await testDownloadContextMenu(testData);
|
||||
},
|
||||
};
|
||||
add_task(tmp[testData.name]);
|
||||
}
|
||||
|
||||
// non default mimetypes with browser.download.improvements_to_download_panel disabled
|
||||
for (let testData of TestCasesNewMimetypesPrefDisabled) {
|
||||
if (testData.skip) {
|
||||
info("Skipping test:" + testData.name);
|
||||
continue;
|
||||
}
|
||||
// use the 'name' property of each test case as the test function name
|
||||
// so we get useful logs
|
||||
let tmp = {
|
||||
async [testData.name]() {
|
||||
await testDownloadContextMenu(testData);
|
||||
},
|
||||
};
|
||||
add_task(tmp[testData.name]);
|
||||
}
|
||||
|
||||
// non default mimetypes with browser.download.improvements_to_download_panel enabled
|
||||
for (let testData of TestCasesNewMimetypesPrefEnabled) {
|
||||
// non default mimetypes
|
||||
for (let testData of TestCasesNewMimetypes) {
|
||||
if (testData.skip) {
|
||||
info("Skipping test:" + testData.name);
|
||||
continue;
|
||||
|
@ -463,16 +295,8 @@ async function testDownloadContextMenu({
|
|||
overrideExtension = null,
|
||||
downloads = [],
|
||||
expected,
|
||||
prefEnabled,
|
||||
itemIndex = 0,
|
||||
}) {
|
||||
info(
|
||||
`Setting browser.download.improvements_to_download_panel to ${prefEnabled}`
|
||||
);
|
||||
SpecialPowers.setBoolPref(
|
||||
"browser.download.improvements_to_download_panel",
|
||||
prefEnabled
|
||||
);
|
||||
// prepare downloads
|
||||
await prepareDownloads(downloads, overrideExtension);
|
||||
let downloadList = await Downloads.getList(Downloads.PUBLIC);
|
||||
|
|
|
@ -12,7 +12,6 @@ const TEST_PATH = getRootDirectory(gTestPath).replace(
|
|||
add_setup(async function () {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.alwaysOpenPanel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["security.dialog_enable_delay", 1000],
|
||||
|
|
|
@ -5,10 +5,7 @@
|
|||
|
||||
add_setup(async function () {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", false]],
|
||||
});
|
||||
|
||||
registerCleanupFunction(async () => {
|
||||
|
|
|
@ -154,7 +154,6 @@ async function testDownloadsPanelAfterDialog({
|
|||
set: [
|
||||
["browser.download.useDownloadDir", !askWhereToSave],
|
||||
["browser.download.always_ask_before_handling_new_types", openUCT],
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["security.dialog_enable_delay", 0],
|
||||
],
|
||||
});
|
||||
|
@ -264,7 +263,6 @@ async function testDownloadsPanelAfterDialog({
|
|||
add_task(async function test_downloads_panel_opens() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.alwaysOpenPanel", true],
|
||||
],
|
||||
|
@ -275,7 +273,6 @@ add_task(async function test_downloads_panel_opens() {
|
|||
add_task(async function test_customizemode_doesnt_wreck_things() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.alwaysOpenPanel", true],
|
||||
],
|
||||
|
@ -335,7 +332,6 @@ add_task(async function test_customizemode_doesnt_wreck_things() {
|
|||
add_task(async function test_downloads_panel_opening_pref() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.alwaysOpenPanel", false],
|
||||
],
|
||||
|
@ -354,7 +350,6 @@ add_task(async function test_downloads_panel_opening_pref() {
|
|||
add_task(async function test_downloads_openDownloadsListOnStart_param() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.alwaysOpenPanel", true],
|
||||
],
|
||||
|
@ -376,7 +371,6 @@ add_task(async function test_downloads_openDownloadsListOnStart_param() {
|
|||
add_task(async function test_downloads_panel_on_webext_download_api() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.alwaysOpenPanel", true],
|
||||
],
|
||||
|
@ -481,10 +475,7 @@ add_task(async function test_downloads_panel_on_webext_download_api() {
|
|||
*/
|
||||
add_task(async function test_downloads_panel_remains_closed() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", false]],
|
||||
});
|
||||
await task_addDownloads([
|
||||
{ state: DownloadsCommon.DOWNLOAD_DOWNLOADING },
|
||||
|
@ -542,10 +533,7 @@ add_task(async function test_downloads_panel_remains_closed() {
|
|||
*/
|
||||
add_task(async function test_downloads_panel_inactive_window() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", false]],
|
||||
});
|
||||
|
||||
let oldShowEventNotification = DownloadsIndicatorView.showEventNotification;
|
||||
|
|
|
@ -49,26 +49,20 @@ add_task(async function test_first_download_panel() {
|
|||
"Should have recorded that the panel was opened on a download."
|
||||
);
|
||||
|
||||
// If browser.download.improvements_to_download_panel is enabled, this will fail
|
||||
// because we always open a downloads panel as long as there is no other simulatenous
|
||||
// download. So, first ensure that this pref is already false.
|
||||
if (
|
||||
!SpecialPowers.getBoolPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
)
|
||||
) {
|
||||
// Next, make sure that if we start another download, we don't open the
|
||||
// panel automatically.
|
||||
let originalOnPopupShown = DownloadsPanel.onPopupShown;
|
||||
DownloadsPanel.onPopupShown = function () {
|
||||
originalOnPopupShown.apply(this, arguments);
|
||||
ok(false, "Should not have opened the downloads panel.");
|
||||
};
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.download.alwaysOpenPanel", false]],
|
||||
});
|
||||
// Next, make sure that if we start another download, we don't open the
|
||||
// panel automatically.
|
||||
let originalOnPopupShown = DownloadsPanel.onPopupShown;
|
||||
DownloadsPanel.onPopupShown = function () {
|
||||
originalOnPopupShown.apply(this, arguments);
|
||||
ok(false, "Should not have opened the downloads panel.");
|
||||
};
|
||||
|
||||
DownloadsCommon.getData(window)._notifyDownloadEvent("start");
|
||||
DownloadsCommon.getData(window)._notifyDownloadEvent("start");
|
||||
|
||||
// Wait 2 seconds to ensure that the panel does not open.
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
DownloadsPanel.onPopupShown = originalOnPopupShown;
|
||||
}
|
||||
// Wait 2 seconds to ensure that the panel does not open.
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
DownloadsPanel.onPopupShown = originalOnPopupShown;
|
||||
});
|
||||
|
|
|
@ -58,7 +58,6 @@ add_task(async function test_save_image_webp_with_jpeg_extension() {
|
|||
add_task(async function test_save_link_webp_with_jpeg_extension() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.useDownloadDir", false],
|
||||
],
|
||||
|
|
|
@ -18,10 +18,7 @@ add_task(async function test_tempfilename() {
|
|||
});
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", false]],
|
||||
});
|
||||
|
||||
const MimeSvc = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
|
||||
|
|
|
@ -81,7 +81,6 @@ async function removeTheFile(download) {
|
|||
add_task(async function alwaysAskPreferenceWorks() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.useDownloadDir", true],
|
||||
],
|
||||
|
@ -134,7 +133,6 @@ add_task(async function alwaysAskPreferenceWorks() {
|
|||
add_task(async function handleInternallyPreferenceWorks() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.useDownloadDir", true],
|
||||
],
|
||||
|
@ -179,7 +177,6 @@ add_task(async function handleInternallyPreferenceWorks() {
|
|||
add_task(async function saveToDiskPreferenceWorks() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.useDownloadDir", true],
|
||||
],
|
||||
|
@ -224,7 +221,6 @@ add_task(async function saveToDiskPreferenceWorks() {
|
|||
add_task(async function useSystemDefaultPreferenceWorks() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.useDownloadDir", true],
|
||||
],
|
||||
|
|
|
@ -47,7 +47,6 @@ add_task(async function test_with_downloads_pref_disabled() {
|
|||
set: [
|
||||
["security.data_uri.block_toplevel_data_uri_navigations", true],
|
||||
["browser.download.always_ask_before_handling_new_types", true],
|
||||
["browser.download.improvements_to_download_panel", false],
|
||||
],
|
||||
});
|
||||
let windowPromise = addWindowListener(
|
||||
|
@ -73,7 +72,6 @@ add_task(async function test_with_always_ask_pref_disabled() {
|
|||
set: [
|
||||
["security.data_uri.block_toplevel_data_uri_navigations", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
],
|
||||
});
|
||||
let downloadsPanelPromise = promisePanelOpened();
|
||||
|
|
|
@ -39,7 +39,6 @@ add_task(async function test_with_pref_enabled() {
|
|||
set: [
|
||||
["security.data_uri.block_toplevel_data_uri_navigations", true],
|
||||
["browser.download.always_ask_before_handling_new_types", true],
|
||||
["browser.download.improvements_to_download_panel", false],
|
||||
],
|
||||
});
|
||||
|
||||
|
@ -65,7 +64,6 @@ add_task(async function test_with_pref_disabled() {
|
|||
set: [
|
||||
["security.data_uri.block_toplevel_data_uri_navigations", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
],
|
||||
});
|
||||
let downloadsPanelPromise = promisePanelOpened();
|
||||
|
|
|
@ -82,11 +82,7 @@ function shouldConsoleTryUpgradeAndError() {
|
|||
// 4. Successfully completes download
|
||||
add_task(async function test_with_downloads_pref_enabled() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["dom.security.https_first", true],
|
||||
// ensure that download panel gets opened - Bug 1746434
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
],
|
||||
set: [["dom.security.https_first", true]],
|
||||
});
|
||||
let checkPromise = shouldConsoleTryUpgradeAndError();
|
||||
let downloadsPanelPromise = promisePanelOpened();
|
||||
|
|
|
@ -108,7 +108,6 @@ async function runTest(url, link, checkFunction, description) {
|
|||
set: [
|
||||
["dom.security.https_first", true],
|
||||
["browser.download.always_ask_before_handling_new_types", true],
|
||||
["browser.download.improvements_to_download_panel", false],
|
||||
],
|
||||
});
|
||||
requestLongerTimeout(2);
|
||||
|
|
|
@ -104,11 +104,7 @@ examiner.prototype = {
|
|||
// 5. Complete download of text file
|
||||
add_task(async function test_slow_download() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["dom.security.https_first", true],
|
||||
// ensure that download panel gets opened
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
],
|
||||
set: [["dom.security.https_first", true]],
|
||||
});
|
||||
|
||||
// remove all previous downloads
|
||||
|
|
|
@ -127,10 +127,7 @@ add_setup(async function () {
|
|||
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_ALL, resolve);
|
||||
});
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["dom.block_download_insecure", true],
|
||||
],
|
||||
set: [["dom.block_download_insecure", true]],
|
||||
});
|
||||
});
|
||||
//Test description:
|
||||
|
|
|
@ -206,10 +206,7 @@ add_setup(async () => {
|
|||
add_task(async function test_blocking() {
|
||||
for (let prefVal of [true, false]) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.always_ask_before_handling_new_types", prefVal],
|
||||
["browser.download.improvements_to_download_panel", !prefVal],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", prefVal]],
|
||||
});
|
||||
await runTest(
|
||||
INSECURE_BASE_URL,
|
||||
|
@ -248,10 +245,7 @@ add_task(async function test_blocking() {
|
|||
add_task(async function test_manual_unblocking() {
|
||||
for (let prefVal of [true, false]) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.always_ask_before_handling_new_types", prefVal],
|
||||
["browser.download.improvements_to_download_panel", !prefVal],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", prefVal]],
|
||||
});
|
||||
await runTest(
|
||||
SECURE_BASE_URL,
|
||||
|
@ -274,10 +268,7 @@ add_task(async function test_manual_unblocking() {
|
|||
add_task(async function test_unblock_download_visible() {
|
||||
for (let prefVal of [true, false]) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.always_ask_before_handling_new_types", prefVal],
|
||||
["browser.download.improvements_to_download_panel", !prefVal],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", prefVal]],
|
||||
});
|
||||
// Focus, open and close the panel once
|
||||
// to make sure the panel is loaded and ready
|
||||
|
@ -308,10 +299,7 @@ add_task(async function download_open_insecure_SVG() {
|
|||
HandlerService.store(mimeInfo);
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", false]],
|
||||
});
|
||||
await promiseFocus();
|
||||
await runTest(
|
||||
|
|
|
@ -1326,12 +1326,6 @@
|
|||
value: @IS_NOT_MOZILLA_OFFICIAL@
|
||||
mirror: always
|
||||
|
||||
# See bug 1710926
|
||||
- name: browser.download.improvements_to_download_panel
|
||||
type: bool
|
||||
value: true
|
||||
mirror: always
|
||||
|
||||
# See bug 1738574
|
||||
- name: browser.download.start_downloads_in_tmp_dir
|
||||
type: bool
|
||||
|
|
|
@ -559,19 +559,8 @@ export var DownloadIntegration = {
|
|||
// this is a permanently downloaded file or a temporary download to be
|
||||
// opened read-only with an external application.
|
||||
try {
|
||||
// The following logic to determine whether this is a temporary download
|
||||
// is due to the fact that "deleteTempFileOnExit" is false on Mac, where
|
||||
// downloads to be opened with external applications are preserved in
|
||||
// the "Downloads" folder like normal downloads.
|
||||
let isTemporaryDownload =
|
||||
aDownload.launchWhenSucceeded &&
|
||||
(aDownload.source.isPrivate ||
|
||||
(Services.prefs.getBoolPref(
|
||||
"browser.helperApps.deleteTempFileOnExit"
|
||||
) &&
|
||||
!Services.prefs.getBoolPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
)));
|
||||
aDownload.launchWhenSucceeded && aDownload.source.isPrivate;
|
||||
// Permanently downloaded files are made accessible by other users on
|
||||
// this system, while temporary downloads are marked as read-only.
|
||||
let unixMode;
|
||||
|
|
|
@ -264,12 +264,7 @@ add_task(async function test_unix_permissions() {
|
|||
await promiseDownloadStopped(download);
|
||||
}
|
||||
|
||||
let prefEnabled = Services.prefs.getBoolPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
);
|
||||
|
||||
let isTemporary =
|
||||
launchWhenSucceeded && (isPrivate || (autoDelete && !prefEnabled));
|
||||
let isTemporary = launchWhenSucceeded && isPrivate;
|
||||
let stat = await IOUtils.stat(download.target.path);
|
||||
if (Services.appinfo.OS == "WINNT") {
|
||||
// On Windows
|
||||
|
@ -2672,15 +2667,9 @@ add_task(async function test_launchWhenSucceeded_deleteTempFileOnExit() {
|
|||
"@mozilla.org/uriloader/external-helper-app-service;1"
|
||||
].getService(Ci.nsIObserver);
|
||||
expire.observe(null, "profile-before-change", null);
|
||||
// Whether the temp file should have been deleted or not depends on the value
|
||||
// of the improvements pref; if the pref is true, then the file should still
|
||||
// exist following the simulated shutdown.
|
||||
Assert.equal(
|
||||
Services.prefs.getBoolPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
),
|
||||
await IOUtils.exists(autoDeleteTargetPathTwo)
|
||||
);
|
||||
|
||||
// The file should still exist following the simulated shutdown.
|
||||
Assert.ok(await IOUtils.exists(autoDeleteTargetPathTwo));
|
||||
Assert.ok(await IOUtils.exists(noAutoDeleteTargetPath));
|
||||
});
|
||||
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
* The temporary directory downloads saves to, should be only readable
|
||||
* for the current user.
|
||||
*/
|
||||
add_task(async function test_private_temp() {
|
||||
Services.prefs.setBoolPref(
|
||||
"browser.download.improvements_to_download_panel",
|
||||
false
|
||||
);
|
||||
|
||||
let download = await promiseStartExternalHelperAppServiceDownload(
|
||||
httpUrl("empty.txt")
|
||||
);
|
||||
|
||||
await promiseDownloadStopped(download);
|
||||
|
||||
var targetFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
|
||||
targetFile.initWithPath(download.target.path);
|
||||
|
||||
// 488 is the decimal value of 0o700.
|
||||
equal(targetFile.parent.permissions, 448);
|
||||
|
||||
Services.prefs.setBoolPref(
|
||||
"browser.download.improvements_to_download_panel",
|
||||
true
|
||||
);
|
||||
});
|
|
@ -20,6 +20,4 @@ run-sequentially = very high failure rate in parallel
|
|||
[test_DownloadList.js]
|
||||
[test_DownloadPaths.js]
|
||||
[test_Downloads.js]
|
||||
[test_DownloadStore.js]
|
||||
[test_PrivateTemp.js]
|
||||
skip-if = true # Bug 1336730
|
||||
[test_DownloadStore.js]
|
|
@ -59,10 +59,7 @@ add_task(async function test_downloading_pdf_nonprivate_window() {
|
|||
const pdfUrl = TESTROOT + "file_pdfjs_test.pdf";
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", false]],
|
||||
});
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
|
|
|
@ -46,15 +46,11 @@ add_task(async function test_octet_stream_opens_pdfjs() {
|
|||
});
|
||||
|
||||
/**
|
||||
* Check that when the improvements_to_download_panel pref is false and
|
||||
* if the octet-stream thing is in a frame, we don't load it inside PDF.js
|
||||
* Check that if the octet-stream thing is in a frame, we don't load it inside PDF.js
|
||||
*/
|
||||
add_task(async function test_octet_stream_in_frame_downloads() {
|
||||
add_task(async function test_octet_stream_in_frame() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["pdfjs.handleOctetStream", true],
|
||||
["browser.download.improvements_to_download_panel", false],
|
||||
],
|
||||
set: [["pdfjs.handleOctetStream", true]],
|
||||
});
|
||||
|
||||
let handlerInfo = gMIMEService.getFromTypeAndExtension(
|
||||
|
@ -74,125 +70,77 @@ add_task(async function test_octet_stream_in_frame_downloads() {
|
|||
"pdf handler defaults to internal"
|
||||
);
|
||||
|
||||
let dialogPromise = BrowserTestUtils.domWindowOpenedAndLoaded();
|
||||
let downloadsPanelPromise = BrowserTestUtils.waitForEvent(
|
||||
DownloadsPanel.panel,
|
||||
"popupshown"
|
||||
);
|
||||
|
||||
// Once downloaded, the PDF will be opened as a file:// URI in a new tab
|
||||
let previewTabPromise = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
url => {
|
||||
let uri = NetUtil.newURI(url);
|
||||
return uri.scheme == "file" && uri.spec.endsWith(".pdf");
|
||||
},
|
||||
false, // dont wait for load
|
||||
true // any tab, not just the next one
|
||||
);
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: `data:text/html,<iframe src='${PDF_URL}'>` },
|
||||
async function (newTabBrowser) {
|
||||
let dialogWin = await dialogPromise;
|
||||
ok(dialogWin, "Should have a dialog asking what to do.");
|
||||
dialogWin.close(); // This is going to cancel the dialog.
|
||||
// wait until downloadsPanel opens before continuing with test
|
||||
info("Waiting for download panel to open");
|
||||
await downloadsPanelPromise;
|
||||
is(
|
||||
DownloadsPanel.panel.state,
|
||||
"open",
|
||||
"Check the download panel state is 'open'"
|
||||
);
|
||||
let downloadList = await Downloads.getList(Downloads.PUBLIC);
|
||||
let [download] = downloadList._downloads;
|
||||
|
||||
// Verify the downloaded PDF opened in a new tab,
|
||||
// with its download file URI
|
||||
info("Waiting for preview tab");
|
||||
let previewTab = await previewTabPromise;
|
||||
ok(previewTab, "PDF opened in a new tab");
|
||||
|
||||
is(DownloadsPanel.isPanelShowing, true, "DownloadsPanel should be open.");
|
||||
is(
|
||||
downloadList._downloads.length,
|
||||
1,
|
||||
"File should be successfully downloaded."
|
||||
);
|
||||
|
||||
await BrowserTestUtils.removeTab(previewTab);
|
||||
|
||||
info("cleaning up downloads");
|
||||
try {
|
||||
if (Services.appinfo.OS === "WINNT") {
|
||||
// We need to make the file writable to delete it on Windows.
|
||||
await IOUtils.setPermissions(download.target.path, 0o600);
|
||||
}
|
||||
await IOUtils.remove(download.target.path);
|
||||
} catch (error) {
|
||||
info("The file " + download.target.path + " is not removed, " + error);
|
||||
}
|
||||
await downloadList.remove(download);
|
||||
await download.finalize();
|
||||
|
||||
if (DownloadsPanel.panel.state !== "closed") {
|
||||
let hiddenPromise = BrowserTestUtils.waitForEvent(
|
||||
DownloadsPanel.panel,
|
||||
"popuphidden"
|
||||
);
|
||||
DownloadsPanel.hidePanel();
|
||||
await hiddenPromise;
|
||||
}
|
||||
is(
|
||||
DownloadsPanel.panel.state,
|
||||
"closed",
|
||||
"Check that the download panel is closed"
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Check that when the improvements_to_download_panel pref is true and
|
||||
* if the octet-stream thing is in a frame, we don't load it inside PDF.js
|
||||
*/
|
||||
add_task(
|
||||
async function test_octet_stream_in_frame_downloads_improvements_to_download_panel() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["pdfjs.handleOctetStream", true],
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
],
|
||||
});
|
||||
|
||||
let handlerInfo = gMIMEService.getFromTypeAndExtension(
|
||||
"application/pdf",
|
||||
"pdf"
|
||||
);
|
||||
|
||||
// Make sure pdf.js is the default handler.
|
||||
is(
|
||||
handlerInfo.alwaysAskBeforeHandling,
|
||||
false,
|
||||
"pdf handler defaults to always-ask is false"
|
||||
);
|
||||
is(
|
||||
handlerInfo.preferredAction,
|
||||
Ci.nsIHandlerInfo.handleInternally,
|
||||
"pdf handler defaults to internal"
|
||||
);
|
||||
|
||||
let downloadsPanelPromise = BrowserTestUtils.waitForEvent(
|
||||
DownloadsPanel.panel,
|
||||
"popupshown"
|
||||
);
|
||||
|
||||
// Once downloaded, the PDF will be opened as a file:// URI in a new tab
|
||||
let previewTabPromise = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
url => {
|
||||
let uri = NetUtil.newURI(url);
|
||||
return uri.scheme == "file" && uri.spec.endsWith(".pdf");
|
||||
},
|
||||
false, // dont wait for load
|
||||
true // any tab, not just the next one
|
||||
);
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: `data:text/html,<iframe src='${PDF_URL}'>` },
|
||||
async function (newTabBrowser) {
|
||||
// wait until downloadsPanel opens before continuing with test
|
||||
info("Waiting for download panel to open");
|
||||
await downloadsPanelPromise;
|
||||
is(
|
||||
DownloadsPanel.panel.state,
|
||||
"open",
|
||||
"Check the download panel state is 'open'"
|
||||
);
|
||||
let downloadList = await Downloads.getList(Downloads.PUBLIC);
|
||||
let [download] = downloadList._downloads;
|
||||
|
||||
// Verify the downloaded PDF opened in a new tab,
|
||||
// with its download file URI
|
||||
info("Waiting for preview tab");
|
||||
let previewTab = await previewTabPromise;
|
||||
ok(previewTab, "PDF opened in a new tab");
|
||||
|
||||
is(
|
||||
DownloadsPanel.isPanelShowing,
|
||||
true,
|
||||
"DownloadsPanel should be open."
|
||||
);
|
||||
is(
|
||||
downloadList._downloads.length,
|
||||
1,
|
||||
"File should be successfully downloaded."
|
||||
);
|
||||
|
||||
await BrowserTestUtils.removeTab(previewTab);
|
||||
|
||||
info("cleaning up downloads");
|
||||
try {
|
||||
if (Services.appinfo.OS === "WINNT") {
|
||||
// We need to make the file writable to delete it on Windows.
|
||||
await IOUtils.setPermissions(download.target.path, 0o600);
|
||||
}
|
||||
await IOUtils.remove(download.target.path);
|
||||
} catch (error) {
|
||||
info(
|
||||
"The file " + download.target.path + " is not removed, " + error
|
||||
);
|
||||
}
|
||||
await downloadList.remove(download);
|
||||
await download.finalize();
|
||||
|
||||
if (DownloadsPanel.panel.state !== "closed") {
|
||||
let hiddenPromise = BrowserTestUtils.waitForEvent(
|
||||
DownloadsPanel.panel,
|
||||
"popuphidden"
|
||||
);
|
||||
DownloadsPanel.hidePanel();
|
||||
await hiddenPromise;
|
||||
}
|
||||
is(
|
||||
DownloadsPanel.panel.state,
|
||||
"closed",
|
||||
"Check that the download panel is closed"
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
|
|
@ -129,13 +129,10 @@ add_task(async function test_pdf_saveas_forms() {
|
|||
* content disposition filename defaults to using the provided filename.
|
||||
*/
|
||||
add_task(async function test_pdf_saveas_customname() {
|
||||
// Ensure improvements_to_download_panel is enabled so that we render the
|
||||
// attachment directly with the original request in a new tab.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.helperApps.showOpenOptionForPdfJS", true],
|
||||
["browser.helperApps.showOpenOptionForViewableInternally", true],
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.open_pdf_attachments_inline", true],
|
||||
],
|
||||
|
|
|
@ -39,48 +39,41 @@ function initTestHandlers() {
|
|||
async function runTest() {
|
||||
initTestHandlers();
|
||||
|
||||
for (let downloadPrefValue of [false, true]) {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", downloadPrefValue],
|
||||
],
|
||||
});
|
||||
for (let page of Pages) {
|
||||
await BrowserTestUtils.withNewTab(page, async function (aBrowser) {
|
||||
await SpecialPowers.spawn(aBrowser, [], async () => {
|
||||
let h = content.document.createElement("h1");
|
||||
ok(h);
|
||||
h.innerHTML = "My heading";
|
||||
h.id = "my-heading";
|
||||
content.document.body.append(h);
|
||||
is(content.document.getElementById("my-heading"), h, "h exists");
|
||||
for (let page of Pages) {
|
||||
await BrowserTestUtils.withNewTab(page, async function (aBrowser) {
|
||||
await SpecialPowers.spawn(aBrowser, [], async () => {
|
||||
let h = content.document.createElement("h1");
|
||||
ok(h);
|
||||
h.innerHTML = "My heading";
|
||||
h.id = "my-heading";
|
||||
content.document.body.append(h);
|
||||
is(content.document.getElementById("my-heading"), h, "h exists");
|
||||
|
||||
let a = content.document.createElement("a");
|
||||
ok(a);
|
||||
a.innerHTML = "my link";
|
||||
a.id = "my-link";
|
||||
content.document.body.append(a);
|
||||
});
|
||||
|
||||
await SpecialPowers.spawn(aBrowser, [], async () => {
|
||||
let url = "test-proto://some-thing";
|
||||
|
||||
let a = content.document.getElementById("my-link");
|
||||
ok(a);
|
||||
a.href = url;
|
||||
a.click();
|
||||
});
|
||||
|
||||
await SpecialPowers.spawn(aBrowser, [], async () => {
|
||||
ok(
|
||||
content.document.getElementById("my-heading"),
|
||||
"Page contents not erased"
|
||||
);
|
||||
});
|
||||
let a = content.document.createElement("a");
|
||||
ok(a);
|
||||
a.innerHTML = "my link";
|
||||
a.id = "my-link";
|
||||
content.document.body.append(a);
|
||||
});
|
||||
}
|
||||
await SpecialPowers.popPrefEnv();
|
||||
|
||||
await SpecialPowers.spawn(aBrowser, [], async () => {
|
||||
let url = "test-proto://some-thing";
|
||||
|
||||
let a = content.document.getElementById("my-link");
|
||||
ok(a);
|
||||
a.href = url;
|
||||
a.click();
|
||||
});
|
||||
|
||||
await SpecialPowers.spawn(aBrowser, [], async () => {
|
||||
ok(
|
||||
content.document.getElementById("my-heading"),
|
||||
"Page contents not erased"
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
await SpecialPowers.popPrefEnv();
|
||||
}
|
||||
|
||||
add_task(runTest);
|
||||
|
|
|
@ -366,11 +366,12 @@ HandlerService.prototype = {
|
|||
"image/svg+xml",
|
||||
]),
|
||||
_migrateDownloadsImprovementsIfNeeded() {
|
||||
// Migrate if the preference is enabled AND if the migration has never been run before.
|
||||
// Migrate if the migration has never been run before.
|
||||
// Otherwise, we risk overwriting preferences for existing profiles!
|
||||
if (
|
||||
Services.prefs.getBoolPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
"browser.download.improvements_to_download_panel",
|
||||
true
|
||||
) &&
|
||||
!Services.policies?.getActivePolicies()?.Handlers &&
|
||||
!this._store.data.isDownloadsImprovementsAlreadyMigrated &&
|
||||
|
@ -402,11 +403,12 @@ HandlerService.prototype = {
|
|||
},
|
||||
|
||||
_migrateSVGXMLIfNeeded() {
|
||||
// Migrate if the preference is enabled AND if the migration has never been run before.
|
||||
// Migrate if the migration has never been run before.
|
||||
// We need to make sure we only run this once.
|
||||
if (
|
||||
Services.prefs.getBoolPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
"browser.download.improvements_to_download_panel",
|
||||
true
|
||||
) &&
|
||||
!Services.policies?.getActivePolicies()?.Handlers &&
|
||||
!this._store.data.isSVGXMLAlreadyMigrated
|
||||
|
@ -493,7 +495,8 @@ HandlerService.prototype = {
|
|||
(handlerInfo.preferredAction == alwaysAsk &&
|
||||
this._isMIMEInfo(handlerInfo) &&
|
||||
Services.prefs.getBoolPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
"browser.download.improvements_to_download_panel",
|
||||
true
|
||||
))
|
||||
) {
|
||||
storedHandlerInfo.action = handlerInfo.preferredAction;
|
||||
|
|
|
@ -511,10 +511,7 @@ nsresult nsOSHelperAppService::GetMIMEInfoFromOS(const nsACString& aMIMEType,
|
|||
}
|
||||
|
||||
mimeInfoMac->SetDefaultApplication(app);
|
||||
|
||||
mozilla::StaticPrefs::browser_download_improvements_to_download_panel()
|
||||
? mimeInfoMac->SetPreferredAction(nsIMIMEInfo::saveToDisk)
|
||||
: mimeInfoMac->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
|
||||
mimeInfoMac->SetPreferredAction(nsIMIMEInfo::saveToDisk);
|
||||
|
||||
} else {
|
||||
mimeInfoMac->SetPreferredAction(nsIMIMEInfo::saveToDisk);
|
||||
|
|
|
@ -1733,10 +1733,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
|
|||
int32_t action = nsIMIMEInfo::saveToDisk;
|
||||
mMimeInfo->GetPreferredAction(&action);
|
||||
|
||||
bool forcePrompt =
|
||||
mReason == nsIHelperAppLauncherDialog::REASON_TYPESNIFFED ||
|
||||
(mReason == nsIHelperAppLauncherDialog::REASON_SERVERREQUEST &&
|
||||
!StaticPrefs::browser_download_improvements_to_download_panel());
|
||||
bool forcePrompt = mReason == nsIHelperAppLauncherDialog::REASON_TYPESNIFFED;
|
||||
|
||||
// OK, now check why we're here
|
||||
if (!alwaysAsk && forcePrompt) {
|
||||
|
@ -1746,8 +1743,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest* request) {
|
|||
}
|
||||
|
||||
bool shouldAutomaticallyHandleInternally =
|
||||
action == nsIMIMEInfo::handleInternally &&
|
||||
StaticPrefs::browser_download_improvements_to_download_panel();
|
||||
action == nsIMIMEInfo::handleInternally;
|
||||
|
||||
// If we're not asking, check we actually know what to do:
|
||||
if (!alwaysAsk) {
|
||||
|
@ -2458,8 +2454,7 @@ void nsExternalAppHandler::RequestSaveDestination(
|
|||
NS_IMETHODIMP nsExternalAppHandler::PromptForSaveDestination() {
|
||||
if (mCanceled) return NS_OK;
|
||||
|
||||
if (!StaticPrefs::browser_download_improvements_to_download_panel() ||
|
||||
mForceSave) {
|
||||
if (mForceSave) {
|
||||
mMimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk);
|
||||
}
|
||||
|
||||
|
@ -2487,9 +2482,7 @@ nsresult nsExternalAppHandler::ContinueSave(nsIFile* aNewFileLocation) {
|
|||
|
||||
int32_t action = nsIMIMEInfo::saveToDisk;
|
||||
mMimeInfo->GetPreferredAction(&action);
|
||||
mHandleInternally =
|
||||
action == nsIMIMEInfo::handleInternally &&
|
||||
StaticPrefs::browser_download_improvements_to_download_panel();
|
||||
mHandleInternally = action == nsIMIMEInfo::handleInternally;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIFile> fileToUse = aNewFileLocation;
|
||||
|
@ -2587,8 +2580,7 @@ NS_IMETHODIMP nsExternalAppHandler::SetDownloadToLaunch(
|
|||
// directory as originally downloaded so the download can be renamed in place
|
||||
// later.
|
||||
nsCOMPtr<nsIFile> fileToUse;
|
||||
if (aNewFileLocation &&
|
||||
StaticPrefs::browser_download_improvements_to_download_panel()) {
|
||||
if (aNewFileLocation) {
|
||||
fileToUse = aNewFileLocation;
|
||||
} else {
|
||||
(void)GetDownloadDirectory(getter_AddRefs(fileToUse));
|
||||
|
|
|
@ -41,8 +41,6 @@ add_task(async function test_check_download_dir() {
|
|||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
// Enable downloads improvements
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
// Avoid opening dialogs
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
// Switch back to default OS downloads dir (changed in head.js):
|
||||
|
|
|
@ -24,11 +24,7 @@ server.registerFile(`/${encodeURIComponent(TEST_FILE)}`, file);
|
|||
*/
|
||||
add_task(async function test_idn_blocklisted_char_not_escaped() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
// Enable downloads improvements
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", false]],
|
||||
});
|
||||
|
||||
info("Testing with " + TEST_URL);
|
||||
|
|
|
@ -695,7 +695,6 @@ add_task(async function test_check_open_with_internal_handler_noask() {
|
|||
// Build the matrix of tests to perform.
|
||||
let matrix = {
|
||||
alwaysOpenPDFInline: [false, true],
|
||||
improvements: [false, true],
|
||||
file: [
|
||||
"file_pdf_application_pdf.pdf",
|
||||
"file_pdf_binary_octet_stream.pdf",
|
||||
|
@ -712,7 +711,7 @@ add_task(async function test_check_open_with_internal_handler_noask() {
|
|||
|
||||
for (let test of tests) {
|
||||
info(`test case: ${JSON.stringify(test)}`);
|
||||
let { alwaysOpenPDFInline, improvements, file, where } = test;
|
||||
let { alwaysOpenPDFInline, file, where } = test;
|
||||
|
||||
// These are the cases that can be opened inline. binary/octet-stream
|
||||
// isn't handled by pdfjs.
|
||||
|
@ -720,18 +719,10 @@ add_task(async function test_check_open_with_internal_handler_noask() {
|
|||
file == "file_pdf_application_pdf.pdf" ||
|
||||
(file == "file_pdf_application_octet_stream.pdf" && where != "frame");
|
||||
|
||||
// We expect a dialog to appear when the improvements is set to false,
|
||||
// and either the open pdf attachments inline setting is false or
|
||||
// we cannot handle the pdf inline.
|
||||
let expectDialog =
|
||||
!improvements && (!alwaysOpenPDFInline || !canHandleInline);
|
||||
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.helperApps.showOpenOptionForPdfJS", true],
|
||||
["browser.helperApps.showOpenOptionForViewableInternally", true],
|
||||
["browser.download.improvements_to_download_panel", improvements],
|
||||
["browser.download.always_ask_before_handling_new_types", expectDialog],
|
||||
["browser.download.open_pdf_attachments_inline", alwaysOpenPDFInline],
|
||||
],
|
||||
});
|
||||
|
@ -764,35 +755,19 @@ add_task(async function test_check_open_with_internal_handler_noask() {
|
|||
// If this is true, the pdf is opened directly without downloading it.
|
||||
// Otherwise, it must first be downloaded and optionally displayed in
|
||||
// a tab with a file url.
|
||||
let openPDFDirectly =
|
||||
!expectDialog && alwaysOpenPDFInline && canHandleInline;
|
||||
let openPDFDirectly = alwaysOpenPDFInline && canHandleInline;
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{ gBrowser, url: TEST_PATH + "blank.html" },
|
||||
async browser => {
|
||||
let readyPromise;
|
||||
if (expectDialog) {
|
||||
let dialogWindowPromise = BrowserTestUtils.domWindowOpenedAndLoaded();
|
||||
await doNavigate(browser);
|
||||
let readyPromise = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
null,
|
||||
false,
|
||||
!openPDFDirectly
|
||||
);
|
||||
|
||||
let dialogWindow = await dialogWindowPromise;
|
||||
|
||||
readyPromise = BrowserTestUtils.waitForNewTab(gBrowser);
|
||||
let dialog = dialogWindow.document.querySelector(
|
||||
"#unknownContentType"
|
||||
);
|
||||
dialog.getButton("accept").disabled = false;
|
||||
dialog.acceptDialog();
|
||||
} else {
|
||||
readyPromise = BrowserTestUtils.waitForNewTab(
|
||||
gBrowser,
|
||||
null,
|
||||
false,
|
||||
!openPDFDirectly
|
||||
);
|
||||
|
||||
await doNavigate(browser);
|
||||
}
|
||||
await doNavigate(browser);
|
||||
|
||||
await readyPromise;
|
||||
|
||||
|
|
|
@ -243,9 +243,6 @@ add_task(async function test_download_preferred_action() {
|
|||
registerCleanupFunction(async function () {
|
||||
await removeAllDownloads();
|
||||
DownloadIntegration.launchFile = oldLaunchFile;
|
||||
Services.prefs.clearUserPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
);
|
||||
Services.prefs.clearUserPref(
|
||||
"browser.download.always_ask_before_handling_new_types"
|
||||
);
|
||||
|
@ -264,10 +261,7 @@ add_task(async function test_download_preferred_action() {
|
|||
}
|
||||
});
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", false]],
|
||||
});
|
||||
let launcherPath = FileTestUtils.getTempFile("app-launcher").path;
|
||||
let localHandlerApp = localHandlerAppFactory.createInstance(
|
||||
|
|
|
@ -11,7 +11,6 @@ const TEST_PATH = getRootDirectory(gTestPath).replace(
|
|||
add_task(async function skipDialogAndDownloadFile() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.useDownloadDir", true],
|
||||
["image.webp.enabled", true],
|
||||
|
|
|
@ -14,7 +14,6 @@ const TEST_PATH = getRootDirectory(gTestPath).replace(
|
|||
add_setup(async function () {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["image.webp.enabled", true],
|
||||
],
|
||||
|
|
|
@ -58,97 +58,6 @@ add_setup(async function () {
|
|||
registerRestoreHandler("image/svg+xml", "svg");
|
||||
});
|
||||
|
||||
const kTestCasesPrefDisabled = [
|
||||
{
|
||||
description:
|
||||
"Saving to disk when internal handling is the default shouldn't change prefs.",
|
||||
preDialogState: {
|
||||
preferredAction: handleInternally,
|
||||
alwaysAskBeforeHandling: false,
|
||||
},
|
||||
dialogActions(doc) {
|
||||
let saveItem = doc.querySelector("#save");
|
||||
saveItem.click();
|
||||
ok(saveItem.selected, "The 'save' option should now be selected");
|
||||
},
|
||||
expectTab: false,
|
||||
expectLaunch: false,
|
||||
expectedPreferredAction: handleInternally,
|
||||
expectedAlwaysAskBeforeHandling: false,
|
||||
},
|
||||
{
|
||||
description:
|
||||
"Opening externally when internal handling is the default shouldn't change prefs.",
|
||||
preDialogState: {
|
||||
preferredAction: handleInternally,
|
||||
alwaysAskBeforeHandling: false,
|
||||
},
|
||||
dialogActions(doc) {
|
||||
let openItem = doc.querySelector("#open");
|
||||
openItem.click();
|
||||
ok(openItem.selected, "The 'save' option should now be selected");
|
||||
},
|
||||
expectTab: false,
|
||||
expectLaunch: true,
|
||||
expectedPreferredAction: handleInternally,
|
||||
expectedAlwaysAskBeforeHandling: false,
|
||||
},
|
||||
{
|
||||
description:
|
||||
"Saving to disk when internal handling is the default *should* change prefs if checkbox is ticked.",
|
||||
preDialogState: {
|
||||
preferredAction: handleInternally,
|
||||
alwaysAskBeforeHandling: false,
|
||||
},
|
||||
dialogActions(doc) {
|
||||
let saveItem = doc.querySelector("#save");
|
||||
saveItem.click();
|
||||
ok(saveItem.selected, "The 'save' option should now be selected");
|
||||
let checkbox = doc.querySelector("#rememberChoice");
|
||||
checkbox.checked = true;
|
||||
checkbox.doCommand();
|
||||
},
|
||||
expectTab: false,
|
||||
expectLaunch: false,
|
||||
expectedPreferredAction: saveToDisk,
|
||||
expectedAlwaysAskBeforeHandling: false,
|
||||
},
|
||||
{
|
||||
description:
|
||||
"Saving to disk when asking is the default should change persisted default.",
|
||||
preDialogState: {
|
||||
preferredAction: handleInternally,
|
||||
alwaysAskBeforeHandling: true,
|
||||
},
|
||||
dialogActions(doc) {
|
||||
let saveItem = doc.querySelector("#save");
|
||||
saveItem.click();
|
||||
ok(saveItem.selected, "The 'save' option should now be selected");
|
||||
},
|
||||
expectTab: false,
|
||||
expectLaunch: false,
|
||||
expectedPreferredAction: saveToDisk,
|
||||
expectedAlwaysAskBeforeHandling: true,
|
||||
},
|
||||
{
|
||||
description:
|
||||
"Opening externally when asking is the default should change persisted default.",
|
||||
preDialogState: {
|
||||
preferredAction: handleInternally,
|
||||
alwaysAskBeforeHandling: true,
|
||||
},
|
||||
dialogActions(doc) {
|
||||
let openItem = doc.querySelector("#open");
|
||||
openItem.click();
|
||||
ok(openItem.selected, "The 'save' option should now be selected");
|
||||
},
|
||||
expectTab: false,
|
||||
expectLaunch: true,
|
||||
expectedPreferredAction: useSystemDefault,
|
||||
expectedAlwaysAskBeforeHandling: true,
|
||||
},
|
||||
];
|
||||
|
||||
function ensureMIMEState({ preferredAction, alwaysAskBeforeHandling }) {
|
||||
const mimeInfo = gMimeSvc.getFromTypeAndExtension("image/svg+xml", "svg");
|
||||
mimeInfo.preferredAction = preferredAction;
|
||||
|
@ -156,127 +65,6 @@ function ensureMIMEState({ preferredAction, alwaysAskBeforeHandling }) {
|
|||
gHandlerSvc.store(mimeInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that if we have SVGs set to handle internally, and the user chooses to
|
||||
* do something else with it, we do not alter the saved state.
|
||||
*/
|
||||
add_task(async function test_check_saving_handler_choices() {
|
||||
let publicList = await Downloads.getList(Downloads.PUBLIC);
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", false],
|
||||
["browser.download.always_ask_before_handling_new_types", true],
|
||||
],
|
||||
});
|
||||
registerCleanupFunction(async () => {
|
||||
await publicList.removeFinished();
|
||||
});
|
||||
for (let testCase of kTestCasesPrefDisabled) {
|
||||
let file = "file_image_svgxml.svg";
|
||||
info("Testing with " + file + "; " + testCase.description);
|
||||
ensureMIMEState(testCase.preDialogState);
|
||||
|
||||
let dialogWindowPromise = BrowserTestUtils.domWindowOpenedAndLoaded();
|
||||
let loadingTab = await BrowserTestUtils.openNewForegroundTab({
|
||||
gBrowser,
|
||||
opening: TEST_PATH + file,
|
||||
waitForLoad: false,
|
||||
waitForStateStop: true,
|
||||
});
|
||||
let dialogWindow = await dialogWindowPromise;
|
||||
is(
|
||||
dialogWindow.location.href,
|
||||
"chrome://mozapps/content/downloads/unknownContentType.xhtml",
|
||||
"Should have seen the unknown content dialogWindow."
|
||||
);
|
||||
let doc = dialogWindow.document;
|
||||
let internalHandlerRadio = doc.querySelector("#handleInternally");
|
||||
|
||||
if (Services.focus.activeWindow != dialogWindow) {
|
||||
await BrowserTestUtils.waitForEvent(dialogWindow, "activate");
|
||||
}
|
||||
|
||||
await waitForAcceptButtonToGetEnabled(doc);
|
||||
|
||||
ok(!internalHandlerRadio.hidden, "The option should be visible for SVG");
|
||||
ok(
|
||||
internalHandlerRadio.selected,
|
||||
"The Firefox option should be selected by default"
|
||||
);
|
||||
|
||||
const { expectTab, expectLaunch, description } = testCase;
|
||||
// Prep to intercept things so we only see the results we want.
|
||||
let tabOpenListener = ev => {
|
||||
ok(
|
||||
expectTab,
|
||||
`A new tab should ${expectTab ? "" : "not "}be opened - ${description}`
|
||||
);
|
||||
BrowserTestUtils.removeTab(ev.target);
|
||||
};
|
||||
gBrowser.tabContainer.addEventListener("TabOpen", tabOpenListener);
|
||||
|
||||
let oldLaunchFile = DownloadIntegration.launchFile;
|
||||
let fileLaunched = PromiseUtils.defer();
|
||||
DownloadIntegration.launchFile = () => {
|
||||
ok(
|
||||
expectLaunch,
|
||||
`The file should ${
|
||||
expectLaunch ? "" : "not "
|
||||
}be launched with an external application - ${description}`
|
||||
);
|
||||
fileLaunched.resolve();
|
||||
};
|
||||
let downloadFinishedPromise = promiseDownloadFinished(publicList);
|
||||
|
||||
await testCase.dialogActions(doc);
|
||||
|
||||
let mainWindowActivatedAndFocused = Promise.all([
|
||||
BrowserTestUtils.waitForEvent(window, "activate"),
|
||||
BrowserTestUtils.waitForEvent(window, "focus", true),
|
||||
]);
|
||||
let dialog = doc.querySelector("#unknownContentType");
|
||||
dialog.acceptDialog();
|
||||
await mainWindowActivatedAndFocused;
|
||||
|
||||
let download = await downloadFinishedPromise;
|
||||
if (expectLaunch) {
|
||||
await fileLaunched.promise;
|
||||
}
|
||||
DownloadIntegration.launchFile = oldLaunchFile;
|
||||
gBrowser.tabContainer.removeEventListener("TabOpen", tabOpenListener);
|
||||
|
||||
is(
|
||||
(await publicList.getAll()).length,
|
||||
1,
|
||||
"download should appear in public list"
|
||||
);
|
||||
|
||||
// Check mime info:
|
||||
const mimeInfo = gMimeSvc.getFromTypeAndExtension("image/svg+xml", "svg");
|
||||
gHandlerSvc.fillHandlerInfo(mimeInfo, "");
|
||||
is(
|
||||
mimeInfo.preferredAction,
|
||||
testCase.expectedPreferredAction,
|
||||
"preferredAction - " + description
|
||||
);
|
||||
is(
|
||||
mimeInfo.alwaysAskBeforeHandling,
|
||||
testCase.expectedAlwaysAskBeforeHandling,
|
||||
"alwaysAskBeforeHandling - " + description
|
||||
);
|
||||
|
||||
BrowserTestUtils.removeTab(loadingTab);
|
||||
await publicList.removeFinished();
|
||||
if (download?.target.exists) {
|
||||
try {
|
||||
await IOUtils.remove(download.target.path);
|
||||
} catch (ex) {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function waitDelay(delay) {
|
||||
return new Promise((resolve, reject) => {
|
||||
/* eslint-disable mozilla/no-arbitrary-setTimeout */
|
||||
|
@ -373,12 +161,9 @@ const kTestCasesPrefEnabled = [
|
|||
];
|
||||
|
||||
add_task(
|
||||
async function test_check_saving_handler_choices_with_downloads_pref_enabled() {
|
||||
async function test_check_saving_handler_choices_with_always_ask_before_handling_new_types_pref_enabled() {
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
],
|
||||
set: [["browser.download.always_ask_before_handling_new_types", false]],
|
||||
});
|
||||
|
||||
let publicList = await Downloads.getList(Downloads.PUBLIC);
|
||||
|
|
|
@ -21,7 +21,6 @@ MockFilePicker.init(window);
|
|||
add_setup(async function () {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["browser.download.improvements_to_download_panel", true],
|
||||
["browser.download.always_ask_before_handling_new_types", false],
|
||||
["browser.download.useDownloadDir", false],
|
||||
],
|
||||
|
|
|
@ -20,71 +20,10 @@ Integration.downloads.defineESModuleGetter(
|
|||
);
|
||||
|
||||
/**
|
||||
* Tests that the migration does not run if the pref
|
||||
* browser.download.improvements_to_download_panel is disabled.
|
||||
* Tests that the migration runs and that only
|
||||
* files with preferredAction alwaysAsk are updated.
|
||||
*/
|
||||
add_task(async function test_migration_pref_disabled() {
|
||||
registerCleanupFunction(async function () {
|
||||
Services.prefs.clearUserPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
);
|
||||
});
|
||||
|
||||
Services.prefs.setBoolPref(
|
||||
"browser.download.improvements_to_download_panel",
|
||||
false
|
||||
);
|
||||
|
||||
// Plain text file
|
||||
let txtHandlerInfo = mimeSvc.getFromTypeAndExtension("text/plain", "txt");
|
||||
txtHandlerInfo.preferredAction = Ci.nsIHandlerInfo.alwaysAsk;
|
||||
txtHandlerInfo.alwaysAskBeforeHandling = true;
|
||||
// PDF file
|
||||
let pdfHandlerInfo = mimeSvc.getFromTypeAndExtension(
|
||||
"application/pdf",
|
||||
"pdf"
|
||||
);
|
||||
// When the downloads pref is disabled, HandlerService.store defaults the
|
||||
// preferredAction from alwaysAsk to useHelperApp for compatibility reasons.
|
||||
pdfHandlerInfo.preferredAction = Ci.nsIHandlerInfo.useHelperApp;
|
||||
pdfHandlerInfo.alwaysAskBeforeHandling = true;
|
||||
handlerSvc.store(txtHandlerInfo);
|
||||
handlerSvc.store(pdfHandlerInfo);
|
||||
|
||||
gHandlerService.wrappedJSObject._migrateDownloadsImprovementsIfNeeded();
|
||||
|
||||
txtHandlerInfo = mimeSvc.getFromTypeAndExtension("text/plain", "txt");
|
||||
pdfHandlerInfo = mimeSvc.getFromTypeAndExtension("application/pdf", "pdf");
|
||||
let data = gHandlerService.wrappedJSObject._store.data;
|
||||
|
||||
Assert.equal(
|
||||
data.isDownloadsImprovementsAlreadyMigrated,
|
||||
false,
|
||||
"isDownloadsImprovementsAlreadyMigrated should be set to false"
|
||||
);
|
||||
Assert.notEqual(
|
||||
pdfHandlerInfo.preferredAction,
|
||||
Ci.nsIHandlerInfo.saveToDisk,
|
||||
"application/pdf - preferredAction should not be saveToDisk"
|
||||
);
|
||||
Assert.equal(
|
||||
txtHandlerInfo.preferredAction,
|
||||
Ci.nsIHandlerInfo.useHelperApp,
|
||||
"text/plain - preferredAction should be useHelperApp"
|
||||
);
|
||||
Assert.equal(
|
||||
txtHandlerInfo.alwaysAskBeforeHandling,
|
||||
true,
|
||||
"text/plain - alwaysAskBeforeHandling should be true"
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* Tests that the migration runs if the pref
|
||||
* browser.download.improvements_to_download_panel is enabled and
|
||||
* that only files with preferredAction alwaysAsk are updated.
|
||||
*/
|
||||
add_task(async function test_migration_pref_enabled() {
|
||||
add_task(async function test_migration() {
|
||||
// Create mock implementation of shouldDownloadInternally for test case
|
||||
let oldShouldViewDownloadInternally =
|
||||
DownloadIntegration.shouldViewDownloadInternally;
|
||||
|
@ -191,21 +130,9 @@ add_task(async function test_migration_pref_enabled() {
|
|||
});
|
||||
|
||||
/**
|
||||
* Tests that the migration does not run if the pref
|
||||
* browser.download.improvements_to_download_panel is enabled but
|
||||
* the migration was already run.
|
||||
* Tests that the migration does not run if the migration was already run.
|
||||
*/
|
||||
add_task(async function test_migration_pref_enabled_already_run() {
|
||||
registerCleanupFunction(async function () {
|
||||
Services.prefs.clearUserPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
);
|
||||
});
|
||||
|
||||
Services.prefs.setBoolPref(
|
||||
"browser.download.improvements_to_download_panel",
|
||||
true
|
||||
);
|
||||
add_task(async function test_migration_already_run() {
|
||||
let data = gHandlerService.wrappedJSObject._store.data;
|
||||
data.isDownloadsImprovementsAlreadyMigrated = true;
|
||||
|
||||
|
@ -254,17 +181,7 @@ add_task(async function test_migration_pref_enabled_already_run() {
|
|||
/**
|
||||
* Test migration of SVG and XML info.
|
||||
*/
|
||||
add_task(async function test_migration_pref_enabled_xml_svg() {
|
||||
registerCleanupFunction(async function () {
|
||||
Services.prefs.clearUserPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
);
|
||||
});
|
||||
|
||||
Services.prefs.setBoolPref(
|
||||
"browser.download.improvements_to_download_panel",
|
||||
true
|
||||
);
|
||||
add_task(async function test_migration_xml_svg() {
|
||||
let data = gHandlerService.wrappedJSObject._store.data;
|
||||
// Plain text file
|
||||
let txtHandlerInfo = mimeSvc.getFromTypeAndExtension("text/plain", "txt");
|
||||
|
|
|
@ -461,15 +461,7 @@ function run_test() {
|
|||
do_get_file("mailcap").path
|
||||
);
|
||||
handlerInfo = mimeSvc.getFromTypeAndExtension("text/plain", null);
|
||||
Assert.equal(
|
||||
handlerInfo.preferredAction,
|
||||
prefSvc.getBoolPref(
|
||||
"browser.download.improvements_to_download_panel",
|
||||
false
|
||||
)
|
||||
? Ci.nsIHandlerInfo.saveToDisk
|
||||
: Ci.nsIHandlerInfo.useSystemDefault
|
||||
);
|
||||
Assert.equal(handlerInfo.preferredAction, Ci.nsIHandlerInfo.saveToDisk);
|
||||
Assert.equal(handlerInfo.defaultDescription, "sed");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,11 +243,7 @@ add_task(async function test_store_preferredAction() {
|
|||
const actions = [
|
||||
{
|
||||
preferred: Ci.nsIHandlerInfo.alwaysAsk,
|
||||
expected: Services.prefs.getBoolPref(
|
||||
"browser.download.improvements_to_download_panel"
|
||||
)
|
||||
? Ci.nsIHandlerInfo.alwaysAsk
|
||||
: Ci.nsIHandlerInfo.useHelperApp,
|
||||
expected: Ci.nsIHandlerInfo.alwaysAsk,
|
||||
},
|
||||
{
|
||||
preferred: Ci.nsIHandlerInfo.handleInternally,
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* 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/. */
|
||||
|
||||
#include "mozilla/StaticPrefs_browser.h"
|
||||
#include "nsGNOMERegistry.h"
|
||||
#include "nsString.h"
|
||||
#include "nsMIMEInfoUnix.h"
|
||||
|
@ -95,9 +94,7 @@ already_AddRefed<nsMIMEInfoBase> nsGNOMERegistry::GetFromType(
|
|||
|
||||
mimeInfo->SetDefaultDescription(name);
|
||||
|
||||
mozilla::StaticPrefs::browser_download_improvements_to_download_panel()
|
||||
? mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk)
|
||||
: mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
|
||||
mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk);
|
||||
mimeInfo->SetDescription(NS_ConvertUTF8toUTF16(description));
|
||||
|
||||
return mimeInfo.forget();
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "mozilla/EnumeratedRange.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/StaticPrefs_browser.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include <mutex>
|
||||
|
||||
|
@ -1289,9 +1288,7 @@ already_AddRefed<nsMIMEInfoBase> nsOSHelperAppService::GetFromExtension(
|
|||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mimeInfo->SetDefaultApplication(handlerFile);
|
||||
mozilla::StaticPrefs::browser_download_improvements_to_download_panel()
|
||||
? mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk)
|
||||
: mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
|
||||
mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk);
|
||||
mimeInfo->SetDefaultDescription(handler);
|
||||
}
|
||||
}
|
||||
|
@ -1407,9 +1404,7 @@ already_AddRefed<nsMIMEInfoBase> nsOSHelperAppService::GetFromType(
|
|||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mimeInfo->SetDefaultApplication(handlerFile);
|
||||
StaticPrefs::browser_download_improvements_to_download_panel()
|
||||
? mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk)
|
||||
: mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
|
||||
mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk);
|
||||
mimeInfo->SetDefaultDescription(handler);
|
||||
} else {
|
||||
mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk);
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "nsLocalFile.h"
|
||||
#include "nsIWindowsRegKey.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "mozilla/StaticPrefs_browser.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
#include "mozilla/WindowsVersion.h"
|
||||
|
||||
|
@ -371,9 +370,7 @@ already_AddRefed<nsMIMEInfoWin> nsOSHelperAppService::GetByExtension(
|
|||
NS_ConvertUTF16toUTF8(Substring(aFileExt, dotlessIndex));
|
||||
ToLowerCase(lowerFileExt);
|
||||
mimeInfo->AppendExtension(lowerFileExt);
|
||||
mozilla::StaticPrefs::browser_download_improvements_to_download_panel()
|
||||
? mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk)
|
||||
: mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
|
||||
mimeInfo->SetPreferredAction(nsIMIMEInfo::saveToDisk);
|
||||
|
||||
if (NS_FAILED(InternalSetDefaultsOnMIME(mimeInfo))) {
|
||||
return nullptr;
|
||||
|
|
Загрузка…
Ссылка в новой задаче