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 "use strict";
3 let {OS: {File, Path, Constants}} = Components.utils.import("resource://gre/modules/osfile.jsm", {});
4 let {Services} = Components.utils.import("resource://gre/modules/Services.jsm", {});
6 // Ensure that we have a profile but that the OS.File worker is not launched
7 add_task(function* init() {
8 do_get_profile();
9 yield File.resetWorker();
10 });
12 function getCount(histogram) {
13 if (histogram == null) {
14 return 0;
15 }
17 let total = 0;
18 for (let i of histogram.counts) {
19 total += i;
20 }
21 return total;
22 }
24 // Ensure that launching the OS.File worker adds data to the relevant
25 // histograms
26 add_task(function* test_startup() {
27 let LAUNCH = "OSFILE_WORKER_LAUNCH_MS";
28 let READY = "OSFILE_WORKER_READY_MS";
30 let before = Services.telemetry.histogramSnapshots;
32 // Launch the OS.File worker
33 yield File.getCurrentDirectory();
35 let after = Services.telemetry.histogramSnapshots;
38 do_print("Ensuring that we have recorded measures for histograms");
39 do_check_eq(getCount(after[LAUNCH]), getCount(before[LAUNCH]) + 1);
40 do_check_eq(getCount(after[READY]), getCount(before[READY]) + 1);
42 do_print("Ensuring that launh <= ready");
43 do_check_true(after[LAUNCH].sum <= after[READY].sum);
44 });
46 // Ensure that calling writeAtomic adds data to the relevant histograms
47 add_task(function* test_writeAtomic() {
48 let LABEL = "OSFILE_WRITEATOMIC_JANK_MS";
50 let before = Services.telemetry.histogramSnapshots;
52 // Perform a write.
53 let path = Path.join(Constants.Path.profileDir, "test_osfile_telemetry.tmp");
54 yield File.writeAtomic(path, LABEL, { tmpPath: path + ".tmp" } );
56 let after = Services.telemetry.histogramSnapshots;
58 do_check_eq(getCount(after[LABEL]), getCount(before[LABEL]) + 1);
59 });
61 function run_test() {
62 run_next_test();
63 }