modules/libjar/zipwriter/test/unit/test_undochange.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 // Values taken from using zipinfo to list the test.zip contents
     7 var TESTS = [
     8   "test.txt",
     9   "test.png"
    10 ];
    12 function run_test()
    13 {
    14   zipW.open(tmpFile, PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE);
    16   for (var i = 0; i < TESTS.length; i++) {
    17     var source = do_get_file(DATA_DIR + TESTS[i]);
    18     zipW.addEntryFile(TESTS[i], Ci.nsIZipWriter.COMPRESSION_NONE, source,
    19                       false);
    20   }
    22   try {
    23     var source = do_get_file(DATA_DIR + TESTS[0]);
    24     zipW.addEntryFile(TESTS[0], Ci.nsIZipWriter.COMPRESSION_NONE, source,
    25                       false);
    26     do_throw("Should not be able to add the same file twice");
    27   }
    28   catch (e) {
    29     do_check_eq(e.result, Components.results.NS_ERROR_FILE_ALREADY_EXISTS);
    30   }
    32   // Remove all the tests and see if we are left with an empty zip
    33   for (var i = 0; i < TESTS.length; i++) {
    34     zipW.removeEntry(TESTS[i], false);
    35   }
    37   zipW.close();
    39   // Empty zip file should just be the end of central directory marker
    40   var newTmpFile = tmpFile.clone();
    41   do_check_eq(newTmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE);
    42 }

mercurial