зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1517213 - Part 2 - Unify which preferences are used for tests. r=bgrins
Differential Revision: https://phabricator.services.mozilla.com/D15570 --HG-- extra : rebase_source : 18241513d31c883b83d5e5e3ddbaa9b93a629b9e extra : source : 8dcd5d5e815ddea060c89a7cffd2d075aadf8ab2
This commit is contained in:
Родитель
4a00b6c301
Коммит
ab65ea678c
|
@ -4,7 +4,8 @@
|
|||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["random.user.pref", "chrome://test/locale/testing.properties"],
|
||||
["test.aboutconfig.userValueLikeLocalized",
|
||||
"chrome://test/locale/testing.properties"],
|
||||
],
|
||||
});
|
||||
});
|
||||
|
@ -18,20 +19,18 @@ add_task(async function test_load_title() {
|
|||
add_task(async function test_load_settings() {
|
||||
await AboutConfigTest.withNewTab(async function() {
|
||||
// Test if page contains elements.
|
||||
Assert.ok(this.getRow("plugins.testmode"));
|
||||
Assert.ok(this.getRow("dom.vr.enabled"));
|
||||
Assert.ok(this.getRow("accessibility.AOM.enabled"));
|
||||
Assert.equal(this.getRow(PREF_NUMBER_DEFAULT_ZERO).value, 0);
|
||||
Assert.equal(this.getRow(PREF_STRING_DEFAULT_EMPTY).value, "");
|
||||
|
||||
// Test if the modified state is displayed for the right prefs.
|
||||
let prefArray = Services.prefs.getChildList("");
|
||||
let nameOfEdited = prefArray.find(
|
||||
name => Services.prefs.prefHasUserValue(name));
|
||||
let nameOfDefault = prefArray.find(
|
||||
name => !Services.prefs.prefHasUserValue(name));
|
||||
Assert.ok(!this.getRow(nameOfDefault).hasClass("has-user-value"));
|
||||
Assert.ok(this.getRow(nameOfEdited).hasClass("has-user-value"));
|
||||
Assert.ok(!this.getRow(PREF_BOOLEAN_DEFAULT_TRUE)
|
||||
.hasClass("has-user-value"));
|
||||
Assert.ok(this.getRow(PREF_BOOLEAN_USERVALUE_TRUE)
|
||||
.hasClass("has-user-value"));
|
||||
|
||||
// Test to see if values are localized.
|
||||
// Test to see if values are localized, sampling from different files. If
|
||||
// any of these are removed or their value changes, just update the value
|
||||
// here or point to a different preference in the same file.
|
||||
Assert.equal(this.getRow("font.language.group").value, "x-western");
|
||||
Assert.equal(this.getRow("intl.ellipsis").value, "\u2026");
|
||||
Assert.equal(
|
||||
|
@ -40,12 +39,11 @@ add_task(async function test_load_settings() {
|
|||
|
||||
// Test to see if user created value is not empty string when it matches
|
||||
// /^chrome:\/\/.+\/locale\/.+\.properties/.
|
||||
Assert.equal(this.getRow("random.user.pref").value,
|
||||
Assert.equal(this.getRow("test.aboutconfig.userValueLikeLocalized").value,
|
||||
"chrome://test/locale/testing.properties");
|
||||
|
||||
// Test to see if empty string when value matches
|
||||
// /^chrome:\/\/.+\/locale\/.+\.properties/ and an exception is thrown.
|
||||
Assert.equal(this.getRow("gecko.handlerService.schemes.irc.1.name").value,
|
||||
"");
|
||||
Assert.equal(this.getRow(PREF_STRING_LOCALIZED_MISSING).value, "");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,9 +11,9 @@ add_task(async function setup() {
|
|||
});
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
Services.prefs.clearUserPref("accessibility.typeaheadfind.autostart");
|
||||
Services.prefs.clearUserPref("accessibility.typeaheadfind.soundURL");
|
||||
Services.prefs.clearUserPref("accessibility.typeaheadfind.casesensitive");
|
||||
Services.prefs.clearUserPref(PREF_BOOLEAN_DEFAULT_TRUE);
|
||||
Services.prefs.clearUserPref(PREF_NUMBER_DEFAULT_ZERO);
|
||||
Services.prefs.clearUserPref(PREF_STRING_DEFAULT_EMPTY);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -51,25 +51,28 @@ add_task(async function test_delete_user_pref() {
|
|||
});
|
||||
|
||||
add_task(async function test_reset_user_pref() {
|
||||
await SpecialPowers.pushPrefEnv({"set": [["browser.autofocus", false]]});
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
[PREF_BOOLEAN_DEFAULT_TRUE, false],
|
||||
],
|
||||
});
|
||||
|
||||
await AboutConfigTest.withNewTab(async function() {
|
||||
let testPref = "browser.autofocus";
|
||||
// Click reset.
|
||||
let row = this.getRow(testPref);
|
||||
let row = this.getRow(PREF_BOOLEAN_DEFAULT_TRUE);
|
||||
row.resetColumnButton.click();
|
||||
// Check new layout and reset.
|
||||
Assert.ok(!row.hasClass("has-user-value"));
|
||||
Assert.ok(!row.resetColumnButton);
|
||||
Assert.ok(!Services.prefs.prefHasUserValue(testPref));
|
||||
Assert.equal(this.getRow(testPref).value, "" + Preferences.get(testPref));
|
||||
Assert.ok(!Services.prefs.prefHasUserValue(PREF_BOOLEAN_DEFAULT_TRUE));
|
||||
Assert.equal(this.getRow(PREF_BOOLEAN_DEFAULT_TRUE).value, "true");
|
||||
|
||||
// Search for nothing to test gPrefArray
|
||||
this.search();
|
||||
row = this.getRow(testPref);
|
||||
row = this.getRow(PREF_BOOLEAN_DEFAULT_TRUE);
|
||||
Assert.ok(!row.hasClass("has-user-value"));
|
||||
Assert.ok(!row.resetColumnButton);
|
||||
Assert.equal(this.getRow(testPref).value, "" + Preferences.get(testPref));
|
||||
Assert.equal(this.getRow(PREF_BOOLEAN_DEFAULT_TRUE).value, "true");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -78,7 +81,7 @@ add_task(async function test_modify() {
|
|||
// Test toggle for boolean prefs.
|
||||
for (let nameOfBoolPref of [
|
||||
"test.aboutconfig.modify.boolean",
|
||||
"accessibility.typeaheadfind.autostart",
|
||||
PREF_BOOLEAN_DEFAULT_TRUE,
|
||||
]) {
|
||||
let row = this.getRow(nameOfBoolPref);
|
||||
// Do this a two times to reset the pref.
|
||||
|
@ -113,8 +116,8 @@ add_task(async function test_modify() {
|
|||
for (let prefName of [
|
||||
"test.aboutconfig.modify.string",
|
||||
"test.aboutconfig.modify.number",
|
||||
"accessibility.typeaheadfind.soundURL",
|
||||
"accessibility.typeaheadfind.casesensitive",
|
||||
PREF_NUMBER_DEFAULT_ZERO,
|
||||
PREF_STRING_DEFAULT_EMPTY,
|
||||
]) {
|
||||
row = this.getRow(prefName);
|
||||
// Activate edit and check displaying.
|
||||
|
|
|
@ -1,50 +1,53 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const PREF_STRING_NO_DEFAULT = "test.aboutconfig.a";
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["test.aboutconfig.a", "some value"],
|
||||
[PREF_STRING_NO_DEFAULT, "some value"],
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_locked() {
|
||||
registerCleanupFunction(() => {
|
||||
Services.prefs.unlockPref("browser.search.searchEnginesURL");
|
||||
Services.prefs.unlockPref("test.aboutconfig.a");
|
||||
Services.prefs.unlockPref("accessibility.AOM.enabled");
|
||||
Services.prefs.unlockPref(PREF_STRING_DEFAULT_NOTEMPTY);
|
||||
Services.prefs.unlockPref(PREF_BOOLEAN_DEFAULT_TRUE);
|
||||
Services.prefs.unlockPref(PREF_STRING_NO_DEFAULT);
|
||||
});
|
||||
|
||||
Services.prefs.lockPref("browser.search.searchEnginesURL");
|
||||
Services.prefs.lockPref("test.aboutconfig.a");
|
||||
Services.prefs.lockPref("accessibility.AOM.enabled");
|
||||
Services.prefs.lockPref(PREF_STRING_DEFAULT_NOTEMPTY);
|
||||
Services.prefs.lockPref(PREF_BOOLEAN_DEFAULT_TRUE);
|
||||
Services.prefs.lockPref(PREF_STRING_NO_DEFAULT);
|
||||
|
||||
await AboutConfigTest.withNewTab(async function() {
|
||||
// Test locked default string pref.
|
||||
let lockedPref = this.getRow("browser.search.searchEnginesURL");
|
||||
let lockedPref = this.getRow(PREF_STRING_DEFAULT_NOTEMPTY);
|
||||
Assert.ok(lockedPref.hasClass("locked"));
|
||||
Assert.equal(lockedPref.value, "https://addons.mozilla.org/%LOCALE%/firefox/search-engines/");
|
||||
Assert.equal(lockedPref.value, PREF_STRING_DEFAULT_NOTEMPTY_VALUE);
|
||||
Assert.ok(lockedPref.editColumnButton.classList.contains("button-edit"));
|
||||
Assert.ok(lockedPref.editColumnButton.disabled);
|
||||
|
||||
// Test locked default boolean pref.
|
||||
lockedPref = this.getRow("accessibility.AOM.enabled");
|
||||
lockedPref = this.getRow(PREF_BOOLEAN_DEFAULT_TRUE);
|
||||
Assert.ok(lockedPref.hasClass("locked"));
|
||||
Assert.equal(lockedPref.value, "false");
|
||||
Assert.equal(lockedPref.value, "true");
|
||||
Assert.ok(lockedPref.editColumnButton.classList.contains("button-toggle"));
|
||||
Assert.ok(lockedPref.editColumnButton.disabled);
|
||||
|
||||
// Test locked user added pref.
|
||||
lockedPref = this.getRow("test.aboutconfig.a");
|
||||
lockedPref = this.getRow(PREF_STRING_NO_DEFAULT);
|
||||
Assert.ok(lockedPref.hasClass("locked"));
|
||||
Assert.equal(lockedPref.value, "");
|
||||
Assert.ok(lockedPref.editColumnButton.classList.contains("button-edit"));
|
||||
Assert.ok(lockedPref.editColumnButton.disabled);
|
||||
|
||||
// Test pref not locked
|
||||
let unlockedPref = this.getRow("accessibility.indicator.enabled");
|
||||
// Test pref not locked.
|
||||
let unlockedPref = this.getRow(PREF_BOOLEAN_USERVALUE_TRUE);
|
||||
Assert.ok(!unlockedPref.hasClass("locked"));
|
||||
Assert.equal(unlockedPref.value, "false");
|
||||
Assert.equal(unlockedPref.value, "true");
|
||||
Assert.ok(unlockedPref.editColumnButton.classList.contains("button-toggle"));
|
||||
Assert.ok(!unlockedPref.editColumnButton.disabled);
|
||||
});
|
||||
|
|
|
@ -5,6 +5,18 @@
|
|||
|
||||
ChromeUtils.import("resource://gre/modules/Preferences.jsm", this);
|
||||
|
||||
// List of default preferences that can be used for tests, chosen because they
|
||||
// have little or no side-effects when they are modified for a brief time. If
|
||||
// any of these preferences are removed or their default state changes, just
|
||||
// update the constant to point to a different preference with the same default.
|
||||
const PREF_BOOLEAN_DEFAULT_TRUE = "accessibility.typeaheadfind.manual";
|
||||
const PREF_BOOLEAN_USERVALUE_TRUE = "browser.dom.window.dump.enabled";
|
||||
const PREF_NUMBER_DEFAULT_ZERO = "accessibility.typeaheadfind.casesensitive";
|
||||
const PREF_STRING_DEFAULT_EMPTY = "browser.helperApps.neverAsk.openFile";
|
||||
const PREF_STRING_DEFAULT_NOTEMPTY = "accessibility.typeaheadfind.soundURL";
|
||||
const PREF_STRING_DEFAULT_NOTEMPTY_VALUE = "beep";
|
||||
const PREF_STRING_LOCALIZED_MISSING = "gecko.handlerService.schemes.irc.1.name";
|
||||
|
||||
class AboutConfigRowTest {
|
||||
constructor(element) {
|
||||
this.element = element;
|
||||
|
|
Загрузка…
Ссылка в новой задаче