diff --git a/browser/components/downloads/DownloadsViewableInternally.jsm b/browser/components/downloads/DownloadsViewableInternally.jsm index 531a2e77af44..c675c99858f0 100644 --- a/browser/components/downloads/DownloadsViewableInternally.jsm +++ b/browser/components/downloads/DownloadsViewableInternally.jsm @@ -115,7 +115,6 @@ let DownloadsViewableInternally = { extension: "xml", mimeTypes: ["text/xml", "application/xml"], available: true, - managedElsewhere: true, }, { extension: "svg", @@ -133,7 +132,6 @@ let DownloadsViewableInternally = { ); }, // available getter is set by initAvailable() - managedElsewhere: true, }, { extension: "webp", diff --git a/dom/security/test/mixedcontentblocker/browser_test_mixed_content_download.js b/dom/security/test/mixedcontentblocker/browser_test_mixed_content_download.js index 1c3f1c50c874..82bbf1375cdc 100644 --- a/dom/security/test/mixedcontentblocker/browser_test_mixed_content_download.js +++ b/dom/security/test/mixedcontentblocker/browser_test_mixed_content_download.js @@ -299,11 +299,6 @@ add_task(async function test_unblock_download_visible() { // Test Download an insecure svg and choose "Open with Firefox" add_task(async function download_open_insecure_SVG() { - const mimeInfo = MIMEService.getFromTypeAndExtension("image/svg+xml", "svg"); - mimeInfo.alwaysAskBeforeHandling = false; - mimeInfo.preferredAction = mimeInfo.handleInternally; - HandlerService.store(mimeInfo); - for (let prefVal of [true, false]) { await SpecialPowers.pushPrefEnv({ set: [["browser.download.improvements_to_download_panel", prefVal]], @@ -336,5 +331,4 @@ add_task(async function download_open_insecure_SVG() { "A Blocked SVG can be opened internally" ); } - HandlerService.remove(mimeInfo); }); diff --git a/toolkit/components/downloads/DownloadIntegration.jsm b/toolkit/components/downloads/DownloadIntegration.jsm index 2524afacc285..aaf6f6aec786 100644 --- a/toolkit/components/downloads/DownloadIntegration.jsm +++ b/toolkit/components/downloads/DownloadIntegration.jsm @@ -809,11 +809,7 @@ var DownloadIntegration = { (mimeInfo && this.shouldViewDownloadInternally(mimeInfo.type, fileExtension) && !mimeInfo.alwaysAskBeforeHandling && - (mimeInfo.preferredAction === Ci.nsIHandlerInfo.handleInternally || - (["image/svg+xml", "text/xml", "application/xml"].includes( - mimeInfo.type - ) && - mimeInfo.preferredAction === Ci.nsIHandlerInfo.saveToDisk)) && + mimeInfo.preferredAction === Ci.nsIHandlerInfo.handleInternally && !aDownload.launchWhenSucceeded) ) { DownloadUIHelper.loadFileIn(file, { diff --git a/toolkit/mozapps/downloads/HelperAppDlg.jsm b/toolkit/mozapps/downloads/HelperAppDlg.jsm index 64de8d098907..6c3f2690dde7 100644 --- a/toolkit/mozapps/downloads/HelperAppDlg.jsm +++ b/toolkit/mozapps/downloads/HelperAppDlg.jsm @@ -867,9 +867,7 @@ nsUnknownContentTypeDialog.prototype = { // If that's the default, then switch to "save to disk." if (isSelected) { openHandler.selectedIndex = 1; - if (this.dialogElement("open").selected) { - modeGroup.selectedItem = this.dialogElement("save"); - } + modeGroup.selectedItem = this.dialogElement("save"); } } diff --git a/uriloader/exthandler/HandlerService.js b/uriloader/exthandler/HandlerService.js index 75eacd87dcf8..54ce5eecc4ce 100644 --- a/uriloader/exthandler/HandlerService.js +++ b/uriloader/exthandler/HandlerService.js @@ -13,14 +13,6 @@ const { XPCOMUtils } = ChromeUtils.import( ); const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); -const { - saveToDisk, - alwaysAsk, - useHelperApp, - handleInternally, - useSystemDefault, -} = Ci.nsIHandlerInfo; - const TOPIC_PDFJS_HANDLER_CHANGED = "pdfjs:handlerChanged"; ChromeUtils.defineModuleGetter( @@ -107,7 +99,6 @@ HandlerService.prototype = { // Since we need DownloadsViewInternally to verify mimetypes, we run this after // DownloadsViewInternally is registered via the 'handlersvc-store-initialized' notification. this._migrateDownloadsImprovementsIfNeeded(); - this._migrateSVGXMLIfNeeded(); } }, @@ -378,11 +369,6 @@ HandlerService.prototype = { * * See Bug 1736924 for more information. */ - _noInternalHandlingDefault: new Set([ - "text/xml", - "application/xml", - "image/svg+xml", - ]), _migrateDownloadsImprovementsIfNeeded() { // Migrate if the preference is enabled AND if the migration has never been run before. // Otherwise, we risk overwriting preferences for existing profiles! @@ -394,16 +380,16 @@ HandlerService.prototype = { !this._store.data.isDownloadsImprovementsAlreadyMigrated ) { for (let [type, mimeInfo] of Object.entries(this._store.data.mimeTypes)) { - let isViewableInternally = - DownloadIntegration.shouldViewDownloadInternally(type) && - !this._noInternalHandlingDefault.has(type); + let isViewableInternally = DownloadIntegration.shouldViewDownloadInternally( + type + ); let isAskOnly = mimeInfo && mimeInfo.ask; if (isAskOnly) { if (isViewableInternally) { - mimeInfo.action = handleInternally; + mimeInfo.action = Ci.nsIHandlerInfo.handleInternally; } else { - mimeInfo.action = saveToDisk; + mimeInfo.action = Ci.nsIHandlerInfo.saveToDisk; } // Sets alwaysAskBeforeHandling to false. Needed to ensure that: @@ -418,30 +404,6 @@ HandlerService.prototype = { } }, - _migrateSVGXMLIfNeeded() { - // Migrate if the preference is enabled AND 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" - ) && - !Services.policies.getActivePolicies()?.Handlers && - !this._store.data.isSVGXMLAlreadyMigrated - ) { - for (let type of this._noInternalHandlingDefault) { - if (Object.hasOwn(this._store.data.mimeTypes, type)) { - let mimeInfo = this._store.data.mimeTypes[type]; - if (!mimeInfo.ask && mimeInfo.action == handleInternally) { - mimeInfo.action = saveToDisk; - } - } - } - - this._store.data.isSVGXMLAlreadyMigrated = true; - this._store.saveSoon(); - } - }, - // nsIHandlerService enumerate() { let handlers = Cc["@mozilla.org/array;1"].createInstance( @@ -503,12 +465,12 @@ HandlerService.prototype = { // Only a limited number of preferredAction values is allowed. if ( - handlerInfo.preferredAction == saveToDisk || - handlerInfo.preferredAction == useSystemDefault || - handlerInfo.preferredAction == handleInternally || + handlerInfo.preferredAction == Ci.nsIHandlerInfo.saveToDisk || + handlerInfo.preferredAction == Ci.nsIHandlerInfo.useSystemDefault || + handlerInfo.preferredAction == Ci.nsIHandlerInfo.handleInternally || // For files (ie mimetype rather than protocol handling info), ensure // we can store the "always ask" state, too: - (handlerInfo.preferredAction == alwaysAsk && + (handlerInfo.preferredAction == Ci.nsIHandlerInfo.alwaysAsk && this._isMIMEInfo(handlerInfo) && Services.prefs.getBoolPref( "browser.download.improvements_to_download_panel" @@ -516,7 +478,7 @@ HandlerService.prototype = { ) { storedHandlerInfo.action = handlerInfo.preferredAction; } else { - storedHandlerInfo.action = useHelperApp; + storedHandlerInfo.action = Ci.nsIHandlerInfo.useHelperApp; } if (handlerInfo.alwaysAskBeforeHandling) { @@ -608,13 +570,13 @@ HandlerService.prototype = { handlerInfo.hasDefaultHandler ); if ( - handlerInfo.preferredAction == alwaysAsk && + handlerInfo.preferredAction == Ci.nsIHandlerInfo.alwaysAsk && handlerInfo.alwaysAskBeforeHandling ) { // `store` will default to `useHelperApp` because `alwaysAsk` is // not one of the 3 recognized options; for compatibility, do // the same here. - handlerInfo.preferredAction = useHelperApp; + handlerInfo.preferredAction = Ci.nsIHandlerInfo.useHelperApp; } } // If it *is* a stub, don't override alwaysAskBeforeHandling or the diff --git a/uriloader/exthandler/tests/mochitest/browser.ini b/uriloader/exthandler/tests/mochitest/browser.ini index fdb194fcda45..b1a13353302b 100644 --- a/uriloader/exthandler/tests/mochitest/browser.ini +++ b/uriloader/exthandler/tests/mochitest/browser.ini @@ -36,16 +36,11 @@ support-files = file_xml_attachment_binary_octet_stream.xml^headers^ file_xml_attachment_test.xml file_xml_attachment_test.xml^headers^ - file_green.webp - file_green.webp^headers^ [browser_download_preferred_action.js] support-files = mime_type_download.sjs [browser_download_privatebrowsing.js] [browser_download_skips_dialog.js] -support-files = - file_green.webp - file_green.webp^headers^ [browser_download_spam_permissions.js] support-files = test_spammy_page.html @@ -61,11 +56,11 @@ support-files = file_as.exe^headers^ [browser_filehandling_loop.js] [browser_launched_app_save_directory.js] + # This test checks the save destination of the + # open with app download on Windows, Linux and OS X. +skip-if = (os == 'android') support-files = file_pdf_application_pdf.pdf - file_pdf_application_pdf.pdf^headers^ - file_green.webp - file_green.webp^headers^ [browser_local_files_no_save_without_asking.js] support-files = file_pdf_binary_octet_stream.pdf @@ -73,13 +68,6 @@ support-files = support-files = file_pdf_binary_octet_stream.pdf [browser_shows_where_to_save_dialog.js] -support-files = - file_green.webp - file_green.webp^headers^ - file_pdf_application_pdf.pdf - file_pdf_application_pdf.pdf^headers^ - file_txt_attachment_test.txt - file_txt_attachment_test.txt^headers^ [browser_open_internal_choice_persistence.js] skip-if = apple_silicon # bug 1752482 diff --git a/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js b/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js index 03b7a97c1d4d..4bf9114bbe25 100644 --- a/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js +++ b/uriloader/exthandler/tests/mochitest/browser_download_open_with_internal_handler.js @@ -121,7 +121,6 @@ add_task(async function setup() { registerRestoreHandler("application/pdf", "pdf"); registerRestoreHandler("binary/octet-stream", "pdf"); registerRestoreHandler("application/unknown", "pdf"); - registerRestoreHandler("image/webp", "webp"); }); /** @@ -573,21 +572,18 @@ add_task(async function test_check_open_with_external_then_internal() { */ add_task( async function test_internal_handler_hidden_with_viewable_internally_type() { - await SpecialPowers.pushPrefEnv({ - set: [["image.webp.enabled", true]], - }); Services.telemetry.clearEvents(); const mimeInfosToRestore = alwaysAskForHandlingTypes({ + "text/xml": "xml", "binary/octet-stream": "xml", - "image/webp": "webp", }); for (let [file, checkDefault] of [ // The default for binary/octet-stream is changed by the PDF tests above, // this may change given bug 1659008, so I'm just ignoring the default for now. ["file_xml_attachment_binary_octet_stream.xml", false], - ["file_green.webp", true], + ["file_xml_attachment_test.xml", true], ]) { let dialogWindowPromise = BrowserTestUtils.domWindowOpenedAndLoaded(); let loadingTab = await BrowserTestUtils.openNewForegroundTab({ @@ -612,21 +608,13 @@ add_task( checkTelemetry( "open " + file + " for viewable internal type", "ask", - file.endsWith(".webp") ? "other" : "octetstream", + file == "file_xml_attachment_test.xml" ? "other" : "octetstream", "attachment" ); - let fileDesc = file.substring(file.lastIndexOf(".") + 1); - - ok( - !internalHandlerRadio.hidden, - `The option should be visible for ${fileDesc}` - ); + ok(!internalHandlerRadio.hidden, "The option should be visible for XML"); if (checkDefault) { - ok( - internalHandlerRadio.selected, - `The option should be selected for ${fileDesc}` - ); + ok(internalHandlerRadio.selected, "The option should be selected"); } let dialog = doc.querySelector("#unknownContentType"); diff --git a/uriloader/exthandler/tests/mochitest/browser_download_skips_dialog.js b/uriloader/exthandler/tests/mochitest/browser_download_skips_dialog.js index cf119b9eba35..a4bdc447ca9d 100644 --- a/uriloader/exthandler/tests/mochitest/browser_download_skips_dialog.js +++ b/uriloader/exthandler/tests/mochitest/browser_download_skips_dialog.js @@ -13,7 +13,6 @@ add_task(async function skipDialogAndDownloadFile() { set: [ ["browser.download.improvements_to_download_panel", true], ["browser.download.useDownloadDir", true], - ["image.webp.enabled", true], ], }); @@ -27,7 +26,7 @@ add_task(async function skipDialogAndDownloadFile() { let loadingTab = await BrowserTestUtils.openNewForegroundTab({ gBrowser, - opening: TEST_PATH + "file_green.webp", + opening: TEST_PATH + "file_image_svgxml.svg", waitForLoad: false, waitForStateStop: true, }); diff --git a/uriloader/exthandler/tests/mochitest/browser_launched_app_save_directory.js b/uriloader/exthandler/tests/mochitest/browser_launched_app_save_directory.js index daff8d4466a3..362d2a945ff9 100644 --- a/uriloader/exthandler/tests/mochitest/browser_launched_app_save_directory.js +++ b/uriloader/exthandler/tests/mochitest/browser_launched_app_save_directory.js @@ -13,10 +13,7 @@ const TEST_PATH = getRootDirectory(gTestPath).replace( add_task(async function setup() { await SpecialPowers.pushPrefEnv({ - set: [ - ["browser.download.improvements_to_download_panel", true], - ["image.webp.enabled", true], - ], + set: [["browser.download.improvements_to_download_panel", true]], }); const allowDirectoriesVal = DownloadIntegration.allowDirectories; DownloadIntegration.allowDirectories = true; @@ -38,7 +35,7 @@ async function aDownloadLaunchedWithAppIsSavedInFolder(downloadDir) { let loadingTab = await BrowserTestUtils.openNewForegroundTab({ gBrowser, - opening: TEST_PATH + "file_green.webp", + opening: TEST_PATH + "file_image_svgxml.svg", waitForLoad: false, waitForStateStop: true, }); diff --git a/uriloader/exthandler/tests/mochitest/browser_shows_where_to_save_dialog.js b/uriloader/exthandler/tests/mochitest/browser_shows_where_to_save_dialog.js index 04ee0e8c7294..b2b70c1d0b0f 100644 --- a/uriloader/exthandler/tests/mochitest/browser_shows_where_to_save_dialog.js +++ b/uriloader/exthandler/tests/mochitest/browser_shows_where_to_save_dialog.js @@ -46,10 +46,7 @@ add_task(async function setup() { // the filetype is set to save to disk. add_task(async function aDownloadSavedToDiskPromptsForFolder() { let publicList = await Downloads.getList(Downloads.PUBLIC); - ensureMIMEState( - { preferredAction: saveToDisk }, - { type: "text/plain", ext: "txt" } - ); + ensureMIMEState({ preferredAction: saveToDisk }); registerCleanupFunction(async () => { await publicList.removeFinished(); }); @@ -79,10 +76,7 @@ add_task(async function aDownloadSavedToDiskPromptsForFolder() { add_task(async function testFilesHandledInternally() { let dir = await setupFilePickerDirectory(); - ensureMIMEState( - { preferredAction: handleInternally }, - { type: "image/webp", ext: "webp" } - ); + ensureMIMEState({ preferredAction: handleInternally }); let filePickerShown = false; MockFilePicker.showCallback = function(fp) { @@ -94,14 +88,14 @@ add_task(async function testFilesHandledInternally() { gBrowser, url => { info("Got load for " + url); - return url.endsWith("file_green.webp") && url.startsWith("file:"); + return url.endsWith("file_image_svgxml.svg") && url.startsWith("file:"); }, true, true ); let loadingTab = await BrowserTestUtils.openNewForegroundTab({ gBrowser, - opening: TEST_PATH + "file_green.webp", + opening: TEST_PATH + "file_image_svgxml.svg", waitForLoad: false, waitForStateStop: true, }); @@ -109,7 +103,7 @@ add_task(async function testFilesHandledInternally() { let openedTab = await thirdTabPromise; ok(!filePickerShown, "file picker should not have shown up."); - assertCorrectFile(dir, "file_green.webp"); + assertCorrectFile(dir, "file_image_svgxml.svg"); // Cleanup BrowserTestUtils.removeTab(loadingTab); @@ -295,11 +289,8 @@ function createSaveDir() { return saveDir; } -function ensureMIMEState( - { preferredAction, preferredHandlerApp = null }, - { type = "application/pdf", ext = "pdf" } = {} -) { - const mimeInfo = gMimeSvc.getFromTypeAndExtension(type, ext); +function ensureMIMEState({ preferredAction, preferredHandlerApp = null }) { + const mimeInfo = gMimeSvc.getFromTypeAndExtension("application/pdf", "pdf"); mimeInfo.preferredAction = preferredAction; mimeInfo.preferredApplicationHandler = preferredHandlerApp; mimeInfo.alwaysAskBeforeHandling = false; diff --git a/uriloader/exthandler/tests/mochitest/file_green.webp b/uriloader/exthandler/tests/mochitest/file_green.webp deleted file mode 100644 index 04b7f003b463..000000000000 Binary files a/uriloader/exthandler/tests/mochitest/file_green.webp and /dev/null differ diff --git a/uriloader/exthandler/tests/mochitest/file_green.webp^headers^ b/uriloader/exthandler/tests/mochitest/file_green.webp^headers^ deleted file mode 100644 index 3f6afd6625a7..000000000000 --- a/uriloader/exthandler/tests/mochitest/file_green.webp^headers^ +++ /dev/null @@ -1,3 +0,0 @@ -Content-Disposition: attachment; filename=file_green.webp -Content-Type: image/webp -