Commit 89ee3323 authored by Marco Bonardo's avatar Marco Bonardo
Browse files

Bug 740076 - Disable autoFill when autocomplete is disabled.

r=dietrich
parent 544e344c
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -103,7 +103,8 @@ const kQueryTypeFiltered = 1;
const kTitleTagsSeparator = " \u2013 ";

const kBrowserUrlbarBranch = "browser.urlbar.";

// Toggle autocomplete.
const kBrowserUrlbarAutocompleteEnabledPref = "autocomplete.enabled";
// Toggle autoFill.
const kBrowserUrlbarAutofillPref = "autoFill";
// Whether to search only typed entries.
@@ -845,7 +846,9 @@ nsPlacesAutoComplete.prototype = {
   */
  _loadPrefs: function PAC_loadPrefs(aRegisterObserver)
  {
    this._enabled = safePrefGetter(this._prefs, "autocomplete.enabled", true);
    this._enabled = safePrefGetter(this._prefs,
                                   kBrowserUrlbarAutocompleteEnabledPref,
                                   true);
    this._matchBehavior = safePrefGetter(this._prefs,
                                         "matchBehavior",
                                         MATCH_BOUNDARY_ANYWHERE);
@@ -1301,7 +1304,7 @@ urlInlineComplete.prototype = {

  get _db()
  {
    if (!this.__db && this._autofill) {
    if (!this.__db && this._autofillEnabled) {
      this.__db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase).
                  DBConnection.clone(true);
    }
@@ -1486,9 +1489,13 @@ urlInlineComplete.prototype = {
  _loadPrefs: function UIC_loadPrefs(aRegisterObserver)
  {
    let prefBranch = Services.prefs.getBranch(kBrowserUrlbarBranch);
    this._autofill = safePrefGetter(prefBranch,
    let autocomplete = safePrefGetter(prefBranch,
                                      kBrowserUrlbarAutocompleteEnabledPref,
                                      true);
    let autofill = safePrefGetter(prefBranch,
                                  kBrowserUrlbarAutofillPref,
                                  true);
    this._autofillEnabled = autocomplete && autofill;
    this._autofillTyped = safePrefGetter(prefBranch,
                                         kBrowserUrlbarAutofillTypedPref,
                                         true);
@@ -1548,10 +1555,11 @@ urlInlineComplete.prototype = {
    }
    else if (aTopic == kPrefChanged &&
             (aData.substr(kBrowserUrlbarBranch.length) == kBrowserUrlbarAutofillPref ||
              aData.substr(kBrowserUrlbarBranch.length) == kBrowserUrlbarAutocompleteEnabledPref ||
              aData.substr(kBrowserUrlbarBranch.length) == kBrowserUrlbarAutofillTypedPref)) {
      let previousAutofillTyped = this._autofillTyped;
      this._loadPrefs();
      if (!this._autofill) {
      if (!this._autofillEnabled) {
        this.stopSearch();
        this._closeDatabase();
      }
+5 −2
Original line number Diff line number Diff line
@@ -144,9 +144,8 @@ function ensure_results(aSearchString, aExpectedValue) {
}

function run_test() {
  Services.prefs.setBoolPref("browser.urlbar.autoFill", true);
  Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", false);
  do_register_cleanup(function () {
    Services.prefs.clearUserPref("browser.urlbar.autocomplete.enabled");
    Services.prefs.clearUserPref("browser.urlbar.autoFill");
    Services.prefs.clearUserPref("browser.urlbar.autoFill.typed");
  });
@@ -155,6 +154,10 @@ function run_test() {
    let [description, searchString, expectedValue, setupFunc] = testData;
    add_test(function () {
      do_log_info(description);
      Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", true);
      Services.prefs.setBoolPref("browser.urlbar.autoFill", true);
      Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", false);

      if (setupFunc) {
        setupFunc();
      }
+24 −0
Original line number Diff line number Diff line
@@ -4,6 +4,30 @@

// Functional tests for inline autocomplete

add_autocomplete_test([
  "Check disabling autocomplete disables autofill",
  "vis",
  "vis",
  function ()
  {
    Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", false);
    addVisits({ uri: NetUtil.newURI("http://visit.mozilla.org"),
                transition: TRANSITION_TYPED });
  }
]);

add_autocomplete_test([
  "Check disabling autofill disables autofill",
  "vis",
  "vis",
  function ()
  {
    Services.prefs.setBoolPref("browser.urlbar.autoFill", false);
    addVisits({ uri: NetUtil.newURI("http://visit.mozilla.org"),
                transition: TRANSITION_TYPED });
  }
]);

add_autocomplete_test([
  "Add urls, check for correct order",
  "vis",