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

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:2a3711a2d87a
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 */
5
6 var TESTS = [
7 "test.txt",
8 "test.png"
9 ];
10
11 var observer = {
12 onStartRequest: function(request, context)
13 {
14 },
15
16 onStopRequest: function(request, context, status)
17 {
18 do_check_eq(status, Components.results.NS_OK);
19
20 zipW.close();
21
22 // Empty zip file should just be the end of central directory marker
23 var newTmpFile = tmpFile.clone();
24 do_check_eq(newTmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE);
25 do_test_finished();
26 }
27 };
28
29 function run_test()
30 {
31 // Copy our test zip to the tmp dir so we can modify it
32 var testzip = do_get_file(DATA_DIR + "test.zip");
33 testzip.copyTo(tmpDir, tmpFile.leafName);
34
35 do_check_true(tmpFile.exists());
36
37 zipW.open(tmpFile, PR_RDWR);
38
39 for (var i = 0; i < TESTS.length; i++) {
40 do_check_true(zipW.hasEntry(TESTS[i]));
41 zipW.removeEntry(TESTS[i], true);
42 }
43
44 do_test_pending();
45 zipW.processQueue(observer, null);
46 do_check_true(zipW.inQueue);
47 }

mercurial