modules/libjar/zipwriter/test/unit/test_bug467740.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     4  */
     6 function run_test()
     7 {
     8   // In this test we try to open some files that aren't archives:
     9   //  - An empty file, that is certainly not an archive.
    10   //  - A file that couldn't be mistaken for archive, since it is too small.
    11   //  - A file that could be mistaken for archive, if we checked only the file
    12   //     size, but is invalid since it contains no ZIP signature.
    13   var invalidArchives = ["emptyfile.txt", "smallfile.txt", "test.png"];
    15   invalidArchives.forEach(function(invalidArchive) {
    16     // Get a reference to the invalid file
    17     var invalidFile = do_get_file(DATA_DIR + invalidArchive);
    19     // Opening the invalid file should fail (but not crash)
    20     try {
    21       zipW.open(invalidFile, PR_RDWR);
    22       do_throw("Should have thrown NS_ERROR_FILE_CORRUPTED on " +
    23                invalidArchive + " !");
    24     } catch (e if (e instanceof Ci.nsIException &&
    25                    e.result == Components.results.NS_ERROR_FILE_CORRUPTED)) {
    26       // do nothing
    27     }
    28   });
    29 }

mercurial