diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /startupcache/test/browser | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream/115.8.0esr.tar.xz firefox-esr-upstream/115.8.0esr.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'startupcache/test/browser')
-rw-r--r-- | startupcache/test/browser/browser.ini | 1 | ||||
-rw-r--r-- | startupcache/test/browser/browser_startupcache_telemetry.js | 50 |
2 files changed, 51 insertions, 0 deletions
diff --git a/startupcache/test/browser/browser.ini b/startupcache/test/browser/browser.ini new file mode 100644 index 0000000000..cd4a5cbbe6 --- /dev/null +++ b/startupcache/test/browser/browser.ini @@ -0,0 +1 @@ +[browser_startupcache_telemetry.js] diff --git a/startupcache/test/browser/browser_startupcache_telemetry.js b/startupcache/test/browser/browser_startupcache_telemetry.js new file mode 100644 index 0000000000..e4c8085bed --- /dev/null +++ b/startupcache/test/browser/browser_startupcache_telemetry.js @@ -0,0 +1,50 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const LABELS_STARTUP_CACHE_REQUESTS = { + HitMemory: 0, + HitDisk: 1, + Miss: 2, +}; + +add_task(async function () { + // Turn off tab preloading to avoid issues with RemoteController.js + await SpecialPowers.pushPrefEnv({ + set: [["browser.newtab.preload", false]], + }); + + Services.obs.notifyObservers(null, "startupcache-invalidate"); + Services.telemetry.getSnapshotForHistograms("main", true); + let newWin = await BrowserTestUtils.openNewBrowserWindow(); + let snapshot = Services.telemetry.getSnapshotForHistograms("main", true); + function histValue(label) { + return snapshot.parent.STARTUP_CACHE_REQUESTS.values[label] || 0; + } + Assert.equal(histValue(LABELS_STARTUP_CACHE_REQUESTS.HitMemory), 0); + Assert.equal(histValue(LABELS_STARTUP_CACHE_REQUESTS.HitDisk), 0); + Assert.notEqual(histValue(LABELS_STARTUP_CACHE_REQUESTS.Miss), 0); + await BrowserTestUtils.closeWindow(newWin); + + newWin = await BrowserTestUtils.openNewBrowserWindow(); + snapshot = Services.telemetry.getSnapshotForHistograms("main", true); + Assert.notEqual(histValue(LABELS_STARTUP_CACHE_REQUESTS.HitMemory), 0); + Assert.equal(histValue(LABELS_STARTUP_CACHE_REQUESTS.HitDisk), 0); + + // Here and below, 50 is just a nice round number that should be well over + // what we should observe under normal circumstances, and well under what + // we should see if something is seriously wrong. It won't catch everything, + // but it's better than nothing, and better than a test that cries wolf. + Assert.less(histValue(LABELS_STARTUP_CACHE_REQUESTS.Miss), 50); + await BrowserTestUtils.closeWindow(newWin); + + Services.obs.notifyObservers(null, "startupcache-invalidate", "memoryOnly"); + newWin = await BrowserTestUtils.openNewBrowserWindow(); + snapshot = Services.telemetry.getSnapshotForHistograms("main", true); + Assert.less(histValue(LABELS_STARTUP_CACHE_REQUESTS.HitMemory), 50); + Assert.notEqual(histValue(LABELS_STARTUP_CACHE_REQUESTS.HitDisk), 0); + // Some misses can come through - just ensure it's a small number + Assert.less(histValue(LABELS_STARTUP_CACHE_REQUESTS.Miss), 50); + await BrowserTestUtils.closeWindow(newWin); +}); |