Bug 1599070 - Replace references to textbox.reset(). r=Standard8 a=pascalc
authorTim Nguyen <ntim.bugs@gmail.com>
Wed, 27 Nov 2019 17:36:13 +0000
changeset 563493 20b673a3bcd7678de723fcbc2fd729b183e00593
parent 563492 8ef3650711add852abca2661f6eb43ecc9f53d28
child 563494 9aaa2cc3ad5d439793ad13b24ae06786cbf82bf8
push id2201
push usershindli@mozilla.com
push dateThu, 28 Nov 2019 10:02:20 +0000
treeherdermozilla-release@9aaa2cc3ad5d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, pascalc
bugs1599070
milestone71.0
Bug 1599070 - Replace references to textbox.reset(). r=Standard8 a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D54742
browser/components/places/content/places.js
browser/modules/Sanitizer.jsm
toolkit/content/tests/chrome/test_textbox_search.xul
toolkit/content/widgets/search-textbox.js
--- a/browser/components/places/content/places.js
+++ b/browser/components/places/content/places.js
@@ -372,17 +372,21 @@ var PlacesOrganizer = {
     if (placeURI == this._cachedLeftPaneSelectedURI) {
       return;
     }
     this._cachedLeftPaneSelectedURI = placeURI;
 
     // At this point, resetSearchBox is true, because the left pane selection
     // has changed; otherwise we would have returned earlier.
 
-    PlacesSearchBox.searchFilter.reset();
+    let input = PlacesSearchBox.searchFilter;
+    input.value = "";
+    try {
+      input.editor.transactionManager.clear();
+    } catch (e) {}
     this._setSearchScopeForNode(node);
     this.updateDetailsPane();
   },
 
   /**
    * Sets the search scope based on aNode's properties.
    * @param   aNode
    *          the node to set up scope from
--- a/browser/modules/Sanitizer.jsm
+++ b/browser/modules/Sanitizer.jsm
@@ -406,23 +406,24 @@ var Sanitizer = {
         TelemetryStopwatch.start("FX_SANITIZE_FORMDATA", refObj);
         try {
           // Clear undo history of all search bars.
           for (let currentWindow of Services.wm.getEnumerator(
             "navigator:browser"
           )) {
             let currentDocument = currentWindow.document;
 
-            // searchBar.textbox may not exist due to the search bar binding
-            // not having been constructed yet if the search bar is in the
-            // overflow or menu panel. It won't have a value or edit history in
-            // that case.
+            // searchBar may not exist if it's in the customize mode.
             let searchBar = currentDocument.getElementById("searchbar");
-            if (searchBar && searchBar.textbox) {
-              searchBar.textbox.reset();
+            if (searchBar) {
+              let input = searchBar.textbox;
+              input.value = "";
+              try {
+                input.editor.transactionManager.clear();
+              } catch (e) {}
             }
 
             let tabBrowser = currentWindow.gBrowser;
             if (!tabBrowser) {
               // No tab browser? This means that it's too early during startup (typically,
               // Session Restore hasn't completed yet). Since we don't have find
               // bars at that stage and since Session Restore will not restore
               // find bars further down during startup, we have nothing to clear.
--- a/toolkit/content/tests/chrome/test_textbox_search.xul
+++ b/toolkit/content/tests/chrome/test_textbox_search.xul
@@ -57,20 +57,20 @@ function doTests() {
   }
 
   iconClick(searchIcon);
   is(textbox.getAttribute("focused"), "true", "clicking the search icon focuses the textbox");
 
   textbox.value = "foo";
   is(icons.selectedPanel, clearIcon, "clear icon is displayed when setting a value");
 
-  textbox.reset();
+  textbox.value = "";
   is(textbox.defaultValue, "", "defaultValue is empty");
   is(textbox.value, "", "reset method clears the textbox");
-  is(icons.selectedPanel, searchIcon, "search icon is displayed after textbox.reset()");
+  is(icons.selectedPanel, searchIcon, "search icon is displayed after clearing value");
 
   textbox.value = "foo";
   gExpectedValue = "";
   iconClick(clearIcon);
   is(textbox.value, "", "clicking the clear icon clears the textbox");
   ok(gExpectedValue == null, "search triggered when clearing the textbox with the clear icon");
 
   textbox.value = "foo";
--- a/toolkit/content/widgets/search-textbox.js
+++ b/toolkit/content/widgets/search-textbox.js
@@ -196,26 +196,16 @@
       }
       return val;
     }
 
     get disabled() {
       return this.inputField.disabled;
     }
 
-    reset() {
-      this.value = this.defaultValue;
-      // XXX: Is this still needed ?
-      try {
-        this.editor.transactionManager.clear();
-        return true;
-      } catch (e) {}
-      return false;
-    }
-
     _fireCommand(me) {
       if (me._timer) {
         clearTimeout(me._timer);
       }
       me._timer = null;
       me.doCommand();
     }