Bug 1434210 - [2.0] Trim selection text for search. r=snorp, a=lizzard
authorEugen Sawin <esawin@mozilla.com>
Fri, 09 Feb 2018 21:24:53 +0100
changeset 454975 7a29ddefeab9bf4ad5d798a60b17957ea6cee7d3
parent 454974 4442114ced5703d0d322f3e6db9de51f1a6a02ab
child 454976 45c1f99b1b86dcdb6a7c1d28724749f2f0b79163
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp, lizzard
bugs1434210
milestone59.0
Bug 1434210 - [2.0] Trim selection text for search. r=snorp, a=lizzard
mobile/android/modules/ActionBarHandler.jsm
--- a/mobile/android/modules/ActionBarHandler.jsm
+++ b/mobile/android/modules/ActionBarHandler.jsm
@@ -6,16 +6,17 @@
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 this.EXPORTED_SYMBOLS = ["ActionBarHandler"];
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
+  BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
   EventDispatcher: "resource://gre/modules/Messaging.jsm",
   GeckoViewUtils: "resource://gre/modules/GeckoViewUtils.jsm",
   PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
   Services: "resource://gre/modules/Services.jsm",
   Snackbars: "resource://gre/modules/Snackbars.jsm",
   UITelemetry: "resource://gre/modules/UITelemetry.jsm",
 });
 
@@ -557,17 +558,17 @@ var ActionBarHandler = {
       selector: {
         matches: function(element, win) {
           // Allow if selected text exists.
           return (ActionBarHandler._getSelectedText().length > 0);
         },
       },
 
       action: function(element, win) {
-        let selectedText = ActionBarHandler._getSelectedText();
+        let selectedText = BrowserUtils.trimSelection(ActionBarHandler._getSelectedText());
         ActionBarHandler._uninit();
 
         // Set current tab as parent of new tab,
         // and set new tab as private if the parent is.
         let searchSubmission = Services.search.defaultEngine.getSubmission(selectedText);
         let chrome = GeckoViewUtils.getChromeWindow(win);
         if (chrome.BrowserApp && chrome.BrowserApp.selectedTab && chrome.BrowserApp.addTab) {
           let parent = chrome.BrowserApp.selectedTab;