Bug 1500080 - UrlbarInput::value getter should return the untrimmed value. r=mak
authorDão Gottwald <dao@mozilla.com>
Fri, 19 Oct 2018 15:25:55 +0000
changeset 500664 23321e0768f092b7247cc14c8c54e7a0b27b13ae
parent 500663 4a81fd6046965751585ae7b85740417bb542aa04
child 500665 3fd071cc143477b440eec25e856613ae906e3c6b
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1500080
milestone64.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 1500080 - UrlbarInput::value getter should return the untrimmed value. r=mak Differential Revision: https://phabricator.services.mozilla.com/D9088
browser/components/urlbar/UrlbarInput.jsm
browser/components/urlbar/tests/browser/browser_UrlbarInput_unit.js
--- a/browser/components/urlbar/UrlbarInput.jsm
+++ b/browser/components/urlbar/UrlbarInput.jsm
@@ -47,16 +47,17 @@ class UrlbarInput {
     this.document = this.window.document;
     this.controller = options.controller || new UrlbarController({
       window: this.window,
     });
     this.view = new UrlbarView(this);
     this.valueIsTyped = false;
     this.userInitiatedFocus = false;
     this.isPrivate = PrivateBrowsingUtils.isWindowPrivate(this.window);
+    this._untrimmedValue = "";
 
     // Forward textbox methods and properties.
     const METHODS = ["addEventListener", "removeEventListener",
       "setAttribute", "hasAttribute", "removeAttribute", "getAttribute",
       "focus", "blur", "select"];
     const READ_ONLY_PROPERTIES = ["inputField", "editor"];
     const READ_WRITE_PROPERTIES = ["placeholder", "readOnly",
       "selectionStart", "selectionEnd"];
@@ -240,20 +241,22 @@ class UrlbarInput {
   }
 
   get goButton() {
     return this.document.getAnonymousElementByAttribute(this.textbox, "anonid",
       "urlbar-go-button");
   }
 
   get value() {
-    return this.inputField.value;
+    return this._untrimmedValue;
   }
 
   set value(val) {
+    this._untrimmedValue = val;
+
     val = this.trimValue(val);
 
     this.valueIsTyped = false;
     this.inputField.value = val;
     this.formatValue();
 
     // Dispatch ValueChange event for accessibility.
     let event = this.document.createEvent("Events");
@@ -422,21 +425,24 @@ class UrlbarInput {
         event.detail == 2 &&
         UrlbarPrefs.get("doubleClickSelectsAll")) {
       this.editor.selectAll();
       event.preventDefault();
     }
   }
 
   _on_input(event) {
+    let value = event.target.value;
     this.valueIsTyped = true;
+    this._untrimmedValue = value;
+    this.window.gBrowser.userTypedValue = value;
 
     // XXX Fill in lastKey, and add anything else we need.
     this.controller.startQuery(new QueryContext({
-      searchString: event.target.value,
+      searchString: value,
       lastKey: "",
       maxResults: UrlbarPrefs.get("maxRichResults"),
       isPrivate: this.isPrivate,
     }));
   }
 
   _on_select(event) {
     if (!Services.clipboard.supportsSelectionClipboard()) {
--- a/browser/components/urlbar/tests/browser/browser_UrlbarInput_unit.js
+++ b/browser/components/urlbar/tests/browser/browser_UrlbarInput_unit.js
@@ -69,16 +69,18 @@ add_task(async function setup() {
   // Open a new window, so we don't affect other tests by adding extra
   // UrbarInput wrappers around the urlbar.
   let gTestRoot = getRootDirectory(gTestPath);
 
   let win = window.openDialog(gTestRoot + "empty.xul",
                     "", "chrome");
   await BrowserTestUtils.waitForEvent(win, "load");
 
+  win.gBrowser = {};
+
   registerCleanupFunction(async () => {
     await BrowserTestUtils.closeWindow(win);
     sandbox.restore();
   });
 
   // Clone the elements into the new window, so we get exact copies without having
   // to replicate the xul.
   let doc = win.document;