forked from mirrors/gecko-dev
It seems `doCommand` runs through a different codepath than just clicking the checkbox, and as a result the outcome of the command handler is different that way. This aligns the automated test closer to what happens when you 'manually' click the checkbox, and fixes the bug in the command handler. MozReview-Commit-ID: ACxRUxB35px --HG-- extra : rebase_source : 7bc6d048d4ff6061aae6289e26f2b298820ed5ec
56 lines
2.3 KiB
JavaScript
56 lines
2.3 KiB
JavaScript
const SUGGEST_PREF_NAME = "browser.search.suggest.enabled";
|
|
const URLBAR_SUGGEST_PREF_NAME = "browser.urlbar.suggest.searches";
|
|
var original = Services.prefs.getBoolPref(SUGGEST_PREF_NAME);
|
|
|
|
registerCleanupFunction(() => {
|
|
Services.prefs.setBoolPref(SUGGEST_PREF_NAME, original);
|
|
});
|
|
|
|
// Open with suggestions enabled
|
|
add_task(async function() {
|
|
Services.prefs.setBoolPref(SUGGEST_PREF_NAME, true);
|
|
const INITIAL_URLBAR_SUGGEST_VALUE = Services.prefs.getBoolPref(URLBAR_SUGGEST_PREF_NAME);
|
|
|
|
await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
|
|
|
|
let doc = gBrowser.selectedBrowser.contentDocument;
|
|
let urlbarBox = doc.getElementById("urlBarSuggestion");
|
|
ok(!urlbarBox.disabled, "Checkbox should be enabled");
|
|
is(urlbarBox.checked, INITIAL_URLBAR_SUGGEST_VALUE,
|
|
"Checkbox should match initial pref value: " + INITIAL_URLBAR_SUGGEST_VALUE);
|
|
|
|
await BrowserTestUtils.synthesizeMouseAtCenter("#urlBarSuggestion", {}, gBrowser.selectedBrowser);
|
|
is(urlbarBox.checked, !INITIAL_URLBAR_SUGGEST_VALUE,
|
|
"Checkbox should be flipped after clicking it");
|
|
let prefValue = Services.prefs.getBoolPref(URLBAR_SUGGEST_PREF_NAME);
|
|
is(prefValue, urlbarBox.checked, "Pref should match checkbox. Pref: " + prefValue);
|
|
|
|
await BrowserTestUtils.synthesizeMouseAtCenter("#urlBarSuggestion", {}, gBrowser.selectedBrowser);
|
|
is(urlbarBox.checked, INITIAL_URLBAR_SUGGEST_VALUE,
|
|
"Checkbox should be back to initial value after clicking it");
|
|
prefValue = Services.prefs.getBoolPref(URLBAR_SUGGEST_PREF_NAME);
|
|
is(prefValue, urlbarBox.checked, "Pref should match checkbox. Pref: " + prefValue);
|
|
|
|
Services.prefs.setBoolPref(SUGGEST_PREF_NAME, false);
|
|
ok(!urlbarBox.checked, "Checkbox should now be unchecked");
|
|
ok(urlbarBox.disabled, "Checkbox should be disabled");
|
|
|
|
gBrowser.removeCurrentTab();
|
|
});
|
|
|
|
// Open with suggestions disabled
|
|
add_task(async function() {
|
|
Services.prefs.setBoolPref(SUGGEST_PREF_NAME, false);
|
|
|
|
await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true });
|
|
|
|
let doc = gBrowser.selectedBrowser.contentDocument;
|
|
let urlbarBox = doc.getElementById("urlBarSuggestion");
|
|
ok(urlbarBox.disabled, "Checkbox should be disabled");
|
|
|
|
Services.prefs.setBoolPref(SUGGEST_PREF_NAME, true);
|
|
|
|
ok(!urlbarBox.disabled, "Checkbox should be enabled");
|
|
|
|
gBrowser.removeCurrentTab();
|
|
});
|