modules/libjar/zipwriter/test/unit/test_asyncremove.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.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 4 */
michael@0 5
michael@0 6 var TESTS = [
michael@0 7 "test.txt",
michael@0 8 "test.png"
michael@0 9 ];
michael@0 10
michael@0 11 var observer = {
michael@0 12 onStartRequest: function(request, context)
michael@0 13 {
michael@0 14 },
michael@0 15
michael@0 16 onStopRequest: function(request, context, status)
michael@0 17 {
michael@0 18 do_check_eq(status, Components.results.NS_OK);
michael@0 19
michael@0 20 zipW.close();
michael@0 21
michael@0 22 // Empty zip file should just be the end of central directory marker
michael@0 23 var newTmpFile = tmpFile.clone();
michael@0 24 do_check_eq(newTmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE);
michael@0 25 do_test_finished();
michael@0 26 }
michael@0 27 };
michael@0 28
michael@0 29 function run_test()
michael@0 30 {
michael@0 31 // Copy our test zip to the tmp dir so we can modify it
michael@0 32 var testzip = do_get_file(DATA_DIR + "test.zip");
michael@0 33 testzip.copyTo(tmpDir, tmpFile.leafName);
michael@0 34
michael@0 35 do_check_true(tmpFile.exists());
michael@0 36
michael@0 37 zipW.open(tmpFile, PR_RDWR);
michael@0 38
michael@0 39 for (var i = 0; i < TESTS.length; i++) {
michael@0 40 do_check_true(zipW.hasEntry(TESTS[i]));
michael@0 41 zipW.removeEntry(TESTS[i], true);
michael@0 42 }
michael@0 43
michael@0 44 do_test_pending();
michael@0 45 zipW.processQueue(observer, null);
michael@0 46 do_check_true(zipW.inQueue);
michael@0 47 }

mercurial