Bug 1181781 - Fix ReferenceError: target is not defined when performing a paste-and-search. r=adw, a=sledru
authorNihanth Subramanya <nhnt11@gmail.com>
Thu, 09 Jul 2015 01:13:35 -0400
changeset 281473 9283521d2c15252e153a0ea04706e86debdc1a7c
parent 281472 b99d8bfe7e7753cef1836995d6ba631137c1f661
child 281474 8cfc3238ee5e0827b237a75e55cbd5367f97e4b1
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersadw, sledru
bugs1181781
milestone41.0a2
Bug 1181781 - Fix ReferenceError: target is not defined when performing a paste-and-search. r=adw, a=sledru
browser/components/search/content/search.xml
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -502,37 +502,39 @@
           }
 
           let selection = this.telemetrySearchDetails;
           this.doSearch(textValue, where, aEngine);
 
           if (!selection || (selection.index == -1)) {
             let source = "unknown";
             let type = "unknown";
+            let target = aEvent.originalTarget;
             if (aEvent instanceof KeyboardEvent) {
               type = "key";
               if (this._textbox.selectedButton) {
                 source = "oneoff";
               }
             } else if (aEvent instanceof MouseEvent) {
-              let target = aEvent.originalTarget;
               type = "mouse";
               if (target.classList.contains("searchbar-engine-one-off-item")) {
                 source = "oneoff";
               } else if (target.classList.contains("search-panel-header") ||
                          target.parentNode.classList.contains("search-panel-header")) {
                 source = "header";
               }
             } else if (aEvent instanceof XULCommandEvent) {
               if (target.getAttribute("anonid") == "paste-and-search") {
-                aEngine = this.currentEngine;
                 source = "paste";
               }
             }
 
+            if (!aEngine) {
+              aEngine = this.currentEngine;
+            }
             BrowserSearch.recordOneoffSearchInTelemetry(aEngine, source, type, where);
           }
 
           if (where == "tab-background")
             this.focus();
         ]]></body>
       </method>