Backed out 3 changesets (bug 1753004) for causing xpc failures in test_DownloadsViewableInternally.js CLOSED TREE

Backed out changeset 2846598b65fd (bug 1753004)
Backed out changeset 05000c4c936d (bug 1753004)
Backed out changeset 372676134ff5 (bug 1753004)
This commit is contained in:
Noemi Erli 2022-02-14 21:48:12 +02:00
Родитель 4bc0d28bac
Коммит b8f5c4835b
12 изменённых файлов: 32 добавлений и 124 удалений

Просмотреть файл

@ -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",

Просмотреть файл

@ -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);
});

Просмотреть файл

@ -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, {

Просмотреть файл

@ -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");
}
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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");

Просмотреть файл

@ -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,
});

Просмотреть файл

@ -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,
});

Просмотреть файл

@ -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;

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 42 B

Просмотреть файл

@ -1,3 +0,0 @@
Content-Disposition: attachment; filename=file_green.webp
Content-Type: image/webp