1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
6 const LABELS_STARTUP_CACHE_REQUESTS
= {
12 add_task(async
function () {
13 // Turn off tab preloading to avoid issues with RemoteController.js
14 await SpecialPowers
.pushPrefEnv({
15 set: [["browser.newtab.preload", false]],
18 Services
.obs
.notifyObservers(null, "startupcache-invalidate");
19 Services
.telemetry
.getSnapshotForHistograms("main", true);
20 let newWin
= await BrowserTestUtils
.openNewBrowserWindow();
21 let snapshot
= Services
.telemetry
.getSnapshotForHistograms("main", true);
22 function histValue(label
) {
23 return snapshot
.parent
.STARTUP_CACHE_REQUESTS
.values
[label
] || 0;
25 Assert
.equal(histValue(LABELS_STARTUP_CACHE_REQUESTS
.HitMemory
), 0);
26 Assert
.equal(histValue(LABELS_STARTUP_CACHE_REQUESTS
.HitDisk
), 0);
27 Assert
.notEqual(histValue(LABELS_STARTUP_CACHE_REQUESTS
.Miss
), 0);
28 await BrowserTestUtils
.closeWindow(newWin
);
30 newWin
= await BrowserTestUtils
.openNewBrowserWindow();
31 snapshot
= Services
.telemetry
.getSnapshotForHistograms("main", true);
32 Assert
.notEqual(histValue(LABELS_STARTUP_CACHE_REQUESTS
.HitMemory
), 0);
33 Assert
.equal(histValue(LABELS_STARTUP_CACHE_REQUESTS
.HitDisk
), 0);
35 // Here and below, 50 is just a nice round number that should be well over
36 // what we should observe under normal circumstances, and well under what
37 // we should see if something is seriously wrong. It won't catch everything,
38 // but it's better than nothing, and better than a test that cries wolf.
39 Assert
.less(histValue(LABELS_STARTUP_CACHE_REQUESTS
.Miss
), 50);
40 await BrowserTestUtils
.closeWindow(newWin
);
42 Services
.obs
.notifyObservers(null, "startupcache-invalidate", "memoryOnly");
43 newWin
= await BrowserTestUtils
.openNewBrowserWindow();
44 snapshot
= Services
.telemetry
.getSnapshotForHistograms("main", true);
45 Assert
.less(histValue(LABELS_STARTUP_CACHE_REQUESTS
.HitMemory
), 50);
46 Assert
.notEqual(histValue(LABELS_STARTUP_CACHE_REQUESTS
.HitDisk
), 0);
47 // Some misses can come through - just ensure it's a small number
48 Assert
.less(histValue(LABELS_STARTUP_CACHE_REQUESTS
.Miss
), 50);
49 await BrowserTestUtils
.closeWindow(newWin
);