summaryrefslogtreecommitdiffstats
path: root/toolkit/components/telemetry/tests
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/telemetry/tests')
-rw-r--r--toolkit/components/telemetry/tests/gtest/TestScalars.cpp62
-rw-r--r--toolkit/components/telemetry/tests/python/test_histogramtools_strict.py47
-rw-r--r--toolkit/components/telemetry/tests/python/test_parse_events.py16
-rw-r--r--toolkit/components/telemetry/tests/python/test_parse_scalars.py19
-rw-r--r--toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs7
-rw-r--r--toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js58
-rw-r--r--toolkit/components/telemetry/tests/unit/xpcshell.toml1
7 files changed, 66 insertions, 144 deletions
diff --git a/toolkit/components/telemetry/tests/gtest/TestScalars.cpp b/toolkit/components/telemetry/tests/gtest/TestScalars.cpp
index 201641e77a..3828cbdcd8 100644
--- a/toolkit/components/telemetry/tests/gtest/TestScalars.cpp
+++ b/toolkit/components/telemetry/tests/gtest/TestScalars.cpp
@@ -395,68 +395,6 @@ TEST_F(TelemetryTestFixture, ScalarEventSummary_Dynamic) {
scalarsSnapshot, 2);
}
-TEST_F(TelemetryTestFixture, WrongScalarOperator) {
- AutoJSContextWithGlobal cx(mCleanGlobal);
-
- // Make sure we don't get scalars from other tests.
- Unused << mTelemetry->ClearScalars();
-
- const uint32_t expectedValue = 1172015;
-
- Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_UNSIGNED_INT_KIND,
- expectedValue);
- Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_STRING_KIND,
- NS_LITERAL_STRING_FROM_CSTRING(EXPECTED_STRING));
- Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_BOOLEAN_KIND, true);
-
- TelemetryScalar::DeserializationStarted();
-
- Telemetry::ScalarAdd(Telemetry::ScalarID::TELEMETRY_TEST_STRING_KIND, 1447);
- Telemetry::ScalarAdd(Telemetry::ScalarID::TELEMETRY_TEST_BOOLEAN_KIND, 1447);
- Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_UNSIGNED_INT_KIND,
- true);
- TelemetryScalar::ApplyPendingOperations();
-
- JS::Rooted<JS::Value> scalarsSnapshot(cx.GetJSContext());
- GetScalarsSnapshot(false, cx.GetJSContext(), &scalarsSnapshot);
- CheckStringScalar("telemetry.test.string_kind", cx.GetJSContext(),
- scalarsSnapshot, EXPECTED_STRING);
- CheckBoolScalar("telemetry.test.boolean_kind", cx.GetJSContext(),
- scalarsSnapshot, true);
- CheckUintScalar("telemetry.test.unsigned_int_kind", cx.GetJSContext(),
- scalarsSnapshot, expectedValue);
-}
-
-TEST_F(TelemetryTestFixture, WrongKeyedScalarOperator) {
- AutoJSContextWithGlobal cx(mCleanGlobal);
-
- // Make sure we don't get scalars from other tests.
- Unused << mTelemetry->ClearScalars();
-
- const uint32_t kExpectedUint = 1172017;
-
- Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_KEYED_UNSIGNED_INT,
- u"key1"_ns, kExpectedUint);
- Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_KEYED_BOOLEAN_KIND,
- u"key2"_ns, true);
-
- TelemetryScalar::DeserializationStarted();
-
- Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_KEYED_UNSIGNED_INT,
- u"key1"_ns, false);
- Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_KEYED_BOOLEAN_KIND,
- u"key2"_ns, static_cast<uint32_t>(13));
-
- TelemetryScalar::ApplyPendingOperations();
-
- JS::Rooted<JS::Value> scalarsSnapshot(cx.GetJSContext());
- GetScalarsSnapshot(true, cx.GetJSContext(), &scalarsSnapshot);
- CheckKeyedUintScalar("telemetry.test.keyed_unsigned_int", "key1",
- cx.GetJSContext(), scalarsSnapshot, kExpectedUint);
- CheckKeyedBoolScalar("telemetry.test.keyed_boolean_kind", "key2",
- cx.GetJSContext(), scalarsSnapshot, true);
-}
-
TEST_F(TelemetryTestFixture, TestKeyedScalarAllowedKeys) {
AutoJSContextWithGlobal cx(mCleanGlobal);
// Make sure we don't get scalars from other tests.
diff --git a/toolkit/components/telemetry/tests/python/test_histogramtools_strict.py b/toolkit/components/telemetry/tests/python/test_histogramtools_strict.py
index 2109cd7d35..28d4646dfd 100644
--- a/toolkit/components/telemetry/tests/python/test_histogramtools_strict.py
+++ b/toolkit/components/telemetry/tests/python/test_histogramtools_strict.py
@@ -485,53 +485,6 @@ class TestParser(unittest.TestCase):
)
self.assertRaises(SystemExit, ParserError.exit_func)
- def test_gv_streaming_unsupported_kind(self):
- SAMPLE_HISTOGRAM = {
- "TEST_HISTOGRAM_GV_STREAMING": {
- "record_in_processes": ["main", "content"],
- "alert_emails": ["team@mozilla.xyz"],
- "bug_numbers": [1383793],
- "expires_in_version": "never",
- "kind": "boolean",
- "description": "Test histogram",
- "products": ["geckoview_streaming"],
- }
- }
- histograms = load_histogram(SAMPLE_HISTOGRAM)
- parse_histograms.load_allowlist()
- parse_histograms.Histogram(
- "TEST_HISTOGRAM_GV_STREAMING",
- histograms["TEST_HISTOGRAM_GV_STREAMING"],
- strict_type_checks=True,
- )
- self.assertRaises(SystemExit, ParserError.exit_func)
-
- def test_gv_streaming_keyed(self):
- SAMPLE_HISTOGRAM = {
- "TEST_HISTOGRAM_GV_STREAMING": {
- "record_in_processes": ["main", "content"],
- "alert_emails": ["team@mozilla.xyz"],
- "bug_numbers": [1383793],
- "expires_in_version": "never",
- "kind": "exponential",
- "low": 1024,
- "high": 2**64,
- "n_buckets": 100,
- "keyed": "true",
- "description": "Test histogram",
- "products": ["geckoview_streaming"],
- }
- }
- histograms = load_histogram(SAMPLE_HISTOGRAM)
- parse_histograms.load_allowlist()
- parse_histograms.Histogram(
- "TEST_HISTOGRAM_GV_STREAMING",
- histograms["TEST_HISTOGRAM_GV_STREAMING"],
- strict_type_checks=True,
- )
-
- self.assertRaises(SystemExit, ParserError.exit_func)
-
def test_enumerated_histogram_with_100_buckets(self):
SAMPLE_HISTOGRAM = {
"TEST_100_BUCKETS_HISTOGRAM": {
diff --git a/toolkit/components/telemetry/tests/python/test_parse_events.py b/toolkit/components/telemetry/tests/python/test_parse_events.py
index 0b7b91efcc..d6c7859eee 100644
--- a/toolkit/components/telemetry/tests/python/test_parse_events.py
+++ b/toolkit/components/telemetry/tests/python/test_parse_events.py
@@ -145,22 +145,6 @@ expiry_version: never
),
)
- def test_geckoview_streaming_product(self):
- SAMPLE_EVENT = """
-methods: ["method1", "method2"]
-objects: ["object1", "object2"]
-bug_numbers: [12345]
-notification_emails: ["test01@mozilla.com", "test02@mozilla.com"]
-record_in_processes: ["content"]
-description: This is a test entry for Telemetry.
-products: ["geckoview_streaming"]
-expiry_version: never
-"""
- event = load_event(SAMPLE_EVENT)
- parse_events.EventData("CATEGORY", "test_event", event, strict_type_checks=True)
-
- self.assertRaises(SystemExit, ParserError.exit_func)
-
if __name__ == "__main__":
mozunit.main()
diff --git a/toolkit/components/telemetry/tests/python/test_parse_scalars.py b/toolkit/components/telemetry/tests/python/test_parse_scalars.py
index c699cdb4d8..315c920a4a 100644
--- a/toolkit/components/telemetry/tests/python/test_parse_scalars.py
+++ b/toolkit/components/telemetry/tests/python/test_parse_scalars.py
@@ -243,25 +243,6 @@ bug_numbers:
parse_scalars.ScalarType("CATEGORY", "PROVE", scalar, strict_type_checks=True)
self.assertRaises(SystemExit, ParserError.exit_func)
- def test_gv_streaming_keyed(self):
- SAMPLE_SCALAR = """
-description: A nice one-line description.
-expires: never
-record_in_processes:
- - 'main'
-kind: uint
-notification_emails:
- - test01@mozilla.com
-products: ['geckoview_streaming']
-keyed: true
-bug_numbers:
- - 12345
-"""
-
- scalar = load_scalar(SAMPLE_SCALAR)
- parse_scalars.ScalarType("CATEGORY", "PROVE", scalar, strict_type_checks=True)
- self.assertRaises(SystemExit, ParserError.exit_func)
-
if __name__ == "__main__":
mozunit.main()
diff --git a/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs b/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs
index 0df6dfc2c1..1a4015df36 100644
--- a/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs
+++ b/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs
@@ -40,6 +40,8 @@ const PROFILE_RESET_DATE_MS = Date.now();
// The profile creation date, in milliseconds (Yesterday).
const PROFILE_FIRST_USE_MS = PROFILE_RESET_DATE_MS - MILLISECONDS_PER_DAY;
const PROFILE_CREATION_DATE_MS = PROFILE_FIRST_USE_MS - MILLISECONDS_PER_DAY;
+const PROFILE_RECOVERED_FROM_BACKUP =
+ PROFILE_RESET_DATE_MS - MILLISECONDS_PER_HOUR;
const GFX_VENDOR_ID = "0xabcd";
const GFX_DEVICE_ID = "0x1234";
@@ -126,6 +128,7 @@ export var TelemetryEnvironmentTesting = {
created: PROFILE_CREATION_DATE_MS,
reset: PROFILE_RESET_DATE_MS,
firstUse: PROFILE_FIRST_USE_MS,
+ recoveredFromBackup: PROFILE_RECOVERED_FROM_BACKUP,
}
);
},
@@ -392,6 +395,10 @@ export var TelemetryEnvironmentTesting = {
data.profile.firstUseDate,
truncateToDays(PROFILE_FIRST_USE_MS)
);
+ lazy.Assert.equal(
+ data.profile.recoveredFromBackup,
+ truncateToDays(PROFILE_RECOVERED_FROM_BACKUP)
+ );
},
checkPartnerSection(data, isInitial) {
diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
index 9990d83fdf..ca43772a07 100644
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js
@@ -712,6 +712,64 @@ add_task(async function test_addons() {
await addon.uninstall();
});
+add_task(async function test_signedTheme() {
+ AddonTestUtils.useRealCertChecks = true;
+
+ const { PKCS7_WITH_SHA1, COSE_WITH_SHA256 } = Ci.nsIAppSignatureInfo;
+
+ const ADDON_THEME_INSTALL_URL = gDataRoot + "webext-implicit-id.xpi";
+ const ADDON_THEME_ID = "{46607a7b-1b2a-40ce-9afe-91cda52c46a6}";
+
+ // Install the theme.
+ let deferred = Promise.withResolvers();
+ TelemetryEnvironment.registerChangeListener(
+ "test_signedAddon",
+ deferred.resolve
+ );
+ let theme = await installXPIFromURL(ADDON_THEME_INSTALL_URL);
+ await theme.enable();
+ ok(theme.isActive, "Theme should be active");
+
+ // Install an extension to force the telemetry environment to be
+ // updated (currently theme add-ons changes do not seem to be
+ // notified as changes, see EnvironmentAddonBuilder _updateAddons
+ // method for how changes to the environment.addons property are
+ // being detected).
+ const ADDON_INSTALL_URL = gDataRoot + "amosigned.xpi";
+ let addon = await installXPIFromURL(ADDON_INSTALL_URL);
+
+ await deferred.promise;
+ TelemetryEnvironment.unregisterChangeListener("test_signedAddon");
+
+ let data = TelemetryEnvironment.currentEnvironment;
+ TelemetryEnvironmentTesting.checkEnvironmentData(data);
+
+ // Check signedState and signedTypes on active theme data
+ // (NOTE: other properties of active theme are technically
+ // not covered by any other test task in this xpcshell test).
+ Assert.equal(
+ data.addons.theme.id,
+ ADDON_THEME_ID,
+ "Theme should be in the environment."
+ );
+ Assert.equal(
+ data.addons.theme.signedState,
+ AddonManager.SIGNEDSTATE_SIGNED,
+ "Got expected signedState on activeTheme"
+ );
+ Assert.equal(
+ data.addons.theme.signedTypes,
+ JSON.stringify([COSE_WITH_SHA256, PKCS7_WITH_SHA1]),
+ "Got expected signedTypes on activeTheme"
+ );
+
+ AddonTestUtils.useRealCertChecks = false;
+ await addon.startupPromise;
+ await addon.uninstall();
+ await theme.startupPromise;
+ await theme.uninstall();
+});
+
add_task(async function test_signedAddon() {
AddonTestUtils.useRealCertChecks = true;
diff --git a/toolkit/components/telemetry/tests/unit/xpcshell.toml b/toolkit/components/telemetry/tests/unit/xpcshell.toml
index 0c660888ed..ea5f6f418c 100644
--- a/toolkit/components/telemetry/tests/unit/xpcshell.toml
+++ b/toolkit/components/telemetry/tests/unit/xpcshell.toml
@@ -18,6 +18,7 @@ support-files = [
"testNoPDBAArch64.dll",
"!/toolkit/mozapps/extensions/test/xpcshell/head_addons.js",
"../../../../mozapps/extensions/test/xpinstall/amosigned.xpi",
+ "../../../../mozapps/extensions/test/xpcshell/data/webext-implicit-id.xpi",
]
generated-files = [
"system.xpi",