Bug 1443229 - follow-up: use correct checkbox state, r?jaws
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
--- a/browser/components/preferences/in-content/search.js
+++ b/browser/components/preferences/in-content/search.js
@@ -61,17 +61,17 @@ var gSearchPane = {
let suggestsPref = Preferences.get("browser.search.suggest.enabled");
let urlbarSuggestsPref = Preferences.get("browser.urlbar.suggest.searches");
let updateSuggestionCheckboxes = this._updateSuggestionCheckboxes.bind(this);
suggestsPref.on("change", updateSuggestionCheckboxes);
urlbarSuggestsPref.on("change", updateSuggestionCheckboxes);
let urlbarSuggests = document.getElementById("urlBarSuggestion");
urlbarSuggests.addEventListener("command", () => {
- urlbarSuggestsPref.value = !urlbarSuggests.checked;
+ urlbarSuggestsPref.value = urlbarSuggests.checked;
});
this._initShowSearchSuggestionsFirst();
this._updateSuggestionCheckboxes();
},
_initShowSearchSuggestionsFirst() {
this._urlbarSuggestionsPosPref = Preferences.get("browser.urlbar.matchBuckets");
--- a/browser/components/preferences/in-content/tests/browser_searchsuggestions.js
+++ b/browser/components/preferences/in-content/tests/browser_searchsuggestions.js
@@ -14,23 +14,23 @@ add_task(async function() {
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);
- urlbarBox.doCommand();
+ 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);
- urlbarBox.doCommand();
+ 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");