Bug 1455326 - Don't open search in new tab if current tab is blank. r?adw draft
authorMichael Kaply <mozilla@kaply.com>
Thu, 05 Jul 2018 18:05:50 -0500
changeset 814991 618f783377847c20609dcd2f620522d0bf6e2e9a
parent 814584 e8b7331398910233e3adaaed01cad6b75bb562a2
push id115395
push usermozilla@kaply.com
push dateFri, 06 Jul 2018 14:15:37 +0000
reviewersadw
bugs1455326
milestone63.0a1
Bug 1455326 - Don't open search in new tab if current tab is blank. r?adw MozReview-Commit-ID: BqjoKZ3H7Yq
browser/components/search/content/search.xml
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -276,18 +276,20 @@
               return;
             where = whereToOpenLink(aEvent, false, true);
           } else if (aForceNewTab) {
             where = "tab";
             if (Services.prefs.getBoolPref("browser.tabs.loadInBackground"))
               where += "-background";
           } else {
             var newTabPref = Services.prefs.getBoolPref("browser.search.openintab");
-            if (((aEvent instanceof KeyboardEvent) && aEvent.altKey) ^ newTabPref)
+            if (((aEvent instanceof KeyboardEvent && aEvent.altKey) ^ newTabPref) &&
+                !isTabEmpty(gBrowser.selectedTab)) {
               where = "tab";
+            }
             if ((aEvent instanceof MouseEvent) &&
                 (aEvent.button == 1 || aEvent.getModifierState("Accel"))) {
               where = "tab";
               params = {
                 inBackground: true,
               };
             }
           }
@@ -1778,18 +1780,20 @@
             where = "tab";
             if (Services.prefs.getBoolPref("browser.tabs.loadInBackground")) {
               params = {
                 inBackground: true,
               };
             }
           } else {
             var newTabPref = Services.prefs.getBoolPref("browser.search.openintab");
-            if (((aEvent instanceof KeyboardEvent) && aEvent.altKey) ^ newTabPref)
+            if (((aEvent instanceof KeyboardEvent && aEvent.altKey) ^ newTabPref) &&
+                !isTabEmpty(gBrowser.selectedTab)) {
               where = "tab";
+            }
             if ((aEvent instanceof MouseEvent) &&
                 (aEvent.button == 1 || aEvent.getModifierState("Accel"))) {
               where = "tab";
               params = {
                 inBackground: true,
               };
             }
           }