test_asyncremove.js (1038B)
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 = ["test.txt", "test.png"]; 7 8 var observer = { 9 onStartRequest() {}, 10 11 onStopRequest(request, status) { 12 Assert.equal(status, Cr.NS_OK); 13 14 zipW.close(); 15 16 // Empty zip file should just be the end of central directory marker 17 var newTmpFile = tmpFile.clone(); 18 Assert.equal(newTmpFile.fileSize, ZIP_EOCDR_HEADER_SIZE); 19 do_test_finished(); 20 }, 21 }; 22 23 function run_test() { 24 // Copy our test zip to the tmp dir so we can modify it 25 var testzip = do_get_file(DATA_DIR + "test.zip"); 26 testzip.copyTo(tmpDir, tmpFile.leafName); 27 28 Assert.ok(tmpFile.exists()); 29 30 zipW.open(tmpFile, PR_RDWR); 31 32 for (var i = 0; i < TESTS.length; i++) { 33 Assert.ok(zipW.hasEntry(TESTS[i])); 34 zipW.removeEntry(TESTS[i], true); 35 } 36 37 do_test_pending(); 38 zipW.processQueue(observer, null); 39 Assert.ok(zipW.inQueue); 40 }