Bug 1443229 - follow-up: use correct checkbox state, r?jaws draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 06 Mar 2018 15:00:12 +0000
changeset 763727 f33c52dc90a520945be66262a8ababa289c1a1e8
parent 763635 a007dd56b9947a93c276e82275d7065db1949c9e
push id101536
push userbmo:gijskruitbosch+bugs@gmail.com
push dateTue, 06 Mar 2018 15:40:33 +0000
reviewersjaws
bugs1443229
milestone60.0a1
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
browser/components/preferences/in-content/search.js
browser/components/preferences/in-content/tests/browser_searchsuggestions.js
--- 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");