Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 const ARCHIVE = "zips/zen.zip";
7 const SUBDIR = "zen";
8 const ENTRIES = ["beyond.txt", "waterwood.txt"];
10 Components.utils.import("resource://gre/modules/ZipUtils.jsm");
11 Components.utils.import("resource://gre/modules/FileUtils.jsm");
14 const archive = do_get_file(ARCHIVE, false);
15 const dir = do_get_profile().clone();
16 dir.append("test_ZipUtils");
18 function run_test() {
19 run_next_test();
20 }
22 function ensureExtracted(target) {
23 target.append(SUBDIR);
24 do_check_true(target.exists());
26 for (let i = 0; i < ENTRIES.length; i++) {
27 let entry = target.clone();
28 entry.append(ENTRIES[i]);
29 do_print("ENTRY " + entry.path);
30 do_check_true(entry.exists());
31 }
32 }
35 add_task(function test_extractFiles() {
36 let target = dir.clone();
37 target.append("test_extractFiles");
39 try {
40 ZipUtils.extractFiles(archive, target);
41 } catch(e) {
42 do_throw("Failed to extract synchronously!");
43 }
45 ensureExtracted(target);
46 });
48 add_task(function test_extractFilesAsync() {
49 let target = dir.clone();
50 target.append("test_extractFilesAsync");
51 target.create(Components.interfaces.nsIFile.DIRECTORY_TYPE,
52 FileUtils.PERMS_DIRECTORY);
54 yield ZipUtils.extractFilesAsync(archive, target).then(
55 function success() {
56 do_print("SUCCESS");
57 ensureExtracted(target);
58 },
59 function failure() {
60 do_print("FAILURE");
61 do_throw("Failed to extract asynchronously!");
62 }
63 );
64 });