Differential Revision: https://phabricator.services.mozilla.com/D138321
This commit is contained in:
Gijs Kruitbosch 2022-02-11 21:13:37 +00:00
Родитель 0bb0b4ea48
Коммит 912854cac5
7 изменённых файлов: 58 добавлений и 20 удалений

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

@ -34,13 +34,16 @@ support-files =
file_txt_attachment_test.txt^headers^
file_xml_attachment_binary_octet_stream.xml
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
@ -56,11 +59,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
@ -68,6 +71,13 @@ 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,6 +121,7 @@ add_task(async function setup() {
registerRestoreHandler("application/pdf", "pdf");
registerRestoreHandler("binary/octet-stream", "pdf");
registerRestoreHandler("application/unknown", "pdf");
registerRestoreHandler("image/webp", "webp");
});
/**
@ -572,18 +573,21 @@ 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_xml_attachment_test.xml", true],
["file_green.webp", true],
]) {
let dialogWindowPromise = BrowserTestUtils.domWindowOpenedAndLoaded();
let loadingTab = await BrowserTestUtils.openNewForegroundTab({
@ -608,13 +612,21 @@ add_task(
checkTelemetry(
"open " + file + " for viewable internal type",
"ask",
file == "file_xml_attachment_test.xml" ? "other" : "octetstream",
file.endsWith(".webp") ? "other" : "octetstream",
"attachment"
);
ok(!internalHandlerRadio.hidden, "The option should be visible for XML");
let fileDesc = file.substring(file.lastIndexOf(".") + 1);
ok(
!internalHandlerRadio.hidden,
`The option should be visible for ${fileDesc}`
);
if (checkDefault) {
ok(internalHandlerRadio.selected, "The option should be selected");
ok(
internalHandlerRadio.selected,
`The option should be selected for ${fileDesc}`
);
}
let dialog = doc.querySelector("#unknownContentType");

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

@ -13,6 +13,7 @@ add_task(async function skipDialogAndDownloadFile() {
set: [
["browser.download.improvements_to_download_panel", true],
["browser.download.useDownloadDir", true],
["image.webp.enabled", true],
],
});
@ -26,7 +27,7 @@ add_task(async function skipDialogAndDownloadFile() {
let loadingTab = await BrowserTestUtils.openNewForegroundTab({
gBrowser,
opening: TEST_PATH + "file_image_svgxml.svg",
opening: TEST_PATH + "file_green.webp",
waitForLoad: false,
waitForStateStop: true,
});

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

@ -13,7 +13,10 @@ const TEST_PATH = getRootDirectory(gTestPath).replace(
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [["browser.download.improvements_to_download_panel", true]],
set: [
["browser.download.improvements_to_download_panel", true],
["image.webp.enabled", true],
],
});
const allowDirectoriesVal = DownloadIntegration.allowDirectories;
DownloadIntegration.allowDirectories = true;
@ -35,7 +38,7 @@ async function aDownloadLaunchedWithAppIsSavedInFolder(downloadDir) {
let loadingTab = await BrowserTestUtils.openNewForegroundTab({
gBrowser,
opening: TEST_PATH + "file_image_svgxml.svg",
opening: TEST_PATH + "file_green.webp",
waitForLoad: false,
waitForStateStop: true,
});

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

@ -46,7 +46,10 @@ 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 });
ensureMIMEState(
{ preferredAction: saveToDisk },
{ type: "text/plain", ext: "txt" }
);
registerCleanupFunction(async () => {
await publicList.removeFinished();
});
@ -76,7 +79,10 @@ add_task(async function aDownloadSavedToDiskPromptsForFolder() {
add_task(async function testFilesHandledInternally() {
let dir = await setupFilePickerDirectory();
ensureMIMEState({ preferredAction: handleInternally });
ensureMIMEState(
{ preferredAction: handleInternally },
{ type: "image/webp", ext: "webp" }
);
let filePickerShown = false;
MockFilePicker.showCallback = function(fp) {
@ -88,14 +94,14 @@ add_task(async function testFilesHandledInternally() {
gBrowser,
url => {
info("Got load for " + url);
return url.endsWith("file_image_svgxml.svg") && url.startsWith("file:");
return url.endsWith("file_green.webp") && url.startsWith("file:");
},
true,
true
);
let loadingTab = await BrowserTestUtils.openNewForegroundTab({
gBrowser,
opening: TEST_PATH + "file_image_svgxml.svg",
opening: TEST_PATH + "file_green.webp",
waitForLoad: false,
waitForStateStop: true,
});
@ -103,7 +109,7 @@ add_task(async function testFilesHandledInternally() {
let openedTab = await thirdTabPromise;
ok(!filePickerShown, "file picker should not have shown up.");
assertCorrectFile(dir, "file_image_svgxml.svg");
assertCorrectFile(dir, "file_green.webp");
// Cleanup
BrowserTestUtils.removeTab(loadingTab);
@ -289,8 +295,11 @@ function createSaveDir() {
return saveDir;
}
function ensureMIMEState({ preferredAction, preferredHandlerApp = null }) {
const mimeInfo = gMimeSvc.getFromTypeAndExtension("application/pdf", "pdf");
function ensureMIMEState(
{ preferredAction, preferredHandlerApp = null },
{ type = "application/pdf", ext = "pdf" } = {}
) {
const mimeInfo = gMimeSvc.getFromTypeAndExtension(type, ext);
mimeInfo.preferredAction = preferredAction;
mimeInfo.preferredApplicationHandler = preferredHandlerApp;
mimeInfo.alwaysAskBeforeHandling = false;

Двоичные данные
uriloader/exthandler/tests/mochitest/file_green.webp Normal file

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

После

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

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

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