summaryrefslogtreecommitdiffstats
path: root/browser/modules/test/browser/browser_Telemetry_numberOfSiteOrigins.js
blob: 1ac2d485866c01932765b2cc37b2933b27b9e80f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* eslint-disable mozilla/no-arbitrary-setTimeout */
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

/**
 * This file tests page reload key combination telemetry
 */

"use strict";

ChromeUtils.defineESModuleGetters(this, {
  TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs",
});

const gTestRoot = getRootDirectory(gTestPath).replace(
  "chrome://mochitests/content",
  "http://mochi.test:8888"
);

const { TimedPromise } = ChromeUtils.importESModule(
  "chrome://remote/content/marionette/sync.sys.mjs"
);

async function run_test(count) {
  const histogram = TelemetryTestUtils.getAndClearHistogram(
    "FX_NUMBER_OF_UNIQUE_SITE_ORIGINS_ALL_TABS"
  );

  let newTab = await BrowserTestUtils.openNewForegroundTab({
    gBrowser,
    opening: gTestRoot + "contain_iframe.html",
    waitForStateStop: true,
  });

  await new Promise(resolve =>
    setTimeout(function() {
      window.requestIdleCallback(resolve);
    }, 1000)
  );

  if (count < 2) {
    await BrowserTestUtils.removeTab(newTab);
    await run_test(count + 1);
  } else {
    TelemetryTestUtils.assertHistogram(histogram, 2, 1);
    await BrowserTestUtils.removeTab(newTab);
  }
}

add_task(async function test_telemetryMoreSiteOrigin() {
  await run_test(1);
});