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
This commit is contained in:
Chris H-C
2025-05-08 14:04:01 +00:00
committed by chutten@mozilla.com
parent fa0a9b427c
commit 1b8f8d40eb
2 changed files with 61 additions and 50 deletions

View File

@@ -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.ok("D2DEnabled" in gfxData);
lazy.Assert.equal(gfxData.D2DEnabled, Glean.gfx.d2dEnabled.testGetValue()); lazy.Assert.equal(gfxData.D2DEnabled, Glean.gfx.d2dEnabled.testGetValue());
lazy.Assert.ok("DWriteEnabled" in gfxData); lazy.Assert.ok("DWriteEnabled" in gfxData);
@@ -884,6 +935,14 @@ export var TelemetryEnvironmentTesting = {
lazy.Assert.equal(typeof gfxData.features.gpuProcess.status, "string"); lazy.Assert.equal(typeof gfxData.features.gpuProcess.status, "string");
lazy.Assert.ok(!!Glean.gfxFeatures.gpuProcess.testGetValue().status); 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 { try {
// If we've not got nsIGfxInfoDebug, then this will throw and stop us doing // If we've not got nsIGfxInfoDebug, then this will throw and stop us doing
// this test. // this test.
@@ -911,54 +970,6 @@ export var TelemetryEnvironmentTesting = {
Glean.gfxFeatures.gpuProcess.testGetValue().status Glean.gfxFeatures.gpuProcess.testGetValue().status
); );
} catch (e) {} } 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) { checkActiveAddon(id, data, partialRecord) {

View File

@@ -152,7 +152,7 @@ gfx.features:
status: status:
type: string type: string
version: version:
type: number type: string
notification_emails: notification_emails:
- gfx-telemetry-alerts@mozilla.com - gfx-telemetry-alerts@mozilla.com
expires: never expires: never