Bug 1524068 - Only setup autocompletion if the autocomplete config is not set. r=bgrins
authorGabriel Luong <gabriel.luong@gmail.com>
Fri, 01 Feb 2019 11:58:54 -0500
changeset 456517 550ac85a1218ca468d341655f0621c49c6d029d0
parent 456516 8a96a5d19c50801a89f4029a34d25e7faac64b43
child 456518 9fe2d9456e6bde0a51dd86132eff761dfe9607f0
push id35488
push userdvarga@mozilla.com
push dateSat, 02 Feb 2019 09:44:51 +0000
treeherdermozilla-central@d8cebb3b46cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1524068
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1524068 - Only setup autocompletion if the autocomplete config is not set. r=bgrins
devtools/client/sourceeditor/editor.js
devtools/client/styleeditor/test/browser_styleeditor_autocomplete-disabled.js
--- a/devtools/client/sourceeditor/editor.js
+++ b/devtools/client/sourceeditor/editor.js
@@ -1249,16 +1249,21 @@ Editor.prototype = {
    * Sets up autocompletion for the editor. Lazily imports the required
    * dependencies because they vary by editor mode.
    *
    * Autocompletion is special, because we don't want to automatically use
    * it just because it is preffed on (it still needs to be requested by the
    * editor), but we do want to always disable it if it is preffed off.
    */
   setupAutoCompletion: function() {
+    if (!this.config.autocomplete && !this.initializeAutoCompletion) {
+      // Do nothing since there is no autocomplete config and no autocompletion have
+      // been initialized.
+      return;
+    }
     // The autocomplete module will overwrite this.initializeAutoCompletion
     // with a mode specific autocompletion handler.
     if (!this.initializeAutoCompletion) {
       this.extend(require("./autocomplete"));
     }
 
     if (this.config.autocomplete && Services.prefs.getBoolPref(AUTOCOMPLETE)) {
       this.initializeAutoCompletion(this.config.autocompleteOpts);
--- a/devtools/client/styleeditor/test/browser_styleeditor_autocomplete-disabled.js
+++ b/devtools/client/styleeditor/test/browser_styleeditor_autocomplete-disabled.js
@@ -6,21 +6,30 @@
 // Test that autocomplete can be disabled.
 
 const TESTCASE_URI = TEST_BASE_HTTP + "autocomplete.html";
 
 // Pref which decides if CSS autocompletion is enabled in Style Editor or not.
 const AUTOCOMPLETION_PREF = "devtools.styleeditor.autocompletion-enabled";
 
 add_task(async function() {
-  Services.prefs.setBoolPref(AUTOCOMPLETION_PREF, false);
   const { ui } = await openStyleEditorForURL(TESTCASE_URI);
   const editor = await ui.editors[0].getSourceEditor();
+  editor.sourceEditor.setOption("autocomplete", false);
 
   is(editor.sourceEditor.getOption("autocomplete"), false,
      "Autocompletion option does not exist");
   ok(!editor.sourceEditor.getAutocompletionPopup(),
      "Autocompletion popup does not exist");
 });
 
+add_task(async function() {
+  Services.prefs.setBoolPref(AUTOCOMPLETION_PREF, false);
+  const { ui } = await openStyleEditorForURL(TESTCASE_URI);
+  const editor = await ui.editors[0].getSourceEditor();
+
+  is(editor.sourceEditor.getOption("autocomplete"), false,
+     "Autocompletion option does not exist");
+});
+
 registerCleanupFunction(() => {
   Services.prefs.clearUserPref(AUTOCOMPLETION_PREF);
 });