Bug 1824959 - add tests for .desktop sanitization, r=NeilDeakin

Differential Revision: https://phabricator.services.mozilla.com/D173966
This commit is contained in:
Gijs Kruitbosch 2023-05-16 23:00:45 +00:00
Родитель 859144ba5e
Коммит 83b725df8b
2 изменённых файлов: 25 добавлений и 0 удалений

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

@ -110,6 +110,11 @@ add_task(async function test_sanitize() {
testSanitize("thing.local|", "thing.local.download");
testSanitize("thing.lo|cal", "thing.lo cal");
testSanitize('thing.local/*"', "thing.local_");
testSanitize("thing.desktoP", "thing.desktoP.download");
testSanitize("thing.desktoP \n", "thing.desktoP", {
allowInvalidFilenames: true,
});
});
add_task(async function test_splitBaseNameAndExtension() {

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

@ -375,4 +375,24 @@ add_task(async function validate_filename_method() {
"filename.URL",
"filename.URL allow invalid, sanitize only"
);
Assert.equal(
mimeService.validateFileNameForSaving(
"filename.desktop",
"text/unknown",
mimeService.VALIDATE_SANITIZE_ONLY
),
"filename.desktop.download",
"filename.desktop sanitize only"
);
Assert.equal(
mimeService.validateFileNameForSaving(
"filename.DESKTOP\n",
"text/unknown",
mimeService.VALIDATE_SANITIZE_ONLY |
mimeService.VALIDATE_ALLOW_INVALID_FILENAMES
),
"filename.DESKTOP",
"filename.DESKTOP allow invalid, sanitize only"
);
});