tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_bfcache_telemetry.js (1273B)


      1 const URL1 = "data:text/html;charset=utf-8,<body><p>Hello1</p></body>";
      2 const URL2 = "data:text/html;charset=utf-8,<body><p>Hello2</p></body>";
      3 
      4 async function getBFCacheComboTelemetry(probeInParent) {
      5  let bfcacheCombo;
      6  await TestUtils.waitForCondition(() => {
      7    let histograms;
      8    if (probeInParent) {
      9      histograms = Services.telemetry.getSnapshotForHistograms(
     10        "main",
     11        false /* clear */
     12      ).parent;
     13    } else {
     14      histograms = Services.telemetry.getSnapshotForHistograms(
     15        "main",
     16        false /* clear */
     17      ).content;
     18    }
     19    bfcacheCombo = histograms.BFCACHE_COMBO;
     20    return bfcacheCombo;
     21  });
     22  return bfcacheCombo;
     23 }
     24 
     25 async function test_bfcache_telemetry(probeInParent) {
     26  Services.telemetry.getHistogramById("BFCACHE_COMBO").clear();
     27 
     28  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL1);
     29 
     30  BrowserTestUtils.startLoadingURIString(tab.linkedBrowser, URL2);
     31  await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
     32 
     33  let bfcacheCombo = await getBFCacheComboTelemetry(probeInParent);
     34 
     35  is(bfcacheCombo.values[0], 1, "1 bfcache success");
     36 
     37  gBrowser.removeTab(tab);
     38 }
     39 
     40 add_task(async () => {
     41  await test_bfcache_telemetry(
     42    Services.prefs.getBoolPref("fission.bfcacheInParent")
     43  );
     44 });