зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1672003 - Create basic test for skeleton UI registry values r=agashlin
Differential Revision: https://phabricator.services.mozilla.com/D94111
This commit is contained in:
Родитель
623cb0de05
Коммит
0c6cc8ff79
|
@ -79,6 +79,9 @@ with Files("test/siteIdentity/**"):
|
|||
with Files("test/sidebar/**"):
|
||||
BUG_COMPONENT = ("Firefox", "General")
|
||||
|
||||
with Files("test/startup/**"):
|
||||
BUG_COMPONENT = ("Firefox", "General")
|
||||
|
||||
with Files("test/static/**"):
|
||||
BUG_COMPONENT = ("Firefox", "General")
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
extends: ["plugin:mozilla/browser-test"],
|
||||
};
|
|
@ -0,0 +1,2 @@
|
|||
[browser_preXULSkeletonUIRegistry.js]
|
||||
skip-if = os != 'win'
|
|
@ -0,0 +1,107 @@
|
|||
ChromeUtils.defineModuleGetter(
|
||||
this,
|
||||
"WindowsRegistry",
|
||||
"resource://gre/modules/WindowsRegistry.jsm"
|
||||
);
|
||||
|
||||
// This is copied from WindowsRegistry.jsm, but extended to support
|
||||
// TYPE_BINARY, as that is how we represent doubles in the registry for
|
||||
// the skeleton UI. However, we didn't extend WindowsRegistry.jsm itself,
|
||||
// because TYPE_BINARY is kind of a footgun for javascript callers - our
|
||||
// use case is just trivial (checking that the value is non-zero).
|
||||
function readRegKeyExtended(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, kMode);
|
||||
if (registry.hasValue(aKey)) {
|
||||
let type = registry.getValueType(aKey);
|
||||
switch (type) {
|
||||
case kRegMultiSz:
|
||||
// nsIWindowsRegKey doesn't support REG_MULTI_SZ type out of the box.
|
||||
let str = registry.readStringValue(aKey);
|
||||
return str.split("\0").filter(v => v);
|
||||
case Ci.nsIWindowsRegKey.TYPE_STRING:
|
||||
return registry.readStringValue(aKey);
|
||||
case Ci.nsIWindowsRegKey.TYPE_INT:
|
||||
return registry.readIntValue(aKey);
|
||||
case Ci.nsIWindowsRegKey.TYPE_BINARY:
|
||||
return registry.readBinaryValue(aKey);
|
||||
default:
|
||||
throw new Error("Unsupported registry value.");
|
||||
}
|
||||
}
|
||||
} catch (ex) {
|
||||
} finally {
|
||||
registry.close();
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
add_task(async function testWritesEnabledOnPrefChange() {
|
||||
Services.prefs.setBoolPref("browser.startup.preXulSkeletonUI", true);
|
||||
let enabled = WindowsRegistry.readRegKey(
|
||||
Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
||||
"Software\\Mozilla\\Firefox\\PreXULSkeletonUISettings",
|
||||
"enabled"
|
||||
);
|
||||
is(enabled, 1, "Pre-XUL skeleton UI is enabled in the Windows registry");
|
||||
|
||||
Services.prefs.setBoolPref("browser.startup.preXulSkeletonUI", false);
|
||||
enabled = WindowsRegistry.readRegKey(
|
||||
Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
||||
"Software\\Mozilla\\Firefox\\PreXULSkeletonUISettings",
|
||||
"enabled"
|
||||
);
|
||||
is(enabled, 0, "Pre-XUL skeleton UI is disabled in the Windows registry");
|
||||
});
|
||||
|
||||
add_task(async function testWritesSizeValuesOnChange() {
|
||||
// Enable the skeleton UI, since if it's disabled we won't persist the size values
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.startup.preXulSkeletonUI", true]],
|
||||
});
|
||||
|
||||
const regKeys = [
|
||||
"width",
|
||||
"height",
|
||||
"screenX",
|
||||
"screenY",
|
||||
"cssToDevPixelScaling",
|
||||
];
|
||||
|
||||
// Remove all of the registry values to ensure old tests aren't giving us false
|
||||
// positives
|
||||
for (let key of regKeys) {
|
||||
WindowsRegistry.removeRegKey(
|
||||
Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
||||
"Software\\Mozilla\\Firefox\\PreXULSkeletonUISettings",
|
||||
key
|
||||
);
|
||||
}
|
||||
|
||||
const win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
for (let key of regKeys) {
|
||||
let value = readRegKeyExtended(
|
||||
Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
||||
"Software\\Mozilla\\Firefox\\PreXULSkeletonUISettings",
|
||||
key
|
||||
);
|
||||
ok(
|
||||
value,
|
||||
`Skeleton UI registry values should have a non-zero value for ${key}`
|
||||
);
|
||||
if (value.length) {
|
||||
let hasNonZero = false;
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
hasNonZero = hasNonZero || value[i];
|
||||
}
|
||||
ok(hasNonZero, `Value should have non-zero components for ${key}`);
|
||||
}
|
||||
}
|
||||
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
|
@ -49,6 +49,7 @@ BROWSER_CHROME_MANIFESTS += [
|
|||
'content/test/sanitize/browser.ini',
|
||||
'content/test/sidebar/browser.ini',
|
||||
'content/test/siteIdentity/browser.ini',
|
||||
'content/test/startup/browser.ini',
|
||||
'content/test/static/browser.ini',
|
||||
'content/test/statuspanel/browser.ini',
|
||||
'content/test/sync/browser.ini',
|
||||
|
|
Загрузка…
Ссылка в новой задаче