mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
1e96300cf3
This limits us to 1 preloaded browser per window, in the top 3 normal windows + top 3 private windows. If we try to create additional browsers beyond that, we instead move a pre-existing browser across. Differential Revision: https://phabricator.services.mozilla.com/D21129 --HG-- extra : moz-landing-system : lando
46 lines
1.9 KiB
JavaScript
46 lines
1.9 KiB
JavaScript
/* 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);
|
|
Assert.notEqual(histValue(LABELS_STARTUP_CACHE_REQUESTS.Miss), 0);
|
|
await BrowserTestUtils.closeWindow(newWin);
|
|
|
|
Services.obs.notifyObservers(null, "startupcache-invalidate", "memoryOnly");
|
|
newWin = await BrowserTestUtils.openNewBrowserWindow();
|
|
snapshot = Services.telemetry.getSnapshotForHistograms("main", true);
|
|
Assert.notEqual(histValue(LABELS_STARTUP_CACHE_REQUESTS.HitMemory), 0);
|
|
Assert.notEqual(histValue(LABELS_STARTUP_CACHE_REQUESTS.HitDisk), 0);
|
|
// Some misses can come through - just ensure it's a small number
|
|
Assert.ok(histValue(LABELS_STARTUP_CACHE_REQUESTS.Miss) < 5);
|
|
await BrowserTestUtils.closeWindow(newWin);
|
|
});
|