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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/modules/libjar/zipwriter/test/unit/test_asyncremove.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,47 @@
     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 +var TESTS = [
    1.10 +  "test.txt",
    1.11 +  "test.png"
    1.12 +];
    1.13 +
    1.14 +var observer = {
    1.15 +  onStartRequest: function(request, context)
    1.16 +  {
    1.17 +  },
    1.18 +
    1.19 +  onStopRequest: function(request, context, status)
    1.20 +  {
    1.21 +    do_check_eq(status, Components.results.NS_OK);
    1.22 +
    1.23 +    zipW.close();
    1.24 +
    1.25 +    // Empty zip file should just be the end of central directory marker
    1.26 +    var newTmpFile = tmpFile.clone();
    1.27 +    do_check_eq(newTmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE);
    1.28 +    do_test_finished();
    1.29 +  }
    1.30 +};
    1.31 +
    1.32 +function run_test()
    1.33 +{
    1.34 +  // Copy our test zip to the tmp dir so we can modify it
    1.35 +  var testzip = do_get_file(DATA_DIR + "test.zip");
    1.36 +  testzip.copyTo(tmpDir, tmpFile.leafName);
    1.37 +
    1.38 +  do_check_true(tmpFile.exists());
    1.39 +
    1.40 +  zipW.open(tmpFile, PR_RDWR);
    1.41 +
    1.42 +  for (var i = 0; i < TESTS.length; i++) {
    1.43 +    do_check_true(zipW.hasEntry(TESTS[i]));
    1.44 +    zipW.removeEntry(TESTS[i], true);
    1.45 +  }
    1.46 +
    1.47 +  do_test_pending();
    1.48 +  zipW.processQueue(observer, null);
    1.49 +  do_check_true(zipW.inQueue);
    1.50 +}

mercurial