Bug 1498878 - Implement UrlbarInput::goButton. r=adw
authorDão Gottwald <dao@mozilla.com>
Tue, 16 Oct 2018 03:06:04 +0000
changeset 489753 0329775bb9a4321441c576b01a6f851800afcf6e
parent 489752 583d689d630e68cb1f2ae5ae1e7f27f2ca28f359
child 489754 ba7c1249b79b39df4be295ed0c65a32bc7eaa932
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersadw
bugs1498878
milestone64.0a1
Bug 1498878 - Implement UrlbarInput::goButton. r=adw Differential Revision: https://phabricator.services.mozilla.com/D8670
browser/components/urlbar/UrlbarInput.jsm
--- a/browser/components/urlbar/UrlbarInput.jsm
+++ b/browser/components/urlbar/UrlbarInput.jsm
@@ -39,16 +39,17 @@ class UrlbarInput {
    *   Intended for use in unit tests only.
    */
   constructor(options = {}) {
     this.textbox = options.textbox;
     this.textbox.clickSelectsAll = UrlbarPrefs.get("clickSelectsAll");
 
     this.panel = options.panel;
     this.window = this.textbox.ownerGlobal;
+    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);
 
@@ -233,16 +234,21 @@ class UrlbarInput {
   }
 
   // Getters and Setters below.
 
   get focused() {
     return this.textbox.getAttribute("focused") == "true";
   }
 
+  get goButton() {
+    return this.document.getAnonymousElementByAttribute(this.textbox, "anonid",
+      "urlbar-go-button");
+  }
+
   get value() {
     return this.inputField.value;
   }
 
   set value(val) {
     val = this.trimValue(val);
 
     this.valueIsTyped = false;
@@ -514,17 +520,17 @@ class CopyCutController {
 
     if (command == "cmd_cut" && this.isCommandEnabled(command)) {
       let start = urlbar.selectionStart;
       let end = urlbar.selectionEnd;
       urlbar.inputField.value = urlbar.inputField.value.substring(0, start) +
                                 urlbar.inputField.value.substring(end);
       urlbar.selectionStart = urlbar.selectionEnd = start;
 
-      let event = urlbar.window.document.createEvent("UIEvents");
+      let event = urlbar.document.createEvent("UIEvents");
       event.initUIEvent("input", true, false, this.window, 0);
       urlbar.dispatchEvent(event);
 
       urlbar.window.SetPageProxyState("invalid");
     }
 
     ClipboardHelper.copyString(val);
   }