blob: 03b0cea25e27420179bccc4df94fff7bbef7f487 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
XPCOMUtils.defineLazyServiceGetter(
this,
"gMIMEService",
"@mozilla.org/mime;1",
"nsIMIMEService"
);
// PDF files should always have a generic description instead
// of relying on what is registered with the Operating System.
add_task(async function test_check_unknown_mime_type() {
const mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
let pdfType = mimeService.getTypeFromExtension("pdf");
Assert.equal(pdfType, "application/pdf");
let extension = mimeService.getPrimaryExtension("application/pdf", "");
Assert.equal(extension, "pdf", "Expect pdf extension when given mime");
let mimeInfo = gMIMEService.getFromTypeAndExtension("", "pdf");
let stringBundle = Services.strings.createBundle(
"chrome://mozapps/locale/downloads/unknownContentType.properties"
);
Assert.equal(
mimeInfo.description,
stringBundle.GetStringFromName("pdfExtHandlerDescription"),
"PDF has generic description"
);
});
|