Backed out changeset e9e24264e20d (bug 1547301) for bc failures on UrlbarInput.jsm. CLOSED TREE
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Wed, 19 Jun 2019 02:28:41 +0300
changeset 479146 96b75db0403d0a060e5fe7518320e077896b3ea8
parent 479145 88ac974e3453cb29f1c946bbb044654b18c4c973
child 479147 d4cb35f250617dfb8e018f77e4bc533426a09515
push id36170
push usercbrindusan@mozilla.com
push dateWed, 19 Jun 2019 03:56:45 +0000
treeherdermozilla-central@5f0f37756053 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1547301
milestone69.0a1
backs oute9e24264e20ded4b1c5c89e1470f1451fd3171d4
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
Backed out changeset e9e24264e20d (bug 1547301) for bc failures on UrlbarInput.jsm. CLOSED TREE
browser/app/profile/firefox.js
browser/components/extensions/parent/ext-urlbar.js
browser/components/extensions/schemas/urlbar.json
browser/components/extensions/test/xpcshell/test_ext_urlbar.js
browser/components/urlbar/UrlbarInput.jsm
browser/components/urlbar/UrlbarPrefs.jsm
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -326,18 +326,16 @@ pref("browser.urlbar.openintab", false);
 
 // This is disabled until Bug 1340663 figures out the remaining requirements.
 pref("browser.urlbar.usepreloadedtopurls.enabled", false);
 pref("browser.urlbar.usepreloadedtopurls.expire_days", 14);
 
 // Enable the new Address Bar code.
 pref("browser.urlbar.quantumbar", true);
 
-pref("browser.urlbar.openViewOnFocus", false);
-
 pref("browser.altClickSave", false);
 
 // Enable logging downloads operations to the Console.
 pref("browser.download.loglevel", "Error");
 
 // Number of milliseconds to wait for the http headers (and thus
 // the Content-Disposition filename) before giving up and falling back to
 // picking a filename without that info in hand so that the user sees some
--- a/browser/components/extensions/parent/ext-urlbar.js
+++ b/browser/components/extensions/parent/ext-urlbar.js
@@ -1,27 +1,14 @@
 "use strict";
 
 XPCOMUtils.defineLazyModuleGetters(this, {
-  UrlbarPrefs: "resource:///modules/UrlbarPrefs.jsm",
   UrlbarProvidersManager: "resource:///modules/UrlbarProvidersManager.jsm",
 });
 
-var {ExtensionPreferencesManager} = ChromeUtils.import("resource://gre/modules/ExtensionPreferencesManager.jsm");
-var {getSettingsAPI} = ExtensionPreferencesManager;
-
-ExtensionPreferencesManager.addSetting("openViewOnFocus", {
-  prefNames: [
-    "browser.urlbar.openViewOnFocus",
-  ],
-  setCallback(value) {
-    return {[this.prefNames[0]]: value};
-  },
-});
-
 this.urlbar = class extends ExtensionAPI {
   getAPI(context) {
     return {
       urlbar: {
         /**
          * Event fired before a search starts, to get the provider behavior.
          */
         onQueryReady: new EventManager(context, "urlbar.onQueryReady", (fire, name) => {
@@ -31,18 +18,12 @@ this.urlbar = class extends ExtensionAPI
                 return Promise.resolve("inactive");
               }
               return fire.async(queryContext);
             });
           return () => {
             UrlbarProvidersManager.removeExtensionListener(name, "queryready");
           };
         }).api(),
-
-        openViewOnFocus: getSettingsAPI(
-          context.extension.id, "openViewOnFocus",
-          () => {
-            return UrlbarPrefs.get("openViewOnFocus");
-          }),
       },
     };
   }
 };
--- a/browser/components/extensions/schemas/urlbar.json
+++ b/browser/components/extensions/schemas/urlbar.json
@@ -50,22 +50,16 @@
             "description": "List of acceptable SourceType to return.",
             "items": {
               "$ref": "SourceType"
             }
           }
         }
       }
     ],
-    "properties": {
-      "openViewOnFocus": {
-        "$ref": "types.Setting",
-        "description": "Enables or disables the open-view-on-focus mode."
-      }
-    },
     "events": [
       {
         "name": "onQueryReady",
         "type": "function",
         "description": "Fired before starting a search to get the provider's behavior.",
         "parameters": [
           {
             "name": "context",
--- a/browser/components/extensions/test/xpcshell/test_ext_urlbar.js
+++ b/browser/components/extensions/test/xpcshell/test_ext_urlbar.js
@@ -1,27 +1,16 @@
 "use strict";
 
-const {AddonTestUtils} = ChromeUtils.import("resource://testing-common/AddonTestUtils.jsm");
-
 XPCOMUtils.defineLazyModuleGetters(this, {
   UrlbarController: "resource:///modules/UrlbarController.jsm",
-  UrlbarPrefs: "resource:///modules/UrlbarPrefs.jsm",
   UrlbarProvidersManager: "resource:///modules/UrlbarProvidersManager.jsm",
   UrlbarQueryContext: "resource:///modules/UrlbarUtils.jsm",
 });
 
-AddonTestUtils.init(this);
-AddonTestUtils.overrideCertDB();
-AddonTestUtils.createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
-
-add_task(async function startup() {
-  await AddonTestUtils.promiseStartupManager();
-});
-
 add_task(async function test_urlbar_without_urlbar_permission() {
   let ext = ExtensionTestUtils.loadExtension({
     isPrivileged: true,
     background() {
       browser.test.assertEq(browser.urlbar, undefined,
                             "'urlbar' permission is required");
     },
   });
@@ -185,36 +174,8 @@ add_task(async function test_registerPro
   }
 
   await ext.unload();
 
   // Sanity check the providers.
   Assert.deepEqual(UrlbarProvidersManager.providers, providers,
                    "Should return to the default providers");
 });
-
-add_task(async function test_setOpenViewOnFocus() {
-  let getPrefValue = () => UrlbarPrefs.get("openViewOnFocus");
-
-  Assert.equal(getPrefValue(), false,
-               "Open-view-on-focus mode should be disabled by default");
-
-  let ext = ExtensionTestUtils.loadExtension({
-    manifest: {
-      permissions: ["urlbar"],
-    },
-    isPrivileged: true,
-    incognitoOverride: "spanning",
-    useAddonManager: "temporary",
-    background() {
-      browser.urlbar.openViewOnFocus.set({value: true});
-    },
-  });
-  await ext.startup();
-
-  Assert.equal(getPrefValue(), true,
-               "Successfully enabled the open-view-on-focus mode");
-
-  await ext.unload();
-
-  Assert.equal(getPrefValue(), false,
-               "Open-view-on-focus mode should be reset after unloading the add-on");
-});
--- a/browser/components/urlbar/UrlbarInput.jsm
+++ b/browser/components/urlbar/UrlbarInput.jsm
@@ -44,17 +44,16 @@ class UrlbarInput {
    *   Intended for use in unit tests only.
    */
   constructor(options = {}) {
     this.textbox = options.textbox;
     this.textbox.clickSelectsAll = UrlbarPrefs.get("clickSelectsAll");
 
     this.window = this.textbox.ownerGlobal;
     this.document = this.window.document;
-    this.window.addEventListener("unload", this);
 
     // Create the panel to contain results.
     // In the future this may be moved to the view, so it can customize
     // the container element.
     let MozXULElement = this.window.MozXULElement;
     // TODO Bug 1535659: urlbarView-body-inner possibly doesn't need the
     // role="combobox" once bug 1513337 is fixed.
     this.document.getElementById("mainPopupSet").appendChild(
@@ -93,16 +92,17 @@ class UrlbarInput {
     this.isPrivate = PrivateBrowsingUtils.isWindowPrivate(this.window);
     this.lastQueryContextPromise = Promise.resolve();
     this._actionOverrideKeyCount = 0;
     this._autofillPlaceholder = "";
     this._lastSearchString = "";
     this._resultForCurrentValue = null;
     this._suppressStartQuery = false;
     this._untrimmedValue = "";
+    this._openViewOnFocus = false;
 
     // This exists only for tests.
     this._enableAutofillPlaceholder = true;
 
     // Forward textbox methods and properties.
     const METHODS = ["addEventListener", "removeEventListener",
       "getAttribute", "hasAttribute",
       "setAttribute", "removeAttribute", "toggleAttribute",
@@ -174,26 +174,22 @@ class UrlbarInput {
     this._initPasteAndGo();
 
     // Tracks IME composition.
     this._compositionState = UrlbarUtils.COMPOSITION.NONE;
     this._compositionClosedPopup = false;
 
     this.editor.QueryInterface(Ci.nsIPlaintextEditor).newlineHandling =
       Ci.nsIPlaintextEditor.eNewlinesStripSurroundingWhitespace;
-
-    this._setOpenViewOnFocus();
-    Services.prefs.addObserver("browser.urlbar.openViewOnFocus", this);
   }
 
   /**
    * Uninitializes this input object, detaching it from the inputField.
    */
   uninit() {
-    this.window.removeEventListener("unload", this);
     for (let name of this._inputFieldEvents) {
       this.inputField.removeEventListener(name, this);
     }
     this.removeEventListener("mousedown", this);
 
     this.view.panel.remove();
 
     // When uninit is called due to exiting the browser's customize mode,
@@ -210,18 +206,16 @@ class UrlbarInput {
     } catch (ex) {
       Cu.reportError("Leaking UrlbarInput._copyCutController! You should have called removeCopyCutController!");
     }
 
     if (Object.getOwnPropertyDescriptor(this, "valueFormatter").get) {
       this.valueFormatter.uninit();
     }
 
-    Services.prefs.removeObserver("browser.urlbar.openViewOnFocus", this);
-
     delete this.document;
     delete this.window;
     delete this.eventBufferer;
     delete this.valueFormatter;
     delete this.panel;
     delete this.view;
     delete this.controller;
     delete this.textbox;
@@ -298,24 +292,16 @@ class UrlbarInput {
 
     try {
       return Services.uriFixup.createExposableURI(uri);
     } catch (ex) {}
 
     return uri;
   }
 
-  observe(subject, topic, data) {
-    switch (data) {
-      case "browser.urlbar.openViewOnFocus":
-        this._setOpenViewOnFocus();
-        break;
-    }
-  }
-
   /**
    * Passes DOM events for the textbox to the _on_<event type> methods.
    * @param {Event} event
    *   DOM event from the <textbox>.
    */
   handleEvent(event) {
     let methodName = "_on_" + event.type;
     if (methodName in this) {
@@ -730,25 +716,22 @@ class UrlbarInput {
   set value(val) {
     return this._setValue(val, true);
   }
 
   get openViewOnFocus() {
     return this._openViewOnFocus;
   }
 
-  // Private methods below.
+  set openViewOnFocus(val) {
+    this._openViewOnFocus = val;
+    this.toggleAttribute("hidedropmarker", val);
+  }
 
-  _setOpenViewOnFocus() {
-    // FIXME: Not using UrlbarPrefs because its pref observer may run after
-    // this call, so we'd get the previous openViewOnFocus value here. This
-    // can be cleaned up after bug 1560013.
-    this._openViewOnFocus = Services.prefs.getBoolPref("browser.urlbar.openViewOnFocus");
-    this.toggleAttribute("hidedropmarker", this._openViewOnFocus);
-  }
+  // Private methods below.
 
   _setValue(val, allowTrim) {
     this._untrimmedValue = val;
 
     let originalUrl = ReaderMode.getOriginalUrlObjectForDisplay(val);
     if (originalUrl) {
       val = originalUrl.displaySpec;
     }
@@ -1563,22 +1546,16 @@ class UrlbarInput {
       // For safety reasons, in the drop case we don't want to immediately show
       // the the dropped value, instead we want to keep showing the current page
       // url until an onLocationChange happens.
       // See the handling in URLBarSetURI for further details.
       this.window.gBrowser.userTypedValue = null;
       this.window.URLBarSetURI(null, true);
     }
   }
-
-  _on_unload() {
-    // FIXME: This is needed because uninit calls removePrefObserver. We can
-    // remove this once UrlbarPrefs has support for listeners. (bug 1560013)
-    this.uninit();
-  }
 }
 
 /**
  * Tries to extract droppable data from a DND event.
  * @param {Event} event The DND event to examine.
  * @returns {URL|string|null}
  *          null if there's a security reason for which we should do nothing.
  *          A URL object if it's a value we can load.
--- a/browser/components/urlbar/UrlbarPrefs.jsm
+++ b/browser/components/urlbar/UrlbarPrefs.jsm
@@ -95,18 +95,16 @@ const PREF_URLBAR_DEFAULTS = new Map([
 
   // One-off search buttons enabled status.
   ["oneOffSearches", false],
 
   // Whether addresses and search results typed into the address bar
   // should be opened in new tabs by default.
   ["openintab", false],
 
-  ["openViewOnFocus", false],
-
   // Whether the quantum bar is enabled.
   ["quantumbar", false],
 
   // Whether speculative connections should be enabled.
   ["speculativeConnect.enabled", true],
 
   // Results will include the user's bookmarks when this is true.
   ["suggest.bookmark", true],