diff --git a/toolkit/components/telemetry/TelemetryEnvironment.jsm b/toolkit/components/telemetry/TelemetryEnvironment.jsm index eddffb699de..8706ef1f964 100644 --- a/toolkit/components/telemetry/TelemetryEnvironment.jsm +++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm @@ -1259,7 +1259,8 @@ EnvironmentCache.prototype = { // Query the UBR key and only add it to the environment if it's available. // |readRegKey| doesn't throw, but rather returns 'undefined' on error. let ubr = WindowsRegistry.readRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE, - WINDOWS_UBR_KEY_PATH, "UBR"); + WINDOWS_UBR_KEY_PATH, "UBR", + Ci.nsIWindowsRegKey.WOW64_64); data.windowsUBR = (ubr !== undefined) ? ubr : null; } data.installYear = getSysinfoProperty("installYear", null); diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js index dc2908956bf..6c43fc55fd5 100644 --- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js @@ -518,8 +518,8 @@ function checkSystemSection(data) { } if ("windowsUBR" in osData) { // This might not be available on all Windows platforms. - Assert.ok(Number.isFinite(osData["windowsUBR"]), - "windowsUBR must be a number."); + Assert.ok((osData["windowsUBR"] === null) || Number.isFinite(osData["windowsUBR"]), + "windowsUBR must be null or a number."); } } else if (gIsAndroid || gIsGonk) { Assert.ok(checkNullOrString(osData.kernelVersion)); diff --git a/toolkit/modules/WindowsRegistry.jsm b/toolkit/modules/WindowsRegistry.jsm index 2e7a5ad3938..c015d1eefcb 100644 --- a/toolkit/modules/WindowsRegistry.jsm +++ b/toolkit/modules/WindowsRegistry.jsm @@ -17,15 +17,19 @@ var WindowsRegistry = { * The registry path to the key. * @param aKey * The key name. + * @param [aRegistryNode=0] + * Optionally set to nsIWindowsRegKey.WOW64_64 (or nsIWindowsRegKey.WOW64_32) + * to access a 64-bit (32-bit) key from either a 32-bit or 64-bit application. * @return The key value or undefined if it doesn't exist. If the key is * a REG_MULTI_SZ, an array is returned. */ - readRegKey: function(aRoot, aPath, aKey) { + readRegKey: function(aRoot, aPath, aKey, aRegistryNode=0) { const kRegMultiSz = 7; + const kMode = Ci.nsIWindowsRegKey.ACCESS_READ | aRegistryNode; let registry = Cc["@mozilla.org/windows-registry-key;1"]. createInstance(Ci.nsIWindowsRegKey); try { - registry.open(aRoot, aPath, Ci.nsIWindowsRegKey.ACCESS_READ); + registry.open(aRoot, aPath, kMode); if (registry.hasValue(aKey)) { let type = registry.getValueType(aKey); switch (type) { @@ -57,13 +61,17 @@ var WindowsRegistry = { * The registry path to the key. * @param aKey * The key name. + * @param [aRegistryNode=0] + * Optionally set to nsIWindowsRegKey.WOW64_64 (or nsIWindowsRegKey.WOW64_32) + * to access a 64-bit (32-bit) key from either a 32-bit or 64-bit application. */ - removeRegKey: function(aRoot, aPath, aKey) { + removeRegKey: function(aRoot, aPath, aKey, aRegistryNode=0) { let registry = Cc["@mozilla.org/windows-registry-key;1"]. createInstance(Ci.nsIWindowsRegKey); try { let mode = Ci.nsIWindowsRegKey.ACCESS_QUERY_VALUE | - Ci.nsIWindowsRegKey.ACCESS_SET_VALUE; + Ci.nsIWindowsRegKey.ACCESS_SET_VALUE | + aRegistryNode; registry.open(aRoot, aPath, mode); if (registry.hasValue(aKey)) { registry.removeValue(aKey);