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);
34 Assert.less(histValue(LABELS_STARTUP_CACHE_REQUESTS.Miss), 9);
35 await BrowserTestUtils.closeWindow(newWin);
37 Services.obs.notifyObservers(null, "startupcache-invalidate", "memoryOnly");
38 newWin = await BrowserTestUtils.openNewBrowserWindow();
39 snapshot = Services.telemetry.getSnapshotForHistograms("main", true);
40 Assert.less(histValue(LABELS_STARTUP_CACHE_REQUESTS.HitMemory), 4);
41 Assert.notEqual(histValue(LABELS_STARTUP_CACHE_REQUESTS.HitDisk), 0);
42 // Some misses can come through - just ensure it's a small number
43 Assert.less(histValue(LABELS_STARTUP_CACHE_REQUESTS.Miss), 5);
44 await BrowserTestUtils.closeWindow(newWin);