docshell/test/unit/test_bug414201_jfif.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docshell/test/unit/test_bug414201_jfif.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,27 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +/*
     1.9 + * Test for bug 414201
    1.10 + */
    1.11 +
    1.12 +function run_test()
    1.13 +{
    1.14 +    var ms = Components.classes["@mozilla.org/mime;1"].getService(Components.interfaces.nsIMIMEService);
    1.15 +
    1.16 +    /* Test a few common image types to make sure that they get the right extension */
    1.17 +    var types = {
    1.18 +        "image/jpeg": ["jpg", "jpeg"], /* accept either */
    1.19 +        "image/gif": ["gif"],
    1.20 +        "image/png": ["png"]
    1.21 +    };
    1.22 +
    1.23 +    /* Check whether the primary extension is what we'd expect */
    1.24 +    for (var mimetype in types) {
    1.25 +        var exts = types[mimetype];
    1.26 +        var primary = ms.getFromTypeAndExtension(mimetype, null).primaryExtension.toLowerCase();
    1.27 +
    1.28 +        do_check_true (exts.indexOf(primary) != -1);
    1.29 +    }
    1.30 +}

mercurial