From 1b8f8d40eb8752fb64277df473bc198b0586f0bf Mon Sep 17 00:00:00 2001 From: Chris H-C Date: Thu, 8 May 2025 14:04:01 +0000 Subject: [PATCH] Bug 1964474 - D2D's version is actually a string r=TravisLong Have to split the gfx checks out to their own function because of a complexity eslint. Differential Revision: https://phabricator.services.mozilla.com/D247819 --- .../unit/TelemetryEnvironmentTesting.sys.mjs | 109 ++++++++++-------- widget/metrics.yaml | 2 +- 2 files changed, 61 insertions(+), 50 deletions(-) diff --git a/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs b/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs index b684b5c20928..3a9eaa251e75 100644 --- a/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs +++ b/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs @@ -803,7 +803,58 @@ export var TelemetryEnvironmentTesting = { } } - let gfxData = data.system.gfx; + this.checkGfx(data.system.gfx); + + if (gIsMac) { + lazy.Assert.ok(this.checkString(data.system.appleModelId)); + lazy.Assert.equal( + data.system.appleModelId, + Glean.system.appleModelId.testGetValue() + ); + } else { + lazy.Assert.ok(this.checkNullOrString(data.system.appleModelId)); + lazy.Assert.equal(null, Glean.system.appleModelId.testGetValue()); + } + + // This feature is only available on Windows + if (AppConstants.platform == "win") { + lazy.Assert.ok( + "sec" in data.system, + "sec must be available under data.system" + ); + + let SEC_FIELDS = ["antivirus", "antispyware", "firewall"]; + for (let f of SEC_FIELDS) { + let products = Glean.windowsSecurity[f].testGetValue(); + lazy.Assert.ok( + f in data.system.sec, + f + " must be available under data.system.sec" + ); + + let value = data.system.sec[f]; + // value is null on Windows Server + lazy.Assert.ok( + value === null || Array.isArray(value), + f + " must be either null or an array" + ); + if (Array.isArray(value)) { + for (let product of value) { + // It is posssible that this will fail if either the Legacy or + // Glean string limits are hit. If the Glean string_list limits are + // hit, `testGetValue` above will throw, though. + lazy.Assert.ok(products.includes(product), `${f} data must match.`); + lazy.Assert.equal( + typeof product, + "string", + "Each element of " + f + " must be a string" + ); + } + } + } + } + }, + + checkGfx(gfxData) { lazy.Assert.ok("D2DEnabled" in gfxData); lazy.Assert.equal(gfxData.D2DEnabled, Glean.gfx.d2dEnabled.testGetValue()); lazy.Assert.ok("DWriteEnabled" in gfxData); @@ -884,6 +935,14 @@ export var TelemetryEnvironmentTesting = { lazy.Assert.equal(typeof gfxData.features.gpuProcess.status, "string"); lazy.Assert.ok(!!Glean.gfxFeatures.gpuProcess.testGetValue().status); + if (gIsWindows && !!gfxData.features?.d2d?.version) { + lazy.Assert.equal(typeof gfxData.features.d2d.version, "string"); + lazy.Assert.equal( + gfxData.features.d2d.version, + Glean.gfxFeatures.d2d.testGetValue().version + ); + } + try { // If we've not got nsIGfxInfoDebug, then this will throw and stop us doing // this test. @@ -911,54 +970,6 @@ export var TelemetryEnvironmentTesting = { Glean.gfxFeatures.gpuProcess.testGetValue().status ); } catch (e) {} - - if (gIsMac) { - lazy.Assert.ok(this.checkString(data.system.appleModelId)); - lazy.Assert.equal( - data.system.appleModelId, - Glean.system.appleModelId.testGetValue() - ); - } else { - lazy.Assert.ok(this.checkNullOrString(data.system.appleModelId)); - lazy.Assert.equal(null, Glean.system.appleModelId.testGetValue()); - } - - // This feature is only available on Windows - if (AppConstants.platform == "win") { - lazy.Assert.ok( - "sec" in data.system, - "sec must be available under data.system" - ); - - let SEC_FIELDS = ["antivirus", "antispyware", "firewall"]; - for (let f of SEC_FIELDS) { - let products = Glean.windowsSecurity[f].testGetValue(); - lazy.Assert.ok( - f in data.system.sec, - f + " must be available under data.system.sec" - ); - - let value = data.system.sec[f]; - // value is null on Windows Server - lazy.Assert.ok( - value === null || Array.isArray(value), - f + " must be either null or an array" - ); - if (Array.isArray(value)) { - for (let product of value) { - // It is posssible that this will fail if either the Legacy or - // Glean string limits are hit. If the Glean string_list limits are - // hit, `testGetValue` above will throw, though. - lazy.Assert.ok(products.includes(product), `${f} data must match.`); - lazy.Assert.equal( - typeof product, - "string", - "Each element of " + f + " must be a string" - ); - } - } - } - } }, checkActiveAddon(id, data, partialRecord) { diff --git a/widget/metrics.yaml b/widget/metrics.yaml index 397cbd71ab51..7d8c9db21531 100644 --- a/widget/metrics.yaml +++ b/widget/metrics.yaml @@ -152,7 +152,7 @@ gfx.features: status: type: string version: - type: number + type: string notification_emails: - gfx-telemetry-alerts@mozilla.com expires: never